ThinkC How to draw a "rubber band line" (XOR)?

Relating to ThinkC Development

pfuentes69

Active Tinkerer
Oct 27, 2021
380
290
63
Switzerland
Hey,
for my project I need to make a tool to draw profiles as a sequence of segments.
The tool would allow to use the mouse to add points to the profile, and while drawing the current segment I want the mouse to draw a "rubber band" line and fix it when pressing the button, then add the next segment and so on.
In the past I developed this on PC and while drawing the "rubber band" I was drawing using "XOR Mode", so when the line was moving, it can overlap with existing lines without messing the existing drawing.

Can this be done in QuickDraw? How could I draw such a rubber band?

Txs!
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Right. If you want to get fancy, you can do a MacPaint-style “marching ants” marquee rectangle (instead of a Finder-style static-pattern rectangle) by xor’ing a sequence of striped patterns sequentially shifted by one pixel on a timer. One of the Scott Knaster books includes example code for this — I believe it’s the 1988 (2nd) edition of Macintosh Programming Secrets but it might be How to Write Macintosh Software.
 
  • Like
Reactions: pfuentes69

pfuentes69

Active Tinkerer
Oct 27, 2021
380
290
63
Switzerland
Right. If you want to get fancy, you can do a MacPaint-style “marching ants” marquee rectangle (instead of a Finder-style static-pattern rectangle) by xor’ing a sequence of striped patterns sequentially shifted by one pixel on a timer. One of the Scott Knaster books includes example code for this — I believe it’s the 1988 (2nd) edition of Macintosh Programming Secrets but it might be How to Write Macintosh Software.
In fact, the full book is available here: https://cdn.preterhuman.net/texts/computing/macintosh/Macintosh_C/

It seems to be "Macintosh C - A Hobbyist's Guide to Programming the Mac OS in C", written by K. J. Bricknell

It seems quite interesting...