Added eraser

This commit is contained in:
Devine Lu Linvega 2024-05-31 11:52:32 -07:00
parent f897d6f5be
commit 149c04a2cc
3 changed files with 38 additions and 21 deletions

Binary file not shown.

View File

@ -16,6 +16,9 @@
@pen-icn [
c0e0 9090 4848 2424 1212 0909 0600 0000 ]
@eraser-icn [
7e81 8181 8181 8181 8181 8181 7e00 0000 ]
@bar-icn &a [
0000 007e 007e 007e 007e 007e 007e 0000 ]
&b [

View File

@ -38,7 +38,7 @@
( name ) "Note 20 "Pad 0a
( details ) "Original 20 "by 20 "Donn 20 "Denman 0a
( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
( date ) "May 20 "30, 20 "2024 00 01
( date ) "May 20 "31, 20 "2024 00 01
( icon ) 83 =appicon
(
@ -117,27 +117,29 @@
POP BRK
@on-mouse-sketch ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;pen-icn <update-cursor>
[ LIT2 00 -Mouse/state ] DEI STHk NEQ #41 ADD ;eraser-icn ;pen-icn STHr #01 GTH ?{ SWP2 }
POP2 <update-cursor>
( | handle states )
[ LIT &last $1 ] .Mouse/state DEI DUP ,&last STR
( ) DUP2 #0100 NEQ2 ?{ file-save }
( ) DUP2 #0200 NEQ2 ?{ file-save }
DUP2 #0200 NEQ2 ?{
( from ) ,&x1 LDR2 ,&y1 LDR2
( to x ) ,&x1 LDR2 .Mouse/x DEI2 snap
( to y ) ,&y1 LDR2 .Mouse/y DEI2 #0012 SUB2 snap
( paint ) #01 <paint-line>
<draw-sketch> }
DUP2 #00 NEQ #0001 NEQ2 ?{
[ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{ POP #02 }
DUP ,&last STR
( ) SWPk #00 NEQ #0001 NEQ2 ?{ file-save }
DUP2 #0001 NEQ2 ?{
( | down mouse1 )
.Mouse/x DEI2 DUP2 ,&x1 STR2
.Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2
#01 set-pixel <draw-sketch> }
DUP2 #0101 NEQ2 ?{
#01 <set-pixel>
<draw-sketch> }
DUP #01 NEQ ?{
( release/drag mouse1 )
( from* ) [ LIT2 &x1 $2 ] [ LIT2 &y1 $2 ]
( to ) .Mouse/x DEI2 DUP2 ,&x1 STR2
.Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2
( paint ) #01 <paint-line>
<draw-sketch> }
DUP #02 NEQ2 ?{
( | release/drag mouse2 )
.Mouse/x DEI2 .Mouse/y DEI2 #0012 SUB2 <eraser>
<redraw> }
POP2 BRK
@on-mouse-foot ( -> )
@ -201,8 +203,7 @@
@toggle-sketch ( -- )
.selection/sketch LDZk #01 EOR SWP STZ
#41 ;pen-icn ;caret-icn .selection/sketch LDZ ?{ SWP2 }
POP2 <update-cursor>
JMP2r
POP2 !<update-cursor>
@erase-sketch ( -- )
;&mcpy .System/expansion DEO2
@ -212,24 +213,37 @@
@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
@<set-pixel> ( x* y* color -- )
?<add-pixel>
( >> )
@remove-pixel ( x* y* -- )
@<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* -- )
@<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
@<eraser> ( x* y* -- )
,&y STR2
,&x STR2
#000a #0000
&>v ( -- )
STH2k #0006 #0000
&>h ( -- )
( x ) DUP2 [ LIT2 &x $2 ] ADD2
( y ) STH2kr [ LIT2 &y $2 ] ADD2 <remove-pixel>
INC2 GTH2k ?&>h
POP2 POP2 POP2r INC2 GTH2k ?&>v
POP2 POP2 JMP2r
@<paint-line> ( x1* y1* x2* y2* color -- )
,&color STR
,&y STR2
@ -242,7 +256,7 @@
#ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
[ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2
&>while ( -- )
( draw ) ,&x2 LDR2 ,&y2 LDR2 [ LIT &color $1 ] set-pixel
( draw ) ,&x2 LDR2 ,&y2 LDR2 [ LIT &color $1 ] <set-pixel>
( x ) [ LIT2 &x2 $2 ] [ LIT2 &x $2 ] EQU2
( y ) [ LIT2 &y2 $2 ] [ LIT2 &y $2 ] EQU2 AND ?&end
STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?{