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

2012/4/20

line with an thickness

tylers tylers

2012/4/20

#
how do you make a line with an thickness? ive managed to do this :
GreenfootImage img = getBackground();
and this in the constructor:
img.setColor(new Color(255, 0, 0)); 
        
        img.drawLine(400,200,500,250);
Builderboy2005 Builderboy2005

2012/4/20

#
I would do something like this:
for(int i=0;i<thickness;i++){
   for(int j=0;j<thickness;j++){
      img.drawLine(Xpos1+i,Ypos1+j,Xpos2+i,Ypos2+j);
   }
}
Not the most efficient, but it is simple and uses the basic GreenfootImage methods instead of trying to manipulate the BufferedImage
tylers tylers

2012/4/20

#
it works thanks :D
You need to login to post a reply.