2023-12-11 13:42:14 +01:00
|
|
|
~~~
|
2024-09-18 02:40:34 +02:00
|
|
|
:pixel (:xyc-) #33 io:scan-for io:invoke ;
|
|
|
|
:get-pixel (:xy-c) #34 io:scan-for io:invoke ;
|
|
|
|
:mouse (:-xyb) #35 io:scan-for io:invoke ;
|
2023-12-11 13:42:14 +01:00
|
|
|
|
2024-09-18 02:40:34 +02:00
|
|
|
:hline (:xyw-)
|
2023-12-11 13:42:14 +01:00
|
|
|
[ dup-pair #1 pixel &n:inc dip ] times drop-pair ;
|
|
|
|
|
2024-09-18 02:40:34 +02:00
|
|
|
:vline (:xyh-)
|
2023-12-11 13:42:14 +01:00
|
|
|
[ dup-pair #1 pixel n:inc ] times drop-pair ;
|
|
|
|
|
2024-09-18 02:40:34 +02:00
|
|
|
:dline\ (:xyl-)
|
2023-12-11 13:42:14 +01:00
|
|
|
[ dup-pair #1 pixel &n:inc bi@ ] times drop-pair ;
|
|
|
|
|
2024-09-18 02:40:34 +02:00
|
|
|
:dline/ (:xyl-)
|
2023-12-11 13:42:14 +01:00
|
|
|
[ dup-pair #1 pixel &n:dec &n:inc bi* ] times drop-pair ;
|
|
|
|
|
|
|
|
'X var 'Y var 'H var 'W var
|
|
|
|
|
2024-09-18 02:40:34 +02:00
|
|
|
:rect (:xyhw-) !W !H !Y !X
|
2023-12-11 13:42:14 +01:00
|
|
|
@X @Y @W hline @X @Y @H n:add @W hline
|
|
|
|
@X @Y @H vline @X @W n:add @Y @H vline ;
|
|
|
|
|
|
|
|
'XC var 'YC var 'X var 'Y var
|
|
|
|
|
2024-09-18 02:40:34 +02:00
|
|
|
:octant (:xc,yc,x,y)
|
2023-12-11 13:42:14 +01:00
|
|
|
!Y !X !YC !XC
|
|
|
|
@XC @X n:add @YC @Y n:add #1 pixel
|
|
|
|
@XC @X n:sub @YC @Y n:add #1 pixel
|
|
|
|
@XC @X n:add @YC @Y n:sub #1 pixel
|
|
|
|
@XC @X n:sub @YC @Y n:sub #1 pixel
|
|
|
|
@XC @Y n:add @YC @X n:add #1 pixel
|
|
|
|
@XC @Y n:sub @YC @X n:add #1 pixel
|
|
|
|
@XC @Y n:add @YC @X n:sub #1 pixel
|
|
|
|
@XC @Y n:sub @YC @X n:sub #1 pixel ;
|
|
|
|
|
|
|
|
'XC var 'YC var 'X var 'Y var 'D var 'R var
|
|
|
|
|
2024-09-18 02:40:34 +02:00
|
|
|
:circle (:xyr-)
|
2023-12-11 13:42:14 +01:00
|
|
|
!R !YC !XC #0 !X @R [ !Y ] [ !D ] bi
|
|
|
|
@XC @YC @X @Y octant
|
|
|
|
[ &X v:inc
|
|
|
|
@D n:strictly-positive?
|
|
|
|
[ &Y v:dec @X @Y n:sub @R n:mul #2 n:mul @D n:add !D ]
|
|
|
|
[ #2 @R n:mul @X n:mul @D n:add !D ] choose
|
|
|
|
@XC @YC @X @Y octant
|
|
|
|
@Y @X gteq? ] while ;
|
|
|
|
|
|
|
|
'X var 'Y var 'C var 'D var 'R var
|
|
|
|
|
|
|
|
:t:raise #0 !C ;
|
|
|
|
:t:lower #1 !C ;
|
|
|
|
|
|
|
|
:t:left [ &X v:dec ] !D ;
|
|
|
|
:t:right [ &X v:inc ] !D ;
|
|
|
|
:t:up [ &Y v:dec ] !D ;
|
|
|
|
:t:down [ &Y v:inc ] !D ;
|
2024-09-18 02:40:34 +02:00
|
|
|
:t:at (:xy-) !Y !X ;
|
|
|
|
:t:forward (:n-) [ @X @Y @C pixel @D call ] times ;
|
2023-12-11 13:42:14 +01:00
|
|
|
|
|
|
|
#320 #240 t:at t:lower t:right
|
|
|
|
|
|
|
|
:t:down-right [ &Y v:inc &X v:inc ] !D ;
|
|
|
|
:t:down-left [ &Y v:inc &X v:dec ] !D ;
|
|
|
|
:t:up-left [ &Y v:dec &X v:dec ] !D ;
|
|
|
|
:t:up-right [ &Y v:dec &X v:inc ] !D ;
|
|
|
|
|
|
|
|
'Rotations d:create #8 ,
|
|
|
|
&t:right , &t:down-right , &t:down ,
|
|
|
|
&t:down-left , &t:left , &t:up-left ,
|
|
|
|
&t:up , &t:up-right ,
|
|
|
|
|
|
|
|
:t:rotate
|
|
|
|
&R v:inc @R #8 eq? [ #0 !R ] if &Rotations @R a:fetch call ;
|
|
|
|
~~~
|