Author Topic: Drawing App  (Read 3210 times)

0 Members and 1 Guest are viewing this topic.

Offline qbkiller101

  • Newbie
  • Posts: 73
    • View Profile
Drawing App
« 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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Drawing App
« Reply #1 on: October 25, 2020, 01:15:08 pm »
Well I see you really knocked yourself out with this ;-))

 
image_2020-10-25_131459.png



Offline Rubidium

  • Newbie
  • Posts: 10
    • View Profile
Re: Drawing App
« Reply #2 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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Drawing App
« Reply #3 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)
« Last Edit: October 26, 2020, 02:53:54 pm by bplus »