'============
'QuadDraw.bas v1.2
'============
'An odd little drawing program.
'Draws/paints in 4 sections of the screen at same time.
'Coded by Dav for QB64, APR/2020
'CREDIT: Many code enhanchments by Petr. Thanks Petr!
'Follow this programs development here:
'https://www.qb64.org/forum/index.php?topic=2467.0
'Added: UNDO last change by pressing U
'----------
'HOW TO USE:
'----------
'Left click = draws on screen.
'Right click = fills with color.
'Middle click = sets new color
'Use the +/- keys to resize brush size (1 to 50 allowed)
'Press 1,2,3 or 4 to set how many quads to draw, default is 4.
'Press U to undo last change
'Space = clears screen and starts over.
'ESC = Ends program
w~&
= _RGB32(255, 255, 255) 'used often, so variable it
CLS , w~&
'start with white screen
DIM SHARED size: size
= 10 'size of circle (brush)
quads = 4 'defaut, use 4 drawing quads
'====
main:
'====
NewColoredPen = swapColor(NIB, &HFF000000, b~&)
'If left button, draw on screen
_PUTIMAGE (x
- (size
+ 1), y
- (size
+ 1)), NewColoredPen
_PUTIMAGE (cx
- x
+ cx
- (size
+ 1), cy
- y
+ cy
- (size
+ 1)), NewColoredPen
_PUTIMAGE (x
- (size
+ 1), cy
- y
+ cy
- (size
+ 1)), NewColoredPen
_PUTIMAGE (cx
- x
+ cx
- (size
+ 1), y
- (size
+ 1)), NewColoredPen
'if right click, fill sections with color
SPAINT x
, y
, _RGB32(r
, g
, b
) '#, b~& SPAINT cx
- x
+ cx
, cy
- y
+ cy
, _RGB32(r
, g
, b
) ', b~& SPAINT x
, cy
- y
+ cy
, _RGB32(r
, g
, b
) ', b~& SPAINT cx
- x
+ cx
, y
, _RGB32(r
, g
, b
) ', b~&
'Select color
NewColoredPen = swapColor(NIB, &HFF000000, b~&)
'get keyboard input
size
= size
+ 1:
IF size
> 50 THEN size
= 50 size
= size
- 1:
IF size
< 1 THEN size
= 1
'FUNCTION by Petr
NIB
= _NEWIMAGE(size
* 2 + 1, size
* 2 + 1, 32) CIRCLE (size
, size
), size
, &HFF000000 PAINT (size
, size
), &HFF000000, &HFF000000
FUNCTION swapColor&
(oldHandle&
, oldcolor~&
, newcolor~&
) 'FUNCTION by Petr
a& = a& + 4
a& = a& + 1
SUB SPAINT
(x
AS INTEGER, y
AS INTEGER, clr~&
) 'Color everything in the X, Y position regardless of the border color. 'SUB by Petr
CASE 4 ' image is 32 bit image a& = a& + 4
PAINT (x
, y
), clr~&
, Back2~&
a& = 0
a& = a& + 4
CASE 1 ' image is 8 bit image (256 colors) Empty~&
= _RGBA(0, 0, 0, 0) a& = a& + 1
PAINT (x
, y
), clr~&
, Back2~&
a& = 0
a& = a& + 1