This site requires JavaScript, please enable it in your browser!
Greenfoot back
fluttershy
fluttershy wrote ...

2013/10/26

How do i draw a line

fluttershy fluttershy

2013/10/26

#
code to draw a line from (x1, y1) to (x2, y2)?
Kartoffelbrot Kartoffelbrot

2013/10/26

#
As an image or an actor?
fluttershy fluttershy

2013/10/26

#
anything would be fine
fluttershy fluttershy

2013/10/26

#
I tried this:
1
2
3
GreenfootImage art = new GreenfootImage(1,1);
        art.setColor(Color.BLUE);
        art.drawLine(prevx, prevy, presx, presy);
but it is wrong although it compiled what do i do
danpost danpost

2013/10/26

#
The image you are trying to draw the line on is 1 pixel wide by 1 pixel high. At most you will change a point and you need more than one point to draw a line.
Kartoffelbrot Kartoffelbrot

2013/10/27

#
The upper left corner of a GreenfootImage has the coordinates (0/0).
danpost danpost

2013/10/27

#
@Kartoffelbrot, I was referring to line 1 in the code given above. The image being create (the one that is to be drawn on) is too small to draw a line on.
Kartoffelbrot Kartoffelbrot

2013/10/27

#
I know. I wasn't referring to your comment. I only wanted to help and maybe that was a problem, too.
You need to login to post a reply.