Browse code

Fixed drag example

neauoire authored on 17/02/2021 05:36:51
Showing 1 changed files
... ...
@@ -11,8 +11,9 @@
11 11
 	#05 =dev/r ( set dev/read mouse )
12 12
 	#01 =dev/w ( set dev/write to screen ) 
13 13
 
14
-	#02 =color
15
-	#0050 =w #0080 =h ,update JSR
14
+	#02 =color ( starting color )
15
+	#0050 =w #0080 =h ( starting size )
16
+	,update JSR
16 17
 
17 18
 BRK
18 19
 
... ...
@@ -26,21 +27,18 @@ BRK
26 27
 
27 28
 	@on-touch
28 29
 		#01 =down
29
-		#01 =color
30
+		#03 =color
30 31
 		#00 IOR2 =touchx #02 IOR2 =touchy
31 32
 		,update JSR
32 33
 	BRK
34
+
33 35
 	@on-release
34 36
 		#00 =down
35
-		#02 =color
37
+		#01 =color
36 38
 		,update JSR
37 39
 	BRK
38
-	@on-drag
39
-
40
-		( clear last rect )
41
-		#00 =color
42
-		~x ~y ~w ~h ,fillrect JSR
43 40
 
41
+	@on-drag
44 42
 		#00 IOR2 ~touchx SUBS2 ~x ADDS2 =x
45 43
 		#02 IOR2 ~touchy SUBS2 ~y ADDS2 =y
46 44
 		#00 IOR2 =touchx #02 IOR2 =touchy
... ...
@@ -48,14 +46,9 @@ BRK
48 46
 	BRK
49 47
 
50 48
 	@update
51
-
52
-		( draw new rect )
53
-		#03 =color
54
-		~x ~y ~w ~h ,linerect JSR
55
-
56
-		#0000 ,rounds_chr ~x #0010 ADD2 ~y #0010 ADD2 ,drawsprite JSR
57
-		#0100 ,eyeeye_chr ~x #0040 ADD2 ~y #0020 ADD2 ,drawsprite JSR
58
-
49
+		( draw ) ~x ~y ~w ~h ,linerect JSR
50
+		( draw ) #0000 ,rounds_chr ~x #0010 ADD2 ~y #0010 ADD2 ,drawsprite JSR
51
+		( draw ) #0100 ,eyeeye_chr ~x #0040 ADD2 ~y #0020 ADD2 ,drawsprite JSR
59 52
 		,redraw JSR
60 53
 	BRK
61 54
 
... ...
@@ -82,18 +75,18 @@ BRK
82 75
 	RTS
83 76
 
84 77
 @linerect
85
-	,h STR2 ,w STR2 ,y STR2 ,x STR2
86
-	,x LDR2 ,drawx STR2 ,y LDR2 ,drawy STR2
78
+	=h =w =y =x
79
+	~x =drawx ~y =drawy
87 80
 	@linerectcol
88
-		( draw ) ,x LDR2 ,drawy LDR2 ,putpixel JSR
89
-		( draw ) ,x LDR2 ,w LDR2 ADD2 ,drawy LDR2 ,putpixel JSR
90
-		,drawy LDR2 #0001 ADD2 ,drawy STR2 
91
-		,drawy LDR2 ,h LDR2 ,y LDR2 ADD2 LTH2 ,linerectcol ROT JMP? POP2
81
+		( draw ) ~x ~drawy ,putpixel JSR
82
+		( draw ) ~x ~w ADD2 ~drawy ,putpixel JSR
83
+		~drawy #0001 ADD2 =drawy 
84
+		~drawy ~h ~y ADD2 LTH2 ,linerectcol ROT JMP? POP2
92 85
 	@linerectrow
93
-		( draw ) ,drawx LDR2 ,y LDR2 ,putpixel JSR
94
-		( draw ) ,drawx LDR2 ,y LDR2 ,h LDR2 ADD2 ,putpixel JSR
95
-		,drawx LDR2 #0001 ADD2 ,drawx STR2 
96
-		,drawx LDR2 ,w LDR2 ,x LDR2 ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
86
+		( draw ) ~drawx ~y ,putpixel JSR
87
+		( draw ) ~drawx ~y ~h ADD2 ,putpixel JSR
88
+		~drawx #0001 ADD2 =drawx 
89
+		~drawx ~w ~x ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
97 90
 	RTS
98 91
 
99 92
 @getmouse