View unanswered posts | View active topics It is currently Thu Oct 23, 2014 4:39 am






Reply to topic  [ 2 posts ] 
Inverting a circle 
Author Message
Rookie

Joined: Sun May 16, 2010 3:31 pm
Posts: 10
Post Inverting a circle
I use this code:
Code:
nxtEraseEllipse(x-radius, y-radius, x+radius, y+radius);
nxtDrawEllipse (x-radius, y-radius, x+radius, y+radius);
nxtDisplayStringAt(buttons[ID].xText, buttons[ID].yText, "%s", buttons[ID].text);
if (checkButton(ID)) {
    for (int i=-radius; i<=radius; i++) nxtInvertLine(x-sqrt(radius*radius-i*i), y+i, x+sqrt(radius*radius-i*i), y+i);
}

But when checkButton(ID)=true there are some not inverted pixels to the right of the circle:


Attachments:
File comment: checkButton(ID)=true
c2.JPG
c2.JPG [ 2.57 KiB | Viewed 1500 times ]
File comment: checkButton(ID)=false
c1.JPG
c1.JPG [ 2.31 KiB | Viewed 1500 times ]
Fri May 21, 2010 3:27 am
Profile
Rookie

Joined: Sun May 16, 2010 3:31 pm
Posts: 10
Post Re: Inverting a circle
It works!
But I don't understand why it works...
I changed
Code:
for (int i=-radius; i<=radius; i++) nxtInvertLine(x-sqrt(radius*radius-i*i), y+i, x+sqrt(radius*radius-i*i), y+i);

to
Code:
for (int i=-radius; i<=radius; i++) nxtInvertLine(x-sqrt(radius*(radius+1)-i*i)+1, y+i, x+sqrt(radius*(radius+1)-i*i), y+i);


Fri May 21, 2010 3:50 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.