Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Line inside a circle  RSS feed

 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone
I want to draw a line inside a circle, i what to have a horizontal line.
Here is what i have done so far.
can you tell me whats wrong
thank you

 
Campbell Ritchie
Sheriff
Posts: 53750
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still think you should move back into the realms of object orientation. Also that a circle and a line are usually separate shapes, so you might do well to draw them separately.

You should tell us what goes wrong and what you expected, then we can consider it.
Can you add a circle to a general path at all? Why have you got a spelling error on line 55 54?

[edit]Corrected line number[/edit]
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i have not got any spelling error on line 54. i have to have a shape like Key attribute in ERD.
 
Tony Docherty
Bartender
Posts: 3200
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nathalie Monvoisin wrote:No i have not got any spelling error on line 54. i have to have a shape like Key attribute in ERD.

It looks like something is mis-spelled to me.

As to your problem, the constructor for Line2D.Float takes the x and y start location and the x and y end location of the line. If you want a horizontal line the start and end y values must be the same.
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tony Docherty. yeah i have a spelling problem :/ i will correct it
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to draw a line inside a circle, i what to have a horizontal line.


Basic math. You know the top/left point where the oval is painted and you know the with height of the oval.

So the starting point of the line will be:

(x, y + height / 2);

and the ending point will be:

(x + width, y + height / 2);
 
Piet Souris
Rancher
Posts: 1783
55
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Nathalie,

I've made a small example of a shape containing a circle and an arrow, and rotating and
drawing it a couple of times. It looks much like your code, but maybe you see one or two
things that might be useful. I use "natural" coordinates for the shape, and set up the
scaling, position and scaling just before drawing. The idea is to use coordinates in your
shape that are natural to that shape. That makes things sometimes much easier.

Greetz,
Piet
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!