step-tuple: func [ val [tuple!] /by step [tuple!] ][ if any [ 3 <> length? val ; can only step values of 3 segments val = 255.255.255 ] [make error! "Can't step tuple value"] either step [ either (val + step) <> val [val + step] [ make error! "Can't step tuple value" ] ][ steps: [0.0.1 0.1.0 1.0.0] for i 3 1 -1 [ either val/:i = 255 [val/:i: 0] [ return val + first steps ] steps: next steps ] ] ] ; foreach val [ ; 0.0.0 0.0.255 ; 0.1.0 0.255.0 0.255.255 ; 1.0.0 0.255.255 ; 254.255.255 255.255.254 ; 255.254.255 254.255.255 ; ][ ; print [val tab step-tuple val] ; ] ; print attempt [step-tuple 255.255.255] ; print attempt [step-tuple 255.255.255.0]
You need to create an account or log in to post comments to this site.