Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Photoshop style Gradients

 [1/3] 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.

 [2/3] from: james:mustard at: 27-Mar-2002 11:29


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.

 [3/3] from: james:mustard at: 27-Mar-2002 15:50


This is a slightly modified application of the function with gradient and colour blocks for easy switching. REBOL [ Title: "Custom Gradients" Author: "James Marsden" Version: 0.1.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 c][ 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 "]" ] ] mycol: [ [135.0.0 255.0.0 255.133.64 255.255.0] [255.0.0 255.64.0 255.128.0 255.196.0 255.255.0 196.255.0] [196.255.0 128.255.0 64.255.0 0.255.0 0.255.64 0.255.128] [0.255.128 0.255.196 0.255.255 0.196.255 0.128.255 0.64.255] [0.64.255 0.0.255 64.0.255 128.0.255 196.0.255 255.0.255] [255.0.196 255.0.128 255.0.64 255.0.0 255.64.0 255.128.0] ] mygrad: [ [0 32 66 100] [0 20 40 60 80 100] ] ; show the screen view desktop: layout/size/offset [ backcolor black at 0x0 image to-image (multigrad mycol/1 mygrad/1 1x0 system/view/screen-face/size * 1x0 + 0x20) edge [size: 1x1 color: black] Custom Gradients - Click to close [unview desktop] image to-image multigrad mycol/2 mygrad/2 1x0 400x10 image to-image multigrad mycol/3 mygrad/2 1x0 400x10 image to-image multigrad mycol/4 mygrad/2 1x0 400x10 image to-image multigrad mycol/5 mygrad/2 1x0 400x10 image to-image multigrad mycol/6 mygrad/2 1x0 400x10 ] system/view/screen-face/size 0x0 Regards, James.