04-06-2024, 02:52 AM
(This post was last modified: 04-06-2024, 03:44 AM by TerryRitchie.)
UPDATE: Never mind. POINT(0) and POINT(1) already do this.
Thanks Steve
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?
Thanks Steve
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?