Hi all
at last fixed my self, to fill the different colors to petals in
Flower.java, just I replaced petal method with this code.
private void petal( double radius, double degrees ){
for ( double i = radius; i > 0 ; i-- ) {
setPenWidth( (int)(degrees /100) );
arcRight( i, degrees );
right( 180 - degrees );
arcRight( i, degrees );
right( 180 - degrees );
}
}
chander
--- In jurtle-users@yahoogroups.com, Bill Tschumy <bill@o...> wrote:
> Chander,
>
> I gave you bad advice on using fillArc. This method doesn't do
what
> I thought. It will draw a pie shaped wedge rather than a 1/2 a
petal
> like I assumed.
>
> The requirement to fill the petals really makes this problem
harder.
> Are you sure it is necessary?
>
> If you need to fill it, I see your choices as:
>
> 1. use fillPolygon(), but you will need to calculate a list of
points
> defining the polygon of each petal.
> 2. use fillOval(), but you will need to rotate and translate the
> coordinate system to get each petal oriented correctly.
> 3. use drawImage() to draw a generic image of the petal, but you
will
> need to rotate and translate the coordinate system as in #2.
>
> I think you need to discuss this with your instructor and get
> guidance from him. I don't think I can help you further.
>
>
> Bill
>
> On Jun 30, 2005, at 9:12 AM, chander2010 wrote:
>
> > Jhon
> >
> > I used this fillArc method in arcRight() or arcLeft() , this
works,
> > but the problem is it over rides each petal at same positions of
X,
> > Y. I need it should fill the petal as side by side in a circle.
> > g.fillArc(pt.x, pt.y, (int)radius, (int)degrees, 180, 360);
> >
> > thanks
> > Chander
> >
> >
> > --- In jurtle-users@yahoogroups.com, John Kirkilis <john@a...>
wrote:
> >
> >> Chander,
> >>
> >> I haven't done much of any graphics programming outside of
> >>
> > Jurtle's
> >
> >> Turtle methods, but you can get the coordinates of the current
> >>
> > Turtle's
> >
> >> position in the graphic's context by calling the getPosition
> >>
> > method
> >
> >> which returns an object of type Dimension if memory serves me
> >>
> > correctly.
> >
> >> I would hope that the Java2D or AWT arcRight / arcLeft methods
use
> >>
> > the
> >
> >> same coordinate system, but perhaps not.
> >>
> >> Bill will be able to give you a more definite answer, but I
> >>
> > thought I'd
> >
> >> throw in my 2 cents anyway.
> >>
> >> Good luck,
> >>
> >> John
> >>
> >> chander2010 wrote:
> >>
> >>
> >>> I tried to do same way in arcRight() or arcLeft() but I
couldnot
> >>> able to find the X, Y positions and width & height, can you
help
> >>>
> > me
> >
> >>> how to figure out the positions to fill the colors.
> >>>
> >>> this is very urgent, please help me.
> >>>
> >>> thanks
> >>> Chander
> >>>
> >>>
> >>> --- In jurtle-users@yahoogroups.com, Bill Tschumy <bill@o...>
> >>>
> > wrote:
> >
> >>>> That's going to be a bit tricky to do. Turtle Graphics is
> >>>>
> >>> designed
> >>>
> >>>> mainly for line drawing, not for filing areas. You would
> >>>>
> > probably
> >
> >>> be
> >>>
> >>>> better off replacing the arcRight and arcLeft methods in
Flower
> >>>>
> >>> with
> >>>
> >>>> the fillArc method of java.awt.Graphics. You can get the
> >>>>
> >>> Graphics
> >>>
> >>>> object using the Turtle method getGraphics().
> >>>>
> >>>>
> >>>> On Jun 28, 2005, at 12:44 PM, chander2010 wrote:
> >>>>
> >>>>
> >>>>> Hi All
> >>>>>
> >>>>> I need to fill in each petal with different colors in
> >>>>>
> > Flower.java
> >
> >>>>> example. i can draw each petal with different colors, but I
> >>>>>
> >>> couldn't
> >>>
> >>>>> able to fill colors. any body can help me.
> >>>>>
> >>>>> thanks in advance
> >>>>> chander
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> Yahoo! Groups Links
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>> --
> >>>> Bill Tschumy
> >>>> Otherwise -- Austin, TX
> >>>> http://www.otherwise.com
> >>>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------
--
> >>>
> > -------
> >
> >>> YAHOO! GROUPS LINKS
> >>>
> >>> * Visit your group "jurtle-users
> >>> <http://groups.yahoo.com/group/jurtle-users>" on the web.
> >>>
> >>> * To unsubscribe from this group, send an email to:
> >>> jurtle-users-unsubscribe@yahoogroups.com
> >>> <mailto:jurtle-users-unsubscribe@yahoogroups.com?
> >>>
> > subject=Unsubscribe>
> >
> >>>
> >>> * Your use of Yahoo! Groups is subject to the Yahoo! Terms
> >>>
> > of
> >
> >>> Service <http://docs.yahoo.com/info/terms/>.
> >>>
> >>>
> >>> ---------------------------------------------------------------
--
> >>>
> > -------
> >
> >>>
> >>>
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
> --
> Bill Tschumy
> Otherwise -- Austin, TX
> http://www.otherwise.com