Rubber-banding
BlitzPlus Forums/BlitzPlus Programming/Rubber-banding
| ||
Help a poor beginner please... I'm writing a drawing program and need to "rubber-band" lines. In other languages there's an exclusive-OR drawing mode that handles this. How's it done in Blitz? |
| ||
First, I think an image would have helped, but I think I know what you are talking about. I'm not aware that Blitz can draw such a line. This doesn't prevent you from tackling it yourself though (which would be very possible). One thing to consider about drawing such a line is that you must take into consideration how you are going to handle "exclusive-OR"'ing for colors or grays as well as black and white (unless you are not dealing with colors or grays). |
| ||
Thanks WolRon for answering so quickly. It would be nice if Blitz could do it but never mind, I'll try another way. |
| ||
Unless I have missed the point... Line x,y,x1,y1 will draw a line from one point to another. So you have your background saved in a buffer or whatever... Draw Background Draw Line the first X and Y would be set when you first click. The latter X1 and Y1 would be updated until you let go (or whatever controls you want, maybe until you click again?). If you need a special kind of line, then there are a couple of generic line drawing functions in the code archives. |
| ||
What I did was save the background pixels underneath the lines of the band into a small array or bank, draw the lines, then keep swapping buffers and restoring what was saved while the mouse button is down - probably not very professional but it works fine. The cycle is this [save the pixels where the lines of the band will go] [draw the band] [vwait] [flip buffers] [draw saved pixels] If you want the band to remain on screen, which I did, then just omit the final redrawing. |