Browse code

Fixed mouse pickin g for noodle

neauoire authored on 25/03/2021 16:24:26
Showing 2 changed files
1 1
new file mode 100644
2 2
Binary files /dev/null and b/projects/pictures/macpaint4020.bit differ
... ...
@@ -41,7 +41,7 @@
41 41
 ;canvas { x1 2 y1 2 x2 2 y2 2 w 2 h 2 }
42 42
 
43 43
 ;rect { x1 2 y1 2 x2 2 y2 2 }
44
-;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
44
+;line { x1 2 y1 2 x2 2 y2 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
45 45
 ;origin { x1 2 y1 2 x2 2 y2 2 }
46 46
 ;color { byte 1 }
47 47
 ;pt0 { x 2 y 2 }
... ...
@@ -66,7 +66,7 @@
66 66
 |0200 @RESET 
67 67
 	
68 68
 	( default canvas )
69
-	#002a =canvas.w #001a =canvas.h
69
+	#0020 =canvas.w #0010 =canvas.h
70 70
 
71 71
 	( default brush )
72 72
 	#04 =brush.size
... ...
@@ -92,7 +92,7 @@
92 92
 	#0010 =pattpane.x1 ~Screen.height #0018 SUB2 =pattpane.y1
93 93
 	~Screen.width #0050 SUB2 =sizepane.x1 #0010 =sizepane.y1
94 94
 
95
-	~toolpane.x1 #0020 ADD2 =toolpane.x2
95
+	~toolpane.x1 #0028 ADD2 =toolpane.x2
96 96
 	~toolpane.y1 #0008 ADD2 =toolpane.y2
97 97
 	,draw-toolpane JSR2
98 98
 
... ...
@@ -210,16 +210,20 @@ BRK
210 210
 				,$touch-end JMP2
211 211
 			$no-touch-brush
212 212
 
213
+			,$no-touch-zoom ~brush.tool #04 NEQ JMP2?
214
+				~zoom.active #00 EQU =zoom.active
215
+				( release ) #00 =Mouse.state
216
+				~Mouse.x ~canvas.x1 SUB2 ~canvas.w 2/ SUB2 =zoom.x
217
+				~Mouse.y ~canvas.y1 SUB2 ~canvas.h 2/ SUB2 =zoom.y
218
+				,redraw JSR2
219
+				,$touch-end JMP2
220
+			$no-touch-zoom
221
+
213 222
 		$no-touch-canvas
214 223
 
215 224
 		( background interface )
216 225
 		,$no-touch-background ~Mouse.y STEP8 ~Screen.height #0010 SUB2 NEQ2 JMP2?
217 226
 			~Mouse.x ~Screen.width #0020 SUB2 SUB2 8/ 
218
-			DUP2 #0000 NEQ2 ,$no-toggle-zoom ROT JMP2?
219
-				~zoom.active #00 EQU =zoom.active
220
-				( release ) #00 =Mouse.state
221
-				,redraw JSR2
222
-			$no-toggle-zoom
223 227
 			DUP2 #0001 NEQ2 ,$no-load-button ROT JMP2?
224 228
 				,filepath ,load-file JSR2
225 229
 				,draw-canvas JSR2
... ...
@@ -262,6 +266,8 @@ BRK
262 266
 			( tool0 ) #02 =brush.tool ,draw-toolpane JSR2 $no-ekey
263 267
 		DUP #72 NEQ ,$no-rkey ROT JMP2?
264 268
 			( tool0 ) #03 =brush.tool ,draw-toolpane JSR2 $no-rkey
269
+		DUP #74 NEQ ,$no-tkey ROT JMP2?
270
+			( tool0 ) #04 =brush.tool ,draw-toolpane JSR2 $no-tkey
265 271
 		DUP 
266 272
 			DUP #30 GTH SWP #39 LTH #0101 NEQ2 ,$no-numkey ROT JMP2?
267 273
 			( size ) ~Keys #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey
... ...
@@ -311,23 +317,32 @@ RTN
311 317
 
312 318
 @paint-line ( x1 y1 x2 y2 )
313 319
 	
314
-	( load ) =line.y0 =line.x0 =line.y =line.x
315
-	~line.x0 ~line.x SUB2 ABS2 =line.dx
316
-	~line.y0 ~line.y SUB2 ABS2 #0000 SWP2 SUB2 =line.dy
317
-	#ffff #00 ~line.x ~line.x0 LTS2 #0002 MUL2 ADD2 =line.sx 
318
-	#ffff #00 ~line.y ~line.y0 LTS2 #0002 MUL2 ADD2 =line.sy 
320
+	( load ) =line.y1 =line.x1 =line.y2 =line.x2
321
+
322
+	( trim if zoomed )
323
+	,$no-zoom ~zoom.active #01 NEQ JMP2?
324
+		~line.x1 8/ ~zoom.x ADD2 =line.x1
325
+		~line.y1 8/ ~zoom.y ADD2 =line.y1
326
+		~line.x2 8/ ~zoom.x ADD2 =line.x2
327
+		~line.y2 8/ ~zoom.y ADD2 =line.y2
328
+	$no-zoom
329
+
330
+	~line.x1 ~line.x2 SUB2 ABS2 =line.dx
331
+	~line.y1 ~line.y2 SUB2 ABS2 #0000 SWP2 SUB2 =line.dy
332
+	#ffff #00 ~line.x2 ~line.x1 LTS2 #0002 MUL2 ADD2 =line.sx 
333
+	#ffff #00 ~line.y2 ~line.y1 LTS2 #0002 MUL2 ADD2 =line.sy 
319 334
 	~line.dx ~line.dy ADD2 =line.e1
320 335
 	$loop
321
-		( paint ) ~line.x ~line.y ~brush.oper JSR2
322
-		,$end ~line.x ~line.x0 EQU2 ~line.y ~line.y0 EQU2 #0101 EQU2 JMP2?
336
+		( paint ) ~line.x2 ~line.y2 ~brush.oper JSR2
337
+		,$end ~line.x2 ~line.x1 EQU2 ~line.y2 ~line.y1 EQU2 #0101 EQU2 JMP2?
323 338
 		~line.e1 #0002 MUL2 =line.e2
324 339
 		,$skipy ~line.e2 ~line.dy LTS2 JMP2?
325 340
 			~line.e1 ~line.dy ADD2 =line.e1
326
-			~line.x ~line.sx ADD2 =line.x
341
+			~line.x2 ~line.sx ADD2 =line.x2
327 342
 		$skipy
328 343
 		,$skipx ~line.e2 ~line.dx GTS2 JMP2?
329 344
 			~line.e1 ~line.dx ADD2 =line.e1
330
-			~line.y ~line.sy ADD2 =line.y
345
+			~line.y2 ~line.sy ADD2 =line.y2
331 346
 		$skipx
332 347
 		,$loop JMP2
333 348
 
... ...
@@ -342,7 +357,19 @@ RTN
342 357
 
343 358
 @paint-rect ( x1 y1 x2 y2  )
344 359
 
345
-	( load ) =rect.y2 =rect.x2 DUP2 =pt2.y =rect.y1 DUP2 =pt2.x =rect.x1
360
+	( load ) =rect.y2 =rect.x2 =rect.y1 =rect.x1
361
+
362
+	( trim if zoomed )
363
+	,$no-zoom ~zoom.active #01 NEQ JMP2?
364
+		~rect.x1 8/ ~zoom.x ADD2 =rect.x1
365
+		~rect.y1 8/ ~zoom.y ADD2 =rect.y1
366
+		~rect.x2 8/ ~zoom.x ADD2 #0001 ADD2 =rect.x2
367
+		~rect.y2 8/ ~zoom.y ADD2 #0001 ADD2 =rect.y2
368
+	$no-zoom
369
+
370
+	~rect.x1 =pt2.x
371
+	~rect.y1 =pt2.y
372
+
346 373
 	$ver
347 374
 		~rect.x1 =pt2.x
348 375
 		$hor
... ...
@@ -351,9 +378,9 @@ RTN
351 378
 				( draw ) ~pt2.x ~pt2.y ~brush.oper JSR2
352 379
 			$no-pixel
353 380
 			( incr ) ~pt2.x ++ =pt2.x
354
-			,$hor ~pt2.x ~rect.x2 LTH2 JMP2?
381
+			,$hor ~pt2.x ~rect.x2 LTS2 JMP2?
355 382
 		~pt2.y ++ =pt2.y
356
-		,$ver ~pt2.y ~rect.y2 LTH2 JMP2?
383
+		,$ver ~pt2.y ~rect.y2 LTS2 JMP2?
357 384
 
358 385
 	,draw-canvas JSR2
359 386
 	,draw-toolpane JSR2
... ...
@@ -372,12 +399,6 @@ RTN
372 399
 		~pt0.y 8/ ~zoom.y ADD2 #0003 SUB2 =pt0.y
373 400
 	$no-zoom
374 401
 
375
-	( center zoom on paint )
376
-	,$no-follow ~zoom.active JMP2?
377
-		~pt0.x ~canvas.w 2/ SUB2 #0003 ADD2 =zoom.x
378
-		~pt0.y ~canvas.h 2/ SUB2 #0003 ADD2 =zoom.y
379
-	$no-follow
380
-
381 402
 	#00 =px.x #00 =px.y 
382 403
 	$ver
383 404
 		#00 =px.x
... ...
@@ -592,6 +613,12 @@ RTN
592 613
 		( incr ) ~Sprite.addr 8+ =Sprite.addr
593 614
 		,$tools ~Sprite.x ~toolpane.x2 LTH2 JMP2?
594 615
 
616
+	,$no-zoom ~zoom.active #01 NEQ JMP2?
617
+		~Sprite.x #0008 SUB2 =Sprite.x
618
+		,tool_icn #0028 ADD2 =Sprite.addr
619
+		#01 #04 ~brush.tool EQU #02 MUL ADD =Sprite.color
620
+	$no-zoom
621
+
595 622
 RTN
596 623
 
597 624
 @draw-pattpane
... ...
@@ -657,11 +684,9 @@ RTN
657 684
 	,save_icn =Sprite.addr
658 685
 	#01 =Sprite.color
659 686
 	~Screen.width #0020 SUB2 =Sprite.x
660
-	,zoom_icn #00 ~zoom.active 8* ADD2 =Sprite.addr
661
-	#01 =Sprite.color
662 687
 
663 688
 	( draw width )
664
-	~Screen.width #0048 SUB2 =Sprite.x
689
+	~Screen.width #0040 SUB2 =Sprite.x
665 690
 	,font_hex ~canvas.w #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
666 691
 	( draw ) #02 =Sprite.color
667 692
 	~Sprite.x 8+ =Sprite.x
... ...
@@ -735,11 +760,8 @@ RTN
735 760
 	[ e0d0 a844 2212 0c00 ]
736 761
 	[ c0b8 4848 7804 0200 ]
737 762
 	[ 44ba 4444 44ba 4400 ]
738
-	[ 3844 8282 8244 3800 ]
739
-	[ fe82 8282 8282 fe00 ]
740
-	[ 80c0 e0f0 f8e0 1000 ]
741
-	[ 0202 0438 4080 8000 ]
742
-	[ 0204 0810 2040 8000 ]
763
+	[ 3048 8484 4834 0200 ] ( zoom )
764
+	[ 3245 8284 4834 0200 ] ( zoom out )
743 765
 
744 766
 @brush_view 
745 767
 	[ 0000 0010 0000 0000 ]
... ...
@@ -752,10 +774,6 @@ RTN
752 774
 	[ 7c82 8282 8282 7c00 ]
753 775
 	[ 7cfe fefe fefe 7c00 ]
754 776
 
755
-@zoom_icn
756
-	[ 3048 8484 4834 0200 ]
757
-	[ 3245 8284 4834 0200 ]
758
-
759 777
 @bigpixel_icn 
760 778
 	[ 5580 0080 0080 0080 ]
761 779
 	[ 55ff 7fff 7fff 7fff ]
... ...
@@ -768,7 +786,7 @@ RTN
768 786
 @save_icn       [ fe82 8282 848a f400 ]
769 787
 
770 788
 @blank_icn      [ 0000 0000 0000 0000 ]
771
-@filepath       [ projects/pictures/tima2a1a.bit 00 ]
789
+@filepath       [ projects/pictures/akane2010.bit 00 ]
772 790
 
773 791
 @font_hex ( 0-F ) 
774 792
 [