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?
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply
#2
I like any statement that begins with DRAW!

 - Sam
Reply
#3
(04-06-2024, 02:56 AM)Pete Wrote: I like any statement that begins with DRAW!

 - Sam
Or ends in varmint!
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply
#4
Is POINT not the way to do this?

https://qb64phoenix.com/qb64wiki/index.php/POINT

POINT(0) or POINT(1)
Reply
#5
(04-06-2024, 03:07 AM)SMcNeill Wrote: Is POINT not the way to do this?

https://qb64phoenix.com/qb64wiki/index.php/POINT

POINT(0) or POINT(1)
Oh for PETE's sake! I just had a HUGE brain fart. I completely forgot that POINT could be used like that.

Ok, move along, nothing to see here ...
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply
#6
Don't worry.  I remember suggesting the same thing to Galleon ages ago.  He's the one who reminded me of POINT back then.  Big Grin

Maybe someone can do a tutorial on POINT!  Wink Big Grin
Reply
#7
(04-06-2024, 03:14 AM)SMcNeill Wrote: Don't worry.  I remember suggesting the same thing to Galleon ages ago.  He's the one who reminded me of POINT back then.  Big Grin

Maybe someone can do a tutorial on POINT!  Wink Big Grin
LOL, Yep, POINT is going to be added right above the DRAW statement in lesson 5.

Ok, putting the code away for the rest of the night. Going to fire up Brutal DOOM Project Brutality and take my frustration out on some imps with a double barreled shot gun. Draw you varmints!
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply
#8
GREAT IDEA inspired by Terry,

_VARMINT

It must be all uppercase, because CamelCase didn't go so well for  Sam, Whoa CAMEL! I SEZ WHOAAAA!!!

Well case aside, what could _VARMINT do? Well, glad you asked. It acts the same as KILL, but while the KILL statement requires a directive... KILL myfile.bas, etc. _VARMINT just KILLS all your files at once! It even remains in you system, as a TSR, to kill all newly added files, too. Hey, let's get Clippy to beta test it for us! How soon can it be ready?

Steve gets 1-point for pointing out POINT. I mean what's the point of points if people who point out statements like POINT don't get points for pointing them out? 

Just sayin'

Pete Big Grin
If eggs are brain food, Biden has his scrambled.

Reply
#9
(04-06-2024, 03:40 AM)Pete Wrote: GREAT IDEA inspired by Terry,

_VARMINT

It must be all uppercase, because CamelCase didn't go so well for  Sam, Whoa CAMEL! I SEZ WHOAAAA!!!

Well case aside, what could _VARMINT do? Well, glad you asked. It acts the same as KILL, but while the KILL statement requires a directive... KILL myfile.bas, etc. _VARMINT just KILLS all your files at once! It even remains in you system, as a TSR, to kill all newly added files, too. Hey, let's get Clippy to beta test it for us! How soon can it be ready?

Steve gets 1-point for pointing out POINT. I mean what's the point of points if people who point out statements like POINT don't get points for pointing them out? 

Just sayin'

Pete Big Grin
Point well taken.
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply
#10
Yep, now no one can ever accuse me again of making a POINTless post!

Pete Big Grin
Reply




Users browsing this thread: 1 Guest(s)