These are chat archives for JonathanZwiebel/dfasbdasfdsafasd

2nd
Sep 2014
JonathanZwiebel
@JonathanZwiebel
Sep 02 2014 04:40
fadsfs
'''
'''
int code = 4;
'''
' ' '
int code = 4;
' ' '
'int code = 4'
' int code = 4 '
int code = 4
You should log out next time
@andrewqho
Sep 02 2014 04:42
?
i DON
T
UNDERSTAND
JonathanZwiebel
@JonathanZwiebel
Sep 02 2014 04:42
int code = 4;
code += 2;
Use the tilde three times
then code
then tilde three times
code
package flag;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class FlagPanel extends JPanel { 
    //I extended JPanel instead of JFrame so 
    //that part of my flag would not be covered by the border of the window 

    public FlagPanel() {
        setSize(950, 500);
    }

    public void init() {
        setBackground(Color.WHITE);
        repaint();
    }

    public void paintComponent(Graphics g){
        int height = this.getHeight();
        int width = height*(int)1.9;
        drawStripes(g, height, width);
        drawUnion(g, height, width);
        drawStarz(g, height, width);
    }

    public void drawStripes(Graphics g, int height, int width){
        Color OLD_GLORY_RED = new Color(0xBB133E);
        g.setColor(OLD_GLORY_RED);
        for(int i=0; i < 13; i++){ //Draws a red rectangle every other time
            if(i%2 == 0){
                g.fillRect(0, (height*i)/13, (int)(height*1.9), height/13);
            }

        }
    }

    public void drawUnion(Graphics g, int height, int width){
        Color OLD_GLORY_BLUE = new Color(0x0052A5);
        g.setColor(OLD_GLORY_BLUE);
        g.fillRect(0, 0, (int) (height*0.76), (int) (height*0.5385)); //everything dependent on the height, allowing it to rescale
    }

    public void drawStarz(Graphics g, int height, int width){
        g.setColor(Color.WHITE);
        int[] px = new int[10];
        int[] py = new int[10];
        double ro = this.getHeight()*(.0308);
        double ri = ro*(.3819);
        double angle1 = Math.PI/5;
        for(int starCount = 0; starCount<50; starCount++){ //Please note this is not exactly hardcoding... I cut it down by 7 fold!
            if(starCount < 6){
                for(int i = 0; i < 10; i++){
                    if(i%2 == 0){
                        px[i] = (int) (Math.cos(2.19911486+((i-1)*angle1))*ri)+(int)(.063*width)+(int)(starCount*.126*width);
                        py[i] = (int) (Math.sin((2.19911486+((i-1)*angle1)))*ri)+(int)(.054*height);//with this, it starts at the bottom-most inner point
                    }
                    else{
                        px[i] = (int) (Math.cos((Math.PI/2)+(i*angle1))*ro)+(int)(.063*width)+(int)(starCount*.126*width);
                        py[i] = (int) (Math.sin(((Math.PI/2)+(i*angle1)))*ro)+(int)(.054*height);//second point generated is the top-most outer point
                    }
                }
                g.fillPolygon(px, py, 10);
            }
            //same formula used for every other case below it. 
            //Basically, the only difference between each of the
            //following "cases" is the y-coord, which corresponds 
            //to starCount. The larger starCount is, the farther 
            //down the point is.
            else if(6 <= starCount && starCount <11){
                for(int i = 0; i < 10; i++){
                    if(i%2 == 0){
                        px[i] = (int) (Math.cos(2.19911486+((i-1)*angle1))*ri)+(int)(.126*width)+(int)((starCount-6)*.126*width);
                        py[i] = (int) (Math.sin((2.19911486+((i-1)*angle1)))*ri)+(int)(.054*height*2);
                    }
                    else{
                        px[i] = (int) (Math.cos((Math.PI/2)+(i*angle1))*ro)+(int)(.126*width)+(int)((starCount-6)*.126*width);
                        py[i] = (int) (Math.sin(((Math.PI/2)+(i*angle1)))*ro)+(int)(.054*height*2);
                    }
                }
                g.fillPolygon(px,py,10);
            }
            else if(11 <= starCount && starCount < 17){
                for(int i = 0; i < 10; i++){
                    if(i%2 == 0){
                        px[i] = (int) (Math.cos(2.19911486+((i-1)*angle1))*ri)+(int)(.063*width)+(int)((starCount-11)*.126*width);
                        py[i] = (int) (Math.sin((2.19911486+((i-1)*angle1)))*ri)+(int)(.054*height*3);
                    }
                    else{
                        px[i] = (int) (Math.cos((Math.PI/2)+(i*angle1))*ro)+(int)(.063*width)+(int)((starCount-11)*.126*width);
                        py[i] = (int) (Math.sin(((Math.PI/2)+(i*angle1)))*ro)+(int)(.054*height*3);
                    }
                }
                g.fillPolygon(px, py, 10);
            }
            else if(17 <= starCount && starCount < 22){
                for(int i = 0; i < 10; i++){
                    if(i%2 == 0){
                        px[i] = (int) (Math.cos(2.19911486+((i-1)*angle1))*ri)+(int)(.126*width)+(int)((starCount-17)*.126*width);
                        py[i] = (int) (Math.sin((2.19911486+((i-1)*angle1)))*ri)+(int)(.054*height*4);
                    }
                    else{
                        px[i] = (int) (Math.cos((Math.PI/2)+(i*angle1))*ro)+(int)(.126*width)+(int)((starCount-17)*.126*width);
                        py[i] = (int) (Math.sin(((Math.PI/2)+(i*angle1)))*ro)+(int)(.054*height*4);
                    }
                }
                g.fillPolygon(px,py,10);
            }
            else if(22 <= starCount && starCount < 28){
                for(int
You should log out next time
@andrewqho
Sep 02 2014 04:44
tilde?
what is a tilde?
JonathanZwiebel
@JonathanZwiebel
Sep 02 2014 04:44
yes
its a key
`
`
`
tilde: `
else if(11 <= starCount && starCount < 17){
                for(int i = 0; i < 10; i++){
                    if(i%2 == 0){
                        px[i] = (int) (Math.cos(2.19911486+((i-1)*angle1))*ri)+(int)(.063*width)+(int)((starCount-11)*.126*width);
                        py[i] = (int) (Math.sin((2.19911486+((i-1)*angle1)))*ri)+(int)(.054*height*3);
                    }
                    else{
                        px[i] = (int) (Math.cos((Math.PI/2)+(i*angle1))*ro)+(int)(.063*width)+(int)((starCount-11)*.126*width);
                        py[i] = (int) (Math.sin(((Math.PI/2)+(i*angle1)))*ro)+(int)(.054*height*3);
                    }
                }
                g.fillPolygon(px, py, 10);
            }
ok that seems to be one iteration through your stars
so instead of having many many else if blocks
You should log out next time
@andrewqho
Sep 02 2014 04:45
yes
what to do?
JonathanZwiebel
@JonathanZwiebel
Sep 02 2014 04:45
you could have a method where you enter the star count
else if(17 <= starCount && starCount < 22){
                for(int i = 0; i < 10; i++){
                    if(i%2 == 0){
                        px[i] = (int) (Math.cos(2.19911486+((i-1)*angle1))*ri)+(int)(.126*width)+(int)((starCount-17)*.126*width);
                        py[i] = (int) (Math.sin((2.19911486+((i-1)*angle1)))*ri)+(int)(.054*height*4);
                    }
                    else{
                        px[i] = (int) (Math.cos((Math.PI/2)+(i*angle1))*ro)+(int)(.126*width)+(int)((starCount-17)*.126*width);
                        py[i] = (int) (Math.sin(((Math.PI/2)+(i*angle1)))*ro)+(int)(.054*height*4);
                    }
                }
                g.fillPolygon(px,py,10);
            }
these are literally the same with the exception of one number
the 17 in place of the 11
You should log out next time
@andrewqho
Sep 02 2014 04:46
YES
LIKE A GOD
JonathanZwiebel
@JonathanZwiebel
Sep 02 2014 04:46
so you make a method that does that except instead of the 11 or the 17
you call it 'swag'
int swag;
You should log out next time
@andrewqho
Sep 02 2014 04:47
int swag?
wtf does that mean?
JonathanZwiebel
@JonathanZwiebel
Sep 02 2014 04:47
and then you can set swag using a big if else block
so instead of those two things you have above
you could have
if(swag < 17)
for(int i = 0; i < 10; i++){
if(i%2 == 0){
px[i] = (int) (Math.cos(2.19911486+((i-1)angle1))ri)+(int)(.126width)+(int)((starCount-swag).126width);
py[i] = (int) (Math.sin((2.19911486+((i-1)
angle1)))ri)+(int)(.054height4);
}
else{
px[i] = (int) (Math.cos((Math.PI/2)+(i
angle1))ro)+(int)(.126width)+(int)((starCount-swag).126width);
py[i] = (int) (Math.sin(((Math.PI/2)+(iangle1)))ro)+(int)(.054height4);
}
}
g.fillPolygon(px,py,10);
}
woops
if(starCount < 17)
swag = 11;
else
swag = 17;
for(int i = 0; i < 10; i++){
if(i%2 == 0){
px[i] = (int) (Math.cos(2.19911486+((i-1)angle1))ri)+(int)(.126width)+(int)((starCount-swag).126width);
py[i] = (int) (Math.sin((2.19911486+((i-1)angle1)))ri)+(int)(.054height4);
}
else{
px[i] = (int) (Math.cos((Math.PI/2)+(iangle1))ro)+(int)(.126width)+(int)((starCount-swag).126width);
py[i] = (int) (Math.sin(((Math.PI/2)+(iangle1)))ro)+(int)(.054height4);
}
}
g.fillPolygon(px,py,10);
}
like that
it sets the 'swag' at the top and then uses it
throughout
You should log out next time
@andrewqho
Sep 02 2014 04:49
oh ok
i'm not going to to do that now, but that's good for later I guess
because I'm a god
but i'm a lazy god
JonathanZwiebel
@JonathanZwiebel
Sep 02 2014 04:50
i was a lazy god
and i regretted it
so much homework today
ok cya
You should log out next time
@andrewqho
Sep 02 2014 04:51
ok bye
lol
the struggle
thanks though