DrawRect outlined..
BlitzMax Forums/BlitzMax Beginners Area/DrawRect outlined..
| ||
How do I draw Rect or oval only outlined without the fill? |
| ||
check the code archives, several examples there. |
| ||
Or ... wait for David to post the code in here. :) Hope This Helps, HC ! |
| ||
You could draw 2 of them one inside the other. |
| ||
This is from code archives they come in handy. |
| ||
Omy Blitzman. First time I am seeing this code and see they too copied the subtract one from the edge. :D And yes, parentheses are never needed in coding BlitzMAX unless you plan to return a value. |
| ||
Function drawhollowoval(h,v,x,y) DrawRect 0,0,0,0 ' necessary before calling GL stuff glbegin(gl_line_loop) _max2ddriver.DrawOval h,v,h+x,v+y,0,0 glend EndFunction Hello. Wouldn't you rather consult the source code and see what DrawRect does that makes it work? Then you use that, instead of having the dark magic DrawRect(0,0,0,0) call. Also, if you follow the logic that happens inside _max2DDriver.DrawOval, it starts another glBegin block. Having a glBegin inside another glBegin leads to a GL_INVALID_OPERATION error according to the specification: https://www.opengl.org/sdk/docs/man2/xhtml/glBegin.xml |
| ||
Tnx guys.. I know how to make a box out of lines.. I was looking to see if their is a ready command. Im not on pc atm, so tnx for all the help |
| ||
HC, I tried your link. No-one is there. That's one of the problems with Chat nowadays. :) Oh, and what JBR is saying is: Understand though that these are not really hollow images. They are solid, white outline, black inside. |
| ||
I know DW.. thats its 99.99% empty.. but its good to have it online :D It costs nothing. I Sure wish their was an open channel here on blitz website for chats.. The would be nice. Anyway Tnx for your help in general guys.. |
| ||
Silly question.. What is GLmax2dDriver()? Ive just started to build a 2D framework and I didnt add anything to the blitzmax graphics.. Is that new set of commands? "shrug" |
| ||
Hi HC. I usually learn by example and not by definition. I have found that it forces a Front Buffer. That is, the pixels recorded are not saved to any other plane except the front. The advantage of this is clear. Try running this program and it works fine, BUT, take out this line: SetGraphicsDriver(GLMax2DDriver()) ' NECESSARY FOR AGGRESSIVE PIXEL READING & WRITING and it will slow down, crawl, and in some cases, crash. As I described it, GlMax2dDriver() is necessary for aggressive pixel reading and writing. Without it, under certain circumstances you can even get a CANVAS ERROR where no more information can be sent to your graphics. If you plan to read or write pixels, it's a good habit to use the GlMax2dDriver() line. By default, I use it in all my code and seem to have markedly better results in graphics all around. |
| ||
Gees.. thats horrible , Tnx :) So this is mainly for pixel reading? or does it affects all graphic commands? BTW I also learn mostly from examples.. I never read instruction manual when I open a new Gadget :p (Unless I have too) :shrug: Also.. Is their anything I should know about 2D graphics on blitzmax before I rely my 2D Game Engine upon blitzmax native commands? |
| ||
the problem with creating rects with lines is that u cant apply Rotation to it. Also DW817's method creates a hollow rect but not transparent one. why in hell the creator of blitzmax didnt gave what most 2d graphic engines do for decades the option for choosing whether its hollow or filled beats my brains.. Ive already created my own Hollow Rect Version with Rotating ability as well. All I need is to add the option of choosing the Handle location to make it perfect |
| ||
Ok here is my code for Drawing empty Rect with Diversion points and Rotation. Shame I need to spend time for thing that should be implemented on 2D Engine. Method DrawSquare(XPos:Float, YPos:Float, XSize:Float, YSize:Float, Roll:Float = 0, XDivert:Float = 0, YDivert:Float = 0, DrawCenter_flg = True) 'Draw a Square from handle LeftUp Local PntX:Float[5], PntY:Float[5], YeterAngle:Float[5], LengthX:Float[5], LengthY:Float[5], Yeter:Float[5] LengthX[1] = XDivert LengthY[1] = YDivert LengthX[2] = XSize - XDivert LengthY[2] = YDivert LengthX[3] = XSize - XDivert LengthY[3] = YSize - YDivert LengthX[4] = XDivert LengthY[4] = YSize - YDivert Yeter[1] = (LengthX[1] ^ 2 + LengthY[1] ^ 2) ^ 0.5 Yeter[2] = (LengthX[2] ^ 2 + LengthY[2] ^ 2) ^ 0.5 Yeter[3] = (LengthX[3] ^ 2 + LengthY[3] ^ 2) ^ 0.5 Yeter[4] = (LengthX[4] ^ 2 + LengthY[4] ^ 2) ^ 0.5 YeterAngle[1] = ATan2(-LengthY[1], -LengthX[1]) YeterAngle[2] = ATan2(-LengthY[2], LengthX[2]) YeterAngle[3] = ATan2(LengthY[3], LengthX[3]) YeterAngle[4] = ATan2(LengthY[4], -LengthX[4]) PntX[1] = Cos(YeterAngle[1] + Roll) * Yeter[1] + XPos + XDivert PntY[1] = Sin(YeterAngle[1] + Roll) * Yeter[1] + YPos + YDivert PntX[2] = Cos(YeterAngle[2] + Roll) * Yeter[2] + XPos + XDivert PntY[2] = Sin(YeterAngle[2] + Roll) * Yeter[2] + YPos + YDivert PntX[3] = Cos(YeterAngle[3] + Roll) * Yeter[3] + XPos + XDivert PntY[3] = Sin(YeterAngle[3] + Roll) * Yeter[3] + YPos + YDivert PntX[4] = Cos(YeterAngle[4] + Roll) * Yeter[4] + XPos + XDivert PntY[4] = Sin(YeterAngle[4] + Roll) * Yeter[4] + YPos + YDivert DrawLine(PntX[1], PntY[1], PntX[2], PntY[2]) DrawLine(PntX[2], PntY[2], PntX[3], PntY[3]) DrawLine(PntX[3], PntY[3], PntX[4], PntY[4]) DrawLine(PntX[4], PntY[4], PntX[1], PntY[1]) If DrawCenter_flg Then DrawRect(PntX[1] - 2, PntY[1] - 2, 4, 4) DrawOval(XPos + XDivert - 1.5, YPos + YDivert - 1.5, 3, 3) End If End Method |
| ||
Ok here is my code for Drawing empty Rect with Diversion points and Rotation.Method DrawSquare(XPos:Float, YPos:Float, XSize:Float, YSize:Float, Roll:Float = 0, XDivert:Float = 0, YDivert:Float = 0, DrawCenter_flg = True) 'Draw a Square from handle LeftUp Local PntX:Float[5], PntY:Float[5], YeterAngle:Float[5], LengthX:Float[5], LengthY:Float[5], Yeter:Float[5] LengthX[1] = XDivert LengthY[1] = YDivert LengthX[2] = XSize - XDivert LengthY[2] = YDivert LengthX[3] = XSize - XDivert LengthY[3] = YSize - YDivert LengthX[4] = XDivert LengthY[4] = YSize - YDivert Yeter[1] = (LengthX[1] ^ 2 + LengthY[1] ^ 2) ^ 0.5 Yeter[2] = (LengthX[2] ^ 2 + LengthY[2] ^ 2) ^ 0.5 Yeter[3] = (LengthX[3] ^ 2 + LengthY[3] ^ 2) ^ 0.5 Yeter[4] = (LengthX[4] ^ 2 + LengthY[4] ^ 2) ^ 0.5 YeterAngle[1] = ATan2(-LengthY[1], -LengthX[1]) YeterAngle[2] = ATan2(-LengthY[2], LengthX[2]) YeterAngle[3] = ATan2(LengthY[3], LengthX[3]) YeterAngle[4] = ATan2(LengthY[4], -LengthX[4]) PntX[1] = Cos(YeterAngle[1] + Roll) * Yeter[1] + XPos + XDivert PntY[1] = Sin(YeterAngle[1] + Roll) * Yeter[1] + YPos + YDivert PntX[2] = Cos(YeterAngle[2] + Roll) * Yeter[2] + XPos + XDivert PntY[2] = Sin(YeterAngle[2] + Roll) * Yeter[2] + YPos + YDivert PntX[3] = Cos(YeterAngle[3] + Roll) * Yeter[3] + XPos + XDivert PntY[3] = Sin(YeterAngle[3] + Roll) * Yeter[3] + YPos + YDivert PntX[4] = Cos(YeterAngle[4] + Roll) * Yeter[4] + XPos + XDivert PntY[4] = Sin(YeterAngle[4] + Roll) * Yeter[4] + YPos + YDivert DrawLine(PntX[1], PntY[1], PntX[2], PntY[2]) DrawLine(PntX[2], PntY[2], PntX[3], PntY[3]) DrawLine(PntX[3], PntY[3], PntX[4], PntY[4]) DrawLine(PntX[4], PntY[4], PntX[1], PntY[1]) If DrawCenter_flg Then DrawRect(PntX[1] - 2, PntY[1] - 2, 4, 4) DrawOval(XPos + XDivert - 1.5, YPos + YDivert - 1.5, 3, 3) End If End Method |