|
Post by PeterMaria on Dec 21, 2015 10:27:13 GMT -5
hello,
what about my new DrawCircle? it is useful or horrible or simple rubbish ?
glMatrixMode (GL_PROJECTION) glLoadIdentity() glOrtho (0,windowwidth(),windowheight(),0,-1,1) glMatrixMode (GL_MODELVIEW) glDisable (GL_DEPTH_TEST) glEnable (GL_LINE_SMOOTH) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
sub DrawCircle(cx#, cy#, r#, size#) glEnable(GL_BLEND) glLineWidth(size#) dim theta# = 2*3.1415926 dim c# = cosd(theta#) dim s# = sind(theta#) dim x# = r#, y# = 0 dim t#, i glBegin(GL_LINE_LOOP) for i=0 to 360 step 6 glVertex2f(x# + cx#, y# + cy#) t# = x# x# = c# * x# - s# * y# y# = s# * t# + c# * y# next glEnd() glDisable(GL_BLEND) end sub
dim x#=300,y#=200,e#=0.05,dx#,dy#,tx#,ty# dim i,j
while scankeydown(27)=0 glClear(GL_COLOR_BUFFER_BIT) for j=0 to windowheight() step 40 for i=0 to windowwidth () step 40 glcolor4ub(255, 255, 255, 128) drawcircle(i, j, 40, 4) next next
tx# = Mouse_x()*windowwidth()-10 dx# = tx#-x# if abs(dx#) >1 then x# = x#+dx#*e# end if ty# = Mouse_y()*windowheight()-10 dy# = ty#-y# if abs(dy#) >1 then y# = y#+dy#*e# end if glcolor4ub(255,194,83,200) drawcircle(x#, y#, 40, 3) glcolor4ub(255,224,103,200) drawcircle(x#, y#, 30, 3) glcolor4ub(255,244,123,200) drawcircle(x#, y#, 20, 3)
swapbuffers() waittimer(10) wend
|
|
|
Post by PeterMaria on Dec 21, 2015 15:38:03 GMT -5
And full circle as well.
glMatrixMode (GL_PROJECTION) glLoadIdentity() glOrtho (0,windowwidth(),windowheight(),0,-1,1) glMatrixMode (GL_MODELVIEW) glDisable (GL_DEPTH_TEST) glEnable (GL_LINE_SMOOTH) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
sub DrawCircle(cx#, cy#, r#, size#) glEnable(GL_BLEND) glLineWidth(size#) dim theta# = 2*3.1415926 dim c# = cosd(theta#) dim s# = sind(theta#) dim x# = r#, y# = 0 dim t#, i glBegin(GL_LINE_LOOP) for i=0 to 360 step 6 glVertex2f(x# + cx#, y# + cy#) t# = x# x# = c# * x# - s# * y# y# = s# * t# + c# * y# next glEnd() glDisable(GL_BLEND) end sub
sub FillCircle(cx#, cy#, r#) glEnable(GL_BLEND) glLineWidth(1.0) dim theta# = 2*3.1415926 dim c# = cosd(theta#) dim s# = sind(theta#) dim x# = r#, y# = 0 dim t#, i glBegin(GL_POLYGON) for i=0 to 360 step 6 glVertex2f(x# + cx#, y# + cy#) t# = x# x# = c# * x# - s# * y# y# = s# * t# + c# * y# next glEnd() glDisable(GL_BLEND) end sub
dim x#=300,y#=200,e#=0.05,dx#,dy#,tx#,ty# dim i,j
while scankeydown(27)=0 glClear(GL_COLOR_BUFFER_BIT) for j=0 to windowheight() step 40 for i=0 to windowwidth () step 40 glcolor4ub(255, 255, 255, 128) drawcircle(i, j, 40, 4) next next
tx# = Mouse_x()*windowwidth()-10 dx# = tx#-x# if abs(dx#) >1 then x# = x#+dx#*e# end if ty# = Mouse_y()*windowheight()-10 dy# = ty#-y# if abs(dy#) >1 then y# = y#+dy#*e# end if glcolor4ub(255,194,83,200) drawcircle(x#, y#, 40, 3) glcolor4ub(255,224,103,200) drawcircle(x#, y#, 30, 3) glcolor4ub(255,244,123,200) fillcircle(x#, y#, 20)
glcolor4ub(255,44,23,128) fillcircle(windowwidth()/2, windowheight()/2,100) glcolor4ub(23,44,255,128) fillcircle(windowwidth()/2, windowheight()/2-150,100) glcolor4ub(23,255,44,128) fillcircle(windowwidth()/2, windowheight()/2+150,100)
swapbuffers() waittimer(10) wend
|
|
|
Post by matthew on Dec 22, 2015 3:24:40 GMT -5
Very nice, Peter. :-)
|
|
|
Post by PeterMaria on Dec 22, 2015 9:35:27 GMT -5
Thanks Matthew, and Merry Christmas to you and your family.
|
|
|
Post by matthew on Dec 23, 2015 14:32:21 GMT -5
Thanks Peter, I hope you and your family have a nice Christmas too. :-)
|
|