Drawing primitives

This commit is contained in:
Devine Lu Linvega 2024-05-29 09:09:20 -07:00
parent f271a33518
commit d466fdec7b
3 changed files with 35 additions and 4 deletions

View File

@ -10,7 +10,7 @@
@page $1 @page $1
@collapsed $1 @collapsed $1
@selection &a $2 &b $2 &length $2 @selection &a $2 &b $2 &length $2 &sketch $1
|100 |100
@ -18,9 +18,9 @@
( | meta ) ( | meta )
;meta #06 DEO2 ;meta #06 DEO2
( | theme ) ( | theme )
#f0cf .System/r DEO2 #f0ff .System/r DEO2
#f0cf .System/g DEO2 #f00f .System/g DEO2
#f0cf .System/b DEO2 #f00f .System/b DEO2
load-theme load-theme
( | size ) ( | size )
#00e0 .Screen/width DEO2 #00e0 .Screen/width DEO2
@ -31,6 +31,7 @@
;on-frame .Screen/vector DEO2 ;on-frame .Screen/vector DEO2
;on-control .Controller/vector DEO2 ;on-control .Controller/vector DEO2
( | let's go! ) ( | let's go! )
#01 .selection/sketch STZ
file-init <draw-header> file-init <draw-header>
#00 change-page BRK #00 change-page BRK
@ -100,6 +101,7 @@
&unchanged BRK &unchanged BRK
@on-mouse-body ( -> ) @on-mouse-body ( -> )
.selection/sketch LDZ ?on-mouse-body-draw
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;caret-icn <update-cursor> [ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;caret-icn <update-cursor>
<trap-mouse> <trap-mouse>
[ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{ [ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{
@ -110,6 +112,11 @@
,&last STR ,&last STR
POP BRK POP BRK
@on-mouse-body-draw ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;mouse-icn <update-cursor>
.Mouse/x DEI2 .Mouse/y DEI2 #0012 SUB2 #01 set-pixel <draw-sketch>
BRK
@on-mouse-foot ( -> ) @on-mouse-foot ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;mouse-icn <update-cursor> [ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;mouse-icn <update-cursor>
<trap-mouse> <trap-mouse>
@ -432,6 +439,30 @@
INC2 GTH2k ?&>l INC2 GTH2k ?&>l
&end NIP2 JMP2r &end NIP2 JMP2r
(
@|sketch )
@get-row ( x* y* -- row* )
STH2k #03 SFT2 SWP2 #03 SFT2 SWP2 #001c MUL2 ADD2 #30 SFT2 STH2r #0007 AND2 ADD2 ;sketch ADD2 JMP2r
@set-pixel ( x* y* color -- )
?add-pixel
( >> )
@remove-pixel ( x* y* -- )
( keep x* ) OVR2 NIP #07 AND STH
( get byte ) get-row LDAk
( mask ) #0107 STHr SUB #40 SFT SFT #ff EOR AND
( save ) ROT ROT STA
JMP2r
@add-pixel ( x* y* -- )
( keep x* ) OVR2 NIP #07 AND STH
( get byte ) get-row LDAk
( mask ) #0107 STHr SUB #40 SFT SFT ORA
( save ) ROT ROT STA
JMP2r
( (
@|drawing ) @|drawing )

Binary file not shown.