Draw rectangle on screen
Aleksey Murushkin (Cloverleaf) (8233) 41 posts |
Hi. Is it possible to draw on screen a rectangle and then clear it so the picture under it is restored? I need it to display the dragging area over the screen. |
Andy S (2979) 504 posts |
I would use sprite functions (I know you love them :) ) to copy the rectangular area of the picture to a sprite area, draw your rectangle and then to restore it just plot the sprite. Or if you’re trying to implement a drag and drop function, RISC OS may already have a way to do that for you. |
Jeffrey Lee (213) 6048 posts |
Drag boxes are usually rendered using exclusive-or plotting (os_ACTION_EXCLUSIVE_DISJOIN in OSLib). That way you can erase the rectangle just by plotting back over the same pixels. colourtrans_set_gcol(0xffffff00, 0, os_ACTION_EXCLUSIVE_DISJOIN); If you need to do anything more complex (e.g. draw a specific image) then you’ll probably have to copy part of the screen to a sprite, like Andy suggests. That’s how icon drags are handled – the DragASprite module keeps a copy of the area under the dragged sprite/icon (and uses a couple of extra temporary copies in order to avoid redraw flicker when the image needs moving). |
Aleksey Murushkin (Cloverleaf) (8233) 41 posts |
Many thanks. it worked. Where can I read about all these actions? I failed to find a description of them. At StrongHelp I see only the list of them. |
Jeffrey Lee (213) 6048 posts |
We have a list on the wiki: https://www.riscosopen.org/wiki/documentation/show/GCOL%20action |