Setting up the coordinates – the modified code

Here is the code that I am using now to set up the coordinates. It is slightly different from the post “setting up the coordinates“. I put it in a separate tab to make debugging easier.

 
// use this in setup():
void setupCoordinates(){  
  trueStrokeWeight(1.);
  vectorDiameter=8/unitLength;
  xRange=0.5*width/unitLength;
  yRange=0.5*height/unitLength;
}

// use this in draw():
void doTransformations(){  
  translate(width/2,height/2);
  scale(unitLength,-unitLength);
}

// use this to change the line width independently from the unitLength:
void trueStrokeWeight(float weight){
 strokeWeight(weight/unitLength);
}
This entry was posted in programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s