[REBOL] Photoshop style Gradients
From: james::mustard::co::nz at: 27-Mar-2002 11:48
This message may be repeated (sorry) - my messages never seem to reach the
list so this is a last ditch attempt...
The following function is just a little something i whipped up to make
gradient images on the fly rather than save a lot of pre-generated images.
Any comments on making it more flexible etc would be appreciated ;-)
REBOL [
Title: "Custom Gradients"
Author: "James Marsden"
Version: 0.1
Date: 27-Mar-2002
Comment: {
this release allows you to perform standard X / Y gradient fills
similar to the gradient tools in photoshop / gimp / paintshop pro
'n' degree free gradients will have to wait for a new view release
due to constraints on rotate
}
]
multigrad: func [colours [block!] Pc [block!] LxL [pair!] Sz [pair!] /local
l][
if (length? colours) = (length? Pc) [
l: join "layout [ origin 0x0 space 0x0 " either LxL/x <> 0 ["across
^/"]["below ^/"]
for c 1 (length? colours) - 1 1 [
either LxL/x <> 0 [
l: join l ["box " to-integer ((pick Pc c + 1) - (pick Pc c))
* (Sz/x / 100) "x" Sz/y]
][
l: join l ["box " Sz/x "x" to-integer ((pick Pc c + 1) -
(pick Pc c)) * (Sz/y / 100)]
]
l: join l [" effect [gradient " LxL " " (pick colours c) " "
(pick colours c + 1) "]^/" ]
]
do l: join l "]"
]
]
mycolours: [
135.0.0
255.0.0
255.133.64
255.255.0
]
altcolours: [
224.224.224
255.133.64
255.0.0
]
i: multigrad mycolours [0 32 66 100] 1x0 200x20
j: multigrad mycolours [0 32 66 100] 0x1 20x180
k: multigrad altcolours [0 50 100] 1x0 45x45
view layout/size [
at 0x0 image to-image i
at 0x20 image to-image j effect [rotate 180]
at 20x20 image to-image k 180x180 effect [tile]
] 200x200
Regards,
James.