|
Post by PeterMaria on Jul 14, 2015 11:08:49 GMT -5
Hello, Does someone know a faster circle algorithm ?
Sub Gl2D(width,height) glMatrixMode(GL_Projection) glLoadIdentity() glOrtho (0,width,height,0,-128,128) glMatrixMode(GL_ModelView) glDisable (GL_DEPTH_TEST) End Sub Sub Circle(x#,y#,r1#,size#) dim rad glPointSize(size#) glBegin(GL_POINTS) For rad=0 to 360 glVertex2f(x#+sin(rad)*r1#, y#+cos(rad)*r1#) Next glEnd() End Sub
Function RND#() Return rnd()*(1.0/RND_MAX) End Function
GL2D(640,480) glPointSize(4)
dim h=250 dim w=300 dim t#,m#,a#,i
while scankeydown(27)=0 glClearColor(0,0,0,1) glClear(GL_COLOR_BUFFER_BIT)
for i=1 to 360 glColor3ub(255-i,255,255) circle(w+sin(i*90+t#)*200,h+cos(i*90+t#)*200,20+i,1) next
t# = t#+.1 if t# >=360 then t#=-t#: end if swapbuffers() waittimer(10) wend
|
|
|
Post by PeterMaria on Jul 14, 2015 12:22:36 GMT -5
Hello again, here are some Ellipse Stars.
Sub Ellipse(x,y,r1,r2,size) dim t glPointSize(size) glBegin(GL_POINTS) For t=0 to 360 glVertex2f(x+cos(t)*r1, y+sin(t)*r2) Next glEnd() End Sub
Sub Gl2D(width,height) glMatrixMode(GL_Projection) glLoadIdentity() glOrtho (0,width,height,0,-128,128) glMatrixMode(GL_ModelView) glDisable (GL_DEPTH_TEST) End Sub Dim x Gl2D(640,480)
for x=0 to 360 glColor3ub(200,200,255) ellipse(300,240,cos(x)*10,sin(x)*40,1) ellipse(300,240,sin(x)*40,cos(x)*10,1) glColor3ub(255,200,200) ellipse(200,140,cos(x)*20,sin(x)*60,1) ellipse(200,140,sin(x)*60,cos(x)*20,1) glColor3ub(200,255,200) ellipse(400,340,cos(x)*20,sin(x)*40,1) ellipse(400,340,sin(x)*40,cos(x)*20,1) next swapbuffers()
|
|
|
Post by matthew on Jul 14, 2015 16:19:01 GMT -5
Nice, the circles remind me of Spirograph Peter. :-)
|
|