d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java Question
Add Reply New Topic New Poll
Member
Posts: 1,781
Joined: Mar 16 2007
Gold: 0.00
Mar 3 2013 12:26pm
I have two different files

One looks like:
import java.awt.Color;
public class GraffitiApp
{
public static void main(String[]a)
{

World wRef = new World();
ArtisticTurtle tRef = new ArtisticTurtle(wRef);

tRef.pentagon();





FileChooser.pickMediaPath();
Picture pRef;
pRef = new Picture(FileChooser.pickAFile());
pRef.explore();
Color purple = new Color(175, 0, 175);
Pixel pixRef;
pixRef = pRef.getPixel(340, 85);
pixRef.setColor(purple);
pixRef = pRef.getPixel(341, 85);
pixRef.setColor(purple);
pixRef = pRef.getPixel(342, 85);
pixRef.setColor(purple);
pixRef = pRef.getPixel(338, 85);
pixRef.setColor(purple);
pixRef = pRef.getPixel(339, 85);
pixRef.setColor(purple);
pixRef = pRef.getPixel(340, 84);
pixRef.setColor(purple);
pixRef = pRef.getPixel(340, 83);
pixRef.setColor(purple);
pixRef = pRef.getPixel(340, 86);
pixRef.setColor(purple);
pixRef = pRef.getPixel(340, 87);
pixRef.setColor(purple);

pRef.explore();

}

}

The other:
public class ArtisticTurtle extends Turtle
{
public ArtisticTurtle (Picture pRef)
{
super (pRef);
}
public static void main(String[]a)

{

World wRef = new World();
ArtisticTurtle tRef = new ArtisticTurtle(wRef);
tRef.pentagon();

}

public void pentagon()
{
this.forward( 20 );
this.turn( 72 );
this.forward( 20 );
this.turn( 72 );
this.forward( 20 );
this.turn( 72 );
this.forward( 20 );
this.turn( 72 );
this.forward( 20 );
this.turn( 72 );
this.penUp();
this.forward(100);
this.penDown();
this.forward(40);

}
public void spiral (int length)
{
this.forward( length );
length = length + length/5;
this.turn( 72 );
this.forward( length );
length = length + length/5;
this.turn( 72 );
this.forward( length );
length = length + length/5;
this.turn( 72 );
this.forward( length );
length = length + length/5;
this.turn( 72 );
}
public ArtisticTurtle(World wRef)
{
super(wRef);
}
}
The artistic turtle creates a world and moves around in it, the graffitiapp also opens the turtles world and moves him, along with bringing up two pictures, one with purple pixels the other without. turtle and world are both extra class paths i think, in case theres some confusion.

My problem is I need the turtle to draw on the picture with the pixels, not in its own world.
Anyone think they can help me out?
Member
Posts: 1,781
Joined: Mar 16 2007
Gold: 0.00
Mar 3 2013 06:37pm
New question:

I run this code
public void stickFigure(int scale)
{

this.turn(45);
this.forward(scale*40);
this.turn(90);
this.forward(scale*40);
this.backward(scale*40);
this.turn(-90-45);
this.forward(scale*40);
this.turn(55);
this.forward(scale*30);
this.backward(scale*30);
this.turn(-55-55);
this.forward(scale*30);
this.backward(scale*30);
this.turn(55);
this.forward(scale*20);
this.turn(-90);
this.forward(scale*12);
this.turn(90);
this.forward(scale*20);
this.turn(90);
this.forward(scale*24);
this.turn(90);
this.forward(scale*20);
this.turn(90);
this.forward(scale*12);
this.turn(90);
this.penUp();
this.forward(scale*5);
this.penDown();
this.turn(90);
this.forward(scale*5);
this.backward(scale*10);
this.turn(-90);
this.forward(scale*2);
this.backward(scale*2);
this.turn(90);
this.forward(scale*10);
this.turn(-90);
this.forward(scale*2);
this.penUp();
this.forward(scale*7);
this.penDown();
this.turn(-90);
this.forward(scale*3);
this.penUp();
this.forward(scale*4);
this.penDown();
this.forward(scale*3);
}
The first time i run it as stickFigure it works fine, the 2nd time it returns only the last 8 lines or so and they're flipped upside down. any reason why?
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll