forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Drawing circles

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Teggles



Joined: 16 Jan 2006
Posts: 27

PostPosted: Mon Jan 16, 2006 9:35 am    Post subject: Drawing circles Reply with quote

Does anyone have a function that can draw circles in Lua? [ka] gave me one, but it does not have the ability to choose a fill color. I need a fill color.

Thanks!
Back to top
View user's profile Send private message
soulphalanx



Joined: 22 Aug 2005
Posts: 35

PostPosted: Mon Jan 16, 2006 10:42 am    Post subject: Reply with quote

Code:

function drawCirc( x, y, radius, color)

   theta = 0

   while theta<=360 do
      screen:drawLine((math.sin(  theta)*radius)+x, (math.cos(theta)*radius)+  y, (math.sin(theta+1)*radius  )+x, (math.cos(theta+1)*radius  )+y, color)
      theta = theta+1
   end
end
Back to top
View user's profile Send private message
Teggles



Joined: 16 Jan 2006
Posts: 27

PostPosted: Mon Jan 16, 2006 1:05 pm    Post subject: Reply with quote

Not to be rude, but did you even read my post? I said that it needs to be able to fill the circle. That does not fill the circle.
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Mon Jan 16, 2006 1:53 pm    Post subject: Reply with quote

Originally, Lua Player does not have a fill command for circles like we do have one for rectangles.

Shine's team is working on implementation of PSPGL (similar to OpenGL) toward Lua Player.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Mon Jan 16, 2006 4:04 pm    Post subject: Reply with quote

something like (pseudo code, I don't do lua yet)
Code:

for q = -r to r
w=sqrt(r^2 - y^2)
line x-w,y+q to x+w,y+q
next


Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Mon Jan 16, 2006 11:19 pm    Post subject: Reply with quote

i was on coding non rectangular figures and filling support but dropped it;
cause i was not fast enough to follow the changes of every luaplayer release

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
joreofiorio35



Joined: 03 Dec 2005
Posts: 6

PostPosted: Tue Jan 17, 2006 1:55 am    Post subject: Reply with quote

Heres one I just coded:

Code:

function drawCirc(x, y, radiusfill, color, fillcolor)
   x=x+radiusfill
   y=y+radiusfill
   theta = 0
   for radius = 1, radiusfill do
      while theta<=360 do
            if radius == radiusfill then fillcolor = color end
      screen:drawLine((math.sin(theta)*radius)+x, (math.cos(theta)*radius)+ y, (math.sin(theta+1)*radius)+x, (math.cos(theta+1)*radius)+y, fillcolor)
            theta = theta+1
      end
   theta = 0
   end
end


The syntax is simple:

Code:

drawCirc (x position, y position, radius size, outline color, fill color)


Also, I made this one so it places not the center of the circle at the input x and y position, but the upper-left hand corner.
Thanks,
Josh.

EDIT: The outline of the circle, If you choose to outline it with a different color, is quite large. I am unsure on how to make it smaller, because of my poor geometry skills, but I'll fool around with it later @ home (at school right now lol).
Back to top
View user's profile Send private message Send e-mail
Teggles



Joined: 16 Jan 2006
Posts: 27

PostPosted: Tue Jan 17, 2006 11:35 am    Post subject: Reply with quote

Hey, I haven't tried it, but I'm assuming it'll work well. Thanks!
Back to top
View user's profile Send private message
youresam



Joined: 06 Nov 2005
Posts: 87

PostPosted: Wed Jan 18, 2006 8:22 am    Post subject: Reply with quote

Jim wrote:
something like (pseudo code, I don't do lua yet)
Code:

for q = -r to r
w=sqrt(r^2 - y^2)
line x-w,y+q to x+w,y+q
next


Jim



In LUA, it uses commands more like C:

Code:

for q = -r , r
w=sqrt(r^2 - y^2)
screen:drawLine(x-w,y+q,x+w,y+q)
end
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group