Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

PLEASE HELP ME ... need to tile polygon

Thread view: 
cheryl j - 25 Aug 2005 00:36 GMT
Hi, im desperately trying to tile polygon shape across the whole of the
canvas but all i seem to end up with is just one line, i need to loop it so
it draw polygon across whole canvas!!!!!

if(tiled)
{
for( int y=1; y<xPoints.length; y++)

        {
        for(int x=0; x<10;x++)

g.setColor(new Color(250,0,0));
            g.fillPolygon(xPoints, yPoints, xPoints.length);
                    for(int i=0; i<xPoints.length;i++)
                    xPoints[i] +=200;

    }

}
Andrew Thompson - 25 Aug 2005 07:28 GMT
>  PLEASE HELP ME ... need to tile polygon

Please don't SHOUT.  It will not get answers sooner, and is
more likely to get your post ignored than answered.

Also, I would recommend against putting 'please help me'
in a post at all.  If people will help, they will help,
it makes little or no difference if you say 'please'.

> Hi, im desperately trying to tile polygon shape across the whole of the
> canvas but all i seem to end up with is just one line, i need to loop it so
> it draw polygon across whole canvas!!!!!

I cannot see what is wrong from your snippet, (though
if xPoints.length = 1, that might explain it) I suggest
you poast an SSCCE.
<http://www.physci.org/codes/sscce.jsp>

Since you are apparently new to this, I will also add..
<http://www.physci.org/codes/javafaq.jsp#usenet>

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Give me a whiskey, don't think twice.."
The Angels 'Marseille'

Matt Humphrey - 25 Aug 2005 16:16 GMT
> Hi, im desperately trying to tile polygon shape across the whole of the
> canvas but all i seem to end up with is just one line, i need to loop it
[quoted text clipped - 16 lines]
>
> }

You need to think about what needs to happen to the polygon points in order
to make them appear tiled in a grid.  You are incrementing the X, but not
the Y, so the polygon stays on one line.  When the X-loop ends, you need to
increment the Y values, but also to reset the X values back (relatively) to
zero or you'll end up with a diagonal.

It's also not clear to me why your outer loop (y-loop) is over the number of
points in the polygon or why it starts at 1.  I would have expected
something like for (int y = 0; y < numRows; ++y)  where numRows is the
number of rows to be tiled, just as you use 10 for the number of columns (0
through 9) to be tiled.

Cheers,
Matt Humphrey  matth@ivizNOSPAM.com  http://www.iviz.com/
Tor Iver Wilhelmsen - 29 Aug 2005 15:22 GMT
> Hi, im desperately trying to tile polygon shape across the whole of the
> canvas but all i seem to end up with is just one line, i need to loop it so
> it draw polygon across whole canvas!!!!!

If you can use Java2D, look into transforming the coordinate system
instead of adjusting the polygon values: They should be constant
relative to some point shich you move around.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.