processing: use color objects
parent
19feaebb19
commit
1324f6e096
|
@ -9,9 +9,9 @@ USING: kernel namespaces threads combinators sequences arrays
|
||||||
combinators.lib
|
combinators.lib
|
||||||
combinators.cleave
|
combinators.cleave
|
||||||
rewrite-closures fry accessors newfx
|
rewrite-closures fry accessors newfx
|
||||||
processing.color
|
|
||||||
processing.gadget math.geometry.rect
|
processing.gadget math.geometry.rect
|
||||||
processing.shapes ;
|
processing.shapes
|
||||||
|
colors ;
|
||||||
|
|
||||||
IN: processing
|
IN: processing
|
||||||
|
|
||||||
|
@ -39,27 +39,32 @@ IN: processing
|
||||||
|
|
||||||
GENERIC: canonical-color-value ( obj -- color )
|
GENERIC: canonical-color-value ( obj -- color )
|
||||||
|
|
||||||
METHOD: canonical-color-value { number } dup dup 1 4array ;
|
METHOD: canonical-color-value { number } dup dup 1 rgba boa ;
|
||||||
|
|
||||||
METHOD: canonical-color-value { array }
|
METHOD: canonical-color-value { array }
|
||||||
dup length
|
dup length
|
||||||
{
|
{
|
||||||
{ 2 [ first2 >r dup dup r> 4array ] }
|
{ 2 [ first2 >r dup dup r> rgba boa ] }
|
||||||
{ 3 [ 1 suffix ] }
|
{ 3 [ first3 1 rgba boa ] }
|
||||||
{ 4 [ ] }
|
{ 4 [ first4 rgba boa ] }
|
||||||
}
|
}
|
||||||
case ;
|
case ;
|
||||||
|
|
||||||
METHOD: canonical-color-value { rgba }
|
! METHOD: canonical-color-value { rgba }
|
||||||
{ [ red>> ] [ green>> ] [ blue>> ] [ alpha>> ] } cleave 4array ;
|
! { [ red>> ] [ green>> ] [ blue>> ] [ alpha>> ] } cleave 4array ;
|
||||||
|
|
||||||
|
METHOD: canonical-color-value { color } ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
: fill ( value -- ) canonical-color-value >fill-color ;
|
: fill ( value -- ) canonical-color-value >fill-color ;
|
||||||
: stroke ( value -- ) canonical-color-value >stroke-color ;
|
: stroke ( value -- ) canonical-color-value >stroke-color ;
|
||||||
|
|
||||||
: no-fill ( -- ) 0 fill-color> set-fourth ;
|
! : no-fill ( -- ) 0 fill-color> set-fourth ;
|
||||||
: no-stroke ( -- ) 0 stroke-color> set-fourth ;
|
! : no-stroke ( -- ) 0 stroke-color> set-fourth ;
|
||||||
|
|
||||||
|
: no-fill ( -- ) fill-color> 0 >>alpha drop ;
|
||||||
|
: no-stroke ( -- ) stroke-color> 0 >>alpha drop ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue