Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Idea for two new commands
#1
UPDATE: Never mind. POINT(0) and POINT(1) already do this.

Thanks Steve Smile

While working on example programs for the DRAW statement topic in Lesson 5 of the tutorial I had an idea for two new commands.

The LINE statement allows doing this:

LINE(0, 0)-(100, 100), _RGB32(255, 255, 255) ' a white line
LINE -(100, 200), _RGB(255, 255, 255) '  continue the line from last point

By omitting the first set of coordinates the LINE statement simply continues on from the last point. You always know the coordinates because they are explicitly given with numerical values or variables.

However, take this piece of code for instance:

DRAW "BM200,200" ' move pen to location
DRAW "TA45" '           rotate pen
DRAW "R100"  '         draw line 100 pixels long
LINE -(300, 300), _RGB32(255, 255, 255) ' continue line from last DRAW point

By omitting the first set of coordinates the LINE statement will continue on from where DRAW left off. But, what was the first set of coordinates?

Before issuing the LINE statement I suggest two new commands to find out:

_DRAWX ' get current x position of pen (or _GETX ' get current graphics cursor x position)
_DRAWY ' get current y position of pen (or _GETY ' get current graphics cursor y position)

This could come in very handy:

TYPE TICKS
    x AS INTEGER
    y AS INTEGER
END TYPE

DIM Tick(359) AS TICKS
DIM Angle AS INTEGER

SCREEN _NEWIMAGE(800, 600, 32)
FOR Angle = 0 to -359 STEP -1
    DRAW "BM399,299" '                center pen on screen
    DRAW "TA" + STR$(Angle) '      rotate pen
    DRAW "U200" '                          draw line 200 pixels long
    Tick(ABS(Angle)).x = _DRAWX ' get current pen x position
    Tick(ABS(Angle)).y = _DRAWY ' get current pen y position
NEXT Angle

You now have the 360 locations around a circle without using any trigonometry.

You can always know where your graphics cursor (or pen) position is at any time while using DRAW to do complex "Spirograph" type images. This could allow sprites, images, or even text to be located at key points within your DRAW commands.

What do you think? Sound like something looking into to? All drawing commands need to keep track of the graphics cursor position already, right? Would it be a simple thing to extract this using the two new commands?
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Idea for two new commands - by TerryRitchie - 04-06-2024, 02:52 AM
RE: Idea for two new commands - by Pete - 04-06-2024, 02:56 AM
RE: Idea for two new commands - by TerryRitchie - 04-06-2024, 03:05 AM
RE: Idea for two new commands - by SMcNeill - 04-06-2024, 03:07 AM
RE: Idea for two new commands - by TerryRitchie - 04-06-2024, 03:12 AM
RE: Idea for two new commands - by SMcNeill - 04-06-2024, 03:14 AM
RE: Idea for two new commands - by TerryRitchie - 04-06-2024, 03:19 AM
RE: Idea for two new commands - by Pete - 04-06-2024, 03:40 AM
RE: Idea for two new commands - by TerryRitchie - 04-06-2024, 03:45 AM
RE: Idea for two new commands - by Pete - 04-06-2024, 04:02 AM



Users browsing this thread: 4 Guest(s)