Non-fill Draw Shapes
BlitzMax Forums/BlitzMax Beginners Area/Non-fill Draw Shapes
| ||
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? |
| ||
Please try using the search facility. It is so useful . Hope these help find your answer |
| ||
^^ Wot TonyG said ^^ |
| ||
Thanks. However, I think it is poor that such a basic drawing feature is no longer easily available. |
| ||
So do I. |
| ||
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. |
| ||
I would go for something like this but adjust it to draw a standard rect. <edit> Something like this (untested) |
| ||
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!) |
| ||
Cut and paste, then see if it runs, and you'll have your answer. |
| ||
the '..' are line continuation if you haven't guessed yet. Anyway, this seems to do the job using standard Bmax commands : |
| ||
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. |
| ||
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. |
| ||
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. |