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

  • Nominations will close March 25th. If you'd like to join the board and influence how TinkerDifferent runs in the next year, put your name in now!
  • Hey Guest, MARCHintosh 2026 is upon us. Check out community projects, join GlobalTalk, and have fun!
Relating to ThinkC Development

pfuentes69

Active Tinkerer
Oct 27, 2021
380
297
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
293
228
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
297
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...