Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to get the current graphics cursor position?
#1
I've been playing with the DRAW command lately.  It's such a powerful command, and one I haven't fully explored/learned.   I know you can set the graphics cursor position using PSET, and also using commands in the DRAW statement, but I was wondering how to get where the current graphics cursor position DRAW is at?  For instance, in this code below how would I know when DRAWs graphics cursor position goes off screen here so I could reset it?

(BTW, @dbox, running this in QBJS, the output is different)

- Dav

Code: (Select All)

Screen _NewImage(600, 600, 32)

Dim p, p$, ang, a$ '<- for QBJS compat

Do
    p = p + .05
    p$ = "D" + Str$(p)

    ang = ang + 10
    a$ = "TA" + Str$(ang)

    Draw p$ + a$

    _Limit 100

Loop

Find my programs here in Dav's QB64 Corner
Reply
#2
https://qb64phoenix.com/qb64wiki/index.php/POINT

Check out `POINT(0)` and `POINT(1)`.
Reply
#3
(09-09-2023, 08:33 PM)mnrvovrfc Wrote: https://qb64phoenix.com/qb64wiki/index.php/POINT

Check out `POINT(0)` and `POINT(1)`.

Oh great!  I didn’t know about those POINT options. (Or forgot them).  Thanks for the quick reply!

 - Dav

Find my programs here in Dav's QB64 Corner
Reply
#4
(09-09-2023, 08:26 PM)Dav Wrote: (BTW, @dbox, running this in QBJS, the output is different)
Looks like DRAW is working the same.  The issue is that QBJS is going to see p and p$ as the same variable.  Changing this makes the result much closer to QB64.

Reply
#5
Interesting what happens to that code with a Cls in the loop.
b = b + ...
Reply
#6
Thanks for the help.  I put together a small DRAW pattern maker.  Press ENTER to keep making new patterns. Some reason only the first pattern shows in QBJS.  I'll tinker with DRAW more tomorrow.

- Dav

Code: (Select All)

'DRAWPATTERNS.BAS
'Generates pattern using DRAW
'Coded by Dav, SEP/2023

SCREEN _NEWIMAGE(600, 600, 32)

RANDOMIZE TIMER

DIM p, ps$, ang, a$, angrand, prand '<- for QBJS compat

DO
    CLS 'clears and resets DRAW to middle of screen
    angrand = 90 + (RND * 240) 'make random angle
    prand = RND * 5 + 1 'make random pixel size
    ang = 0: p = 0
    DO
        p = p + prand
        ps$ = "D" + STR$(p)
        ang = ang + angrand
        a$ = "TA" + STR$(ang)
        DRAW ps$ + a$ + "C" + STR$(_RGBA(RND * 255, RND * 255, RND * 255, RND * 255))
    LOOP UNTIL POINT(0) < 0 AND POINT(1) < 0
    PRINT "ENTER for another one...";
    LOCATE 2, 1: PRINT INT(prand); INT(angrand); 'show pixel size and angle #
    SLEEP
LOOP

Find my programs here in Dav's QB64 Corner
Reply
#7
It looks like the position is not being reset to the center on the Cls call.  I'll add it to the fix list.  In the meantime you could explicitly set it with a call to PRESET:



Very cool, by the way.
Reply
#8
Thanks, @dox!  

I think I like the patterns much better without colors. 

Just change the DRAW line to read:  DRAW ps$ + a$

- Dav

   

Find my programs here in Dav's QB64 Corner
Reply
#9
Dav, I like the color and the white versions. It works very well.
Reply




Users browsing this thread: 1 Guest(s)