
-----------------------------------
whoareyou
Sun May 01, 2011 1:44 pm

help - moving a flag
-----------------------------------
I've created a program that will draw a Guyana flag. I've implemented variables so that changing and moving around the flag would be much easier (i.e change the variables at the beginning of the program to change the entire flag). The current origin position is at (0,0). Now if I wanted to change the origin position, everything gets misplaced. If i change the maximum width and maximum height, the works and everything is still in proportion. What I can't figure out is why the flag gets messed up when I change the origin.


// The "GuyanaFlag" class.
import java.awt.*;
import hsa.Console;

public class GuyanaFlag
{
    static Console c;           // The output console

    public static void main (String

-----------------------------------
Zren
Sun May 01, 2011 11:35 pm

RE:help - moving a flag
-----------------------------------
Er. Might I suggest using: fillPolygon ( http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html#fillPolygon(intdrawRect(offsetX, offsetY, ...) for everything instead of assuming it starts at (0,0).

Advanced Concepts
If you understand OOP, then you might want to attempt at creating a flag object, even attempt to extend the Rectangle class (as it already has x,y,w,h but overriding it's methods might be a pain). Each flag could then have it's own list of shapes that would be drawn on top of it when it's draw method is called. If you're interested in this method just ask and I'll go into greater detail.
