DrawOval
BlitzMax Forums/BlitzMax Beginners Area/DrawOval
| ||
Is it possible to paint a circle without filling? Example: ------------------------------ Graphics 800,600,32,60 Setcolor 100,100,100 DrawOval 100,100,50,50 Flip While Not KeyHit(KEY_ESCAPE) Wend End ------------------------------ This code draw a filled circle on the screen. But i want to draw a circle without filling. I have searched a possibility but I dont found. Hopefull waiting for an answer... Thommes (t.carstens@...) |
| ||
You have two ways of doing this, you can use lines or points. THere arn't any draw unfilled shapes. |
| ||
Make a black outline circle on an image with centre as alpha colour, then scale/rotate/sethanble and paste it. |
| ||
here is a circle routine I just made using Bresenham Algorith : I hope it can help. |
| ||
Great job!! It works fine and Iam verry happy!! THANX!!!! |
| ||
Try this code: http://www.blitzbasic.com/codearcs/codearcs.php?code=1477 |
| ||
here are both routines incorporated in to a single user friendly file: |
| ||
Here's one that someone posted a while back. Should be faster since it uses GL Lines instead of plot. |
| ||
I am ignorant to openGL. TeaVirus. Can you give an example to show me how it works. I tried it like below but I can't get it to work: |
| ||
It's your projection matrix. The default is -1 to +1 call gluOrtho2D(0,640,480,0) ; left/right/bottom/top just after your Graphics call, with your window sizes. |
| ||
If you are using OpenGL it's as easy as changing the rendering mode. Like this:SetGraphicsDriver GLMax2DDriver() Graphics 640,480,0,0 Local wire:Int = False Repeat If KeyHit(KEY_SPACE) wire = Not wire If wire glPolygonMode(GL_FRONT, GL_LINE) Else glPolygonMode(GL_FRONT, GL_FILL) EndIf EndIf SetColor Rand(100,255),Rand(100,255),Rand(100,255) DrawOval Rand(0,540),Rand(0,380),Rand(10,100),Rand(10,100) SetColor 255,255,255 DrawText "Hit space to toggle line mode",0,0 Flip Until KeyHit(KEY_ESCAPE) Or AppTerminate() End |
| ||
Or you could do a Max2D version and forget about gl at all :-Strict Function DrawOvalUnfilled(x0#,y0#,w#,h#) Local xr#=(w)*.5 Local yr#=(h)*.5 Local segs=Abs(xr)+Abs(yr) segs=Max(segs,12)&~3 x0:+xr y0:+yr Local px# = x0 + xr Local py# = y0 For Local i=1 To segs Local th#=i*360#/segs Local x#=x0+Cos(th)*xr Local y#=y0-Sin(th)*yr DrawLine px,py, x, y px# = x py# = y Next End Function Graphics 640,480 drawovalunfilled(320,220,100,100) Flip WaitKey() This version slightly optimised since it doesn't need check with an If statement for every line. (first point is precalculated). It's easy to modify this if you want it to be centred at the point specified rather than be 'boxed' by the dimensions. |