Non-fill Draw Shapes

BlitzMax Forums/BlitzMax Beginners Area/Non-fill Draw Shapes

Czar Flavius(Posted 2007) [#1]
Sorry for all these noobish questions!

My latest one is, in Blitz Basic I could specify whether I wanted the shape (rectangle, circle etc) to be filled or hollow. Now it seems I can only draw fill shapes. Is it possible to draw hollow shapes?


tonyg(Posted 2007) [#2]
Please
try
using
the
search
facility.
It
is
so
useful .
Hope
these
help
find
your
answer


Yan(Posted 2007) [#3]
^^ Wot TonyG said ^^


Czar Flavius(Posted 2007) [#4]
Thanks. However, I think it is poor that such a basic drawing feature is no longer easily available.


tonyg(Posted 2007) [#5]
So do I.


Czar Flavius(Posted 2007) [#6]
One solution might be to draw a rectangle to a drawing thing, then draw another rectangle of a masking colour inside the first one but 1 pixel shorter around the edges, then save this as a masked image. But I think it would be too slow for on-the-fly size changing images.


tonyg(Posted 2007) [#7]
I would go for something like this but adjust it to draw a standard rect.
<edit> Something like this (untested)



Czar Flavius(Posted 2007) [#8]
Thanks. I'm not familular with using drivers and stuff directly. Are the ".."s where I'm suppose to put something, or is it a way of telling BM to continue on the next line? (Therefore a cool feature I didn't know about!)


Who was John Galt?(Posted 2007) [#9]
Cut and paste, then see if it runs, and you'll have your answer.


tonyg(Posted 2007) [#10]
the '..' are line continuation if you haven't guessed yet.
Anyway, this seems to do the job using standard Bmax commands :



Scaremonger(Posted 2007) [#11]
The easiest way to draw a rectangle outline:
Function DrawOblong( x#, y#, w#, h# )
DrawLine( x , y , x + w , y)
DrawLine( x+w , y , x + w , y+h)
DrawLine( x+w , y+h , x , y+h)
DrawLine( x , y+h , x , y)
End Function

And to create a ellipse outline:
(X and Y are centre of oval, w & h are RADIUS.)
Function drawOvate( x# , y# , w# , h#)
For Local n% = 1 To 360
	Plot( x + w * Cos(n) , y + h * Sin(n) )
Next
End Function

Lastly an ellipse that fits within the specified rectangular area (in the same way that the blitzmax drawoval does)
Function drawEllipse( x# , y# , w# , h#)
Local rh% = h / 2
Local rw% = w/2
For Local n% = 1 To 360
	Plot( rw + x + rw * Cos(n) , rh + y + rh * Sin(n) )
Next
End Function


On a speed note:
It is 5 times quicker to draw a filled rectangle inside another filled rectangle using Blitzmax drawrect() than drawing the four lines to make to edges.

Drawing an oval with either of the latter two functions is about 20 times slower than the Blitzmax drawOval().

Hope this helps.


Czar Flavius(Posted 2007) [#12]
Thank you all for your code and suggestions. The speed issue is slightly worrying, but none of my games are particularly intensive so it shouldn't be a problem.

I'm curious... did non-fill shapes from earlier Blitz Basics become this slow?

In some of the links people talk about some kind of OpenGL stuff to do the same thing. Would this be as slow?

Thanks.


Scaremonger(Posted 2007) [#13]
In most of the games and programs I've written I do not draw anything manually.

The most common way is to load .PNG files containing pre-drawn images and place them on the screen.