QB64.org Forum

Active Forums => Programs => Topic started by: qbkiller101 on October 25, 2020, 12:20:26 pm

Title: Drawing App
Post by: qbkiller101 on October 25, 2020, 12:20:26 pm
Random drawing app made in 3 mins:
Code: QB64: [Select]
  1.         IF _MOUSEBUTTON(1) THEN
  2.             PSET (_MOUSEX, _MOUSEY), 7
  3.             PSET (_MOUSEX + 1, _MOUSEY), 7
  4.             PSET (_MOUSEX - 1, _MOUSEY), 7
  5.             PSET (_MOUSEX, _MOUSEY + 1), 7
  6.             PSET (_MOUSEX, _MOUSEY - 1), 7
  7.             PSET (_MOUSEX + 1, _MOUSEY + 1), 7
  8.             PSET (_MOUSEX - 1, _MOUSEY + 1), 7
  9.             PSET (_MOUSEX + 1, _MOUSEY - 1), 7
  10.             PSET (_MOUSEX - 1, _MOUSEY - 1), 7
  11.         ELSE IF _MOUSEBUTTON(2) THEN
  12.                 PSET (_MOUSEX, _MOUSEY), 0
  13.                 PSET (_MOUSEX + 1, _MOUSEY), 0
  14.                 PSET (_MOUSEX - 1, _MOUSEY), 0
  15.                 PSET (_MOUSEX, _MOUSEY + 1), 0
  16.                 PSET (_MOUSEX, _MOUSEY - 1), 0
  17.                 PSET (_MOUSEX + 1, _MOUSEY + 1), 0
  18.                 PSET (_MOUSEX - 1, _MOUSEY + 1), 0
  19.                 PSET (_MOUSEX + 1, _MOUSEY - 1), 0
  20.                 PSET (_MOUSEX - 1, _MOUSEY - 1), 0
  21.  
  22.             END IF
  23.         END IF
  24.     LOOP

Draws 9 pixels each time
right button for delete
left for draw
might expand on it and add saving options
Title: Re: Drawing App
Post by: bplus on October 25, 2020, 01:15:08 pm
Well I see you really knocked yourself out with this ;-))

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Title: Re: Drawing App
Post by: Rubidium on October 26, 2020, 01:35:47 pm

Hey qbkiller,

you can compact your code like this:

For y = -1 to 1
For x = -1 to 1
            PSET (_MOUSEX+x, _MOUSEY+y), 7
next:next

and again for black

then if u want a bigger draw square you can
have it range from -2 to 2 or set size as
-n to +n
Title: Re: Drawing App
Post by: bplus on October 26, 2020, 02:52:10 pm
Or this:
Code: QB64: [Select]
  1.         IF _MOUSEBUTTON(1) THEN
  2.             CIRCLE (_MOUSEX, _MOUSEY), 1, 7, BF
  3.         ELSEIF _MOUSEBUTTON(2) THEN
  4.             CIRCLE (_MOUSEX, _MOUSEY), 1, 0, BF
  5.         END IF
  6.     LOOP
  7.  

BTW ELSEIF in OP is better than ELSE IF (with space between)