Tuesday, 27 November 2012

VID gradients

This is a collection of scripts about gradients in Rebol:
spec: [style grad box 160x160 font [color: yellow size: 24]]
vectors: [0x0 0x1 0x-1 | 1x0 1x1 1x-1 | -1x0 -1x1 -1x-1]
foreach v vectors [
    append spec either word? v ['return][
        compose/deep [grad form (v) effect [gradient (v) 200.0.0 0.0.200]
        ]
    ]
]
view layout spec


pic: load-thru/binary http://www.rebol.com/view/bay.jpg
page: does [
    foo: copy [backdrop 0.0.0 [unview/all view layout page]]
    loop 5 [loop 5 [append foo compose/deep [
        image pic 80x80 (random 255.255.255) with [effect: [fit gradcol (2x2 - random 3x3)
            (random 255.255.255) 0.0.0]]]]   append foo [return]
    ]
    append foo [backdrop [unview/all view layout page] with [color: none]]
]
view layout page

Click on the window to change gradients

pic: load-thru/binary http://www.rebol.com/view/bay.jpg
spec: [style grad box font [color: yellow size: 24]]
vectors: [0x0 0x1 0x-1 | 1x0 1x1 1x-1 | -1x0 -1x1 -1x-1]
foreach v vectors [
    append spec either word? v ['return][
        compose/deep [grad pic form (v) effect [gradcol (v) 200.0.0 0.0.200]
        ]
    ]
]
view layout spec



pairs: [1x0 -1x0 0x1 0x-1 1x1 -1x1 -1x-1 1x-1]
r-t: does [random 255.255.255]
r-s: does [50x50 + random 200x200]
r-v: does [pairs: next pairs all [tail? pairs pairs: head pairs] pairs/1]
view layout do page: does [
    foo: copy [backdrop 0.0.0]
    sz: r-s
    loop 3 [
    loop 3 [
        append foo compose/deep [box (sz) (form v: r-v) with [
            effect: [fit gradient (v)(r-t)(r-t)]]
            ]
        ]
    append foo [return]
    ]
    append foo [backdrop [unview/all view layout page] with [color: none]]
]



Click window to change

REBOL [
    Title: "Gradient Colorize Examples"
    Date: 22-May-2001/17:13:56-7:00
    Version: 1.0.0
    File: %grad-image.r
    Author: "Carl at REBOL"
    Purpose: "Applies multiple gradients to a single image."
    Email: carl@rebol.com
]
flash "Fetching image..."
img: load-thru/binary http://www.rebol.com/view/demos/nyc.jpg
unview
view layout [
    across backdrop 0.50.0
    style box box img 80
    vh1 "Gradient Colorize Examples"
    below guide
    box effect [fit gradcol]
    box yellow effect [fit gradcol]
    box effect [fit gradcol 200.0.0]
    box yellow effect [fit gradcol 200.0.0]
    box effect [fit gradcol 200.0.0 0.0.200]
    return
    box effect [fit gradcol 1x0]
    box yellow effect [fit gradcol 1x0]
    box effect [fit gradcol 1x0 200.0.0]
    box yellow effect [fit gradcol 1x0 200.0.0]
    box effect [fit gradcol 1x0 200.0.0 0.0.200]
    return
    box effect [fit gradcol -1x0]
    box yellow effect [fit gradcol -1x0]
    box effect [fit gradcol -1x0 200.0.0]
    box yellow effect [fit gradcol -1x0 200.0.0]
    box effect [fit gradcol -1x0 200.0.0 0.0.200]
    return
    box effect [fit gradcol 0x1]
    box yellow effect [fit gradcol 0x1]
    box effect [fit gradcol 0x1 200.0.0]
    box yellow effect [fit gradcol 0x1 200.0.0]
    box effect [fit gradcol 0x1 200.0.0 0.0.200]
    return
    box effect [fit gradcol 0x-1]
    box yellow effect [fit gradcol 0x-1]
    box effect [fit gradcol 0x-1 200.0.0]
    box yellow effect [fit gradcol 0x-1 200.0.0]
    box effect [fit gradcol 0x-1 200.0.0 0.0.200]
    return
    box effect [fit gradcol 1x1]
    box yellow effect [fit gradcol 1x1]
    box effect [fit gradcol 1x1 200.0.0]
    box yellow effect [fit gradcol 1x1 200.0.0]
    box effect [fit gradcol 1x1 200.0.0 0.0.200]
    return
    box effect [fit gradcol -1x1]
    box yellow effect [fit gradcol -1x1]
    box effect [fit gradcol -1x1 200.0.0]
    box yellow effect [fit gradcol -1x1 200.0.0]
    box effect [fit gradcol -1x1 200.0.0 0.0.200]
    return
    box effect [fit gradcol 1x-1]
    box yellow effect [fit gradcol 1x-1]
    box effect [fit gradcol 1x-1 200.0.0]
    box yellow effect [fit gradcol 1x-1 200.0.0]
    box effect [fit gradcol 1x-1 200.0.0 0.0.200]
    return
    box effect [fit gradcol -1x-1]
    box yellow effect [fit gradcol -1x-1]
    box effect [fit gradcol -1x-1 200.0.0]
    box yellow effect [fit gradcol -1x-1 200.0.0]
    box effect [fit gradcol -1x-1 200.0.0 0.0.200]
]







No comments:

Post a Comment