Created
November 5, 2015 17:25
-
-
Save erikcox/11873cbef2837ac821ca to your computer and use it in GitHub Desktop.
A grid to help line things up when using graphics in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste inside public void paint() | |
g.setColor(Color.black); | |
g.setFont(new Font(null)); | |
for ( int X=0; X<800; X += 50 ) | |
g.drawString( String.valueOf(X), X, 50 ); | |
for ( int Y=100; Y<600; Y += 50 ) | |
g.drawString( String.valueOf(Y), 28, Y ); | |
// lines | |
g.setColor(Color.lightGray); | |
for ( int X=0; X<800; X += 50 ) | |
g.drawLine(X,0,X,599); // horizontal | |
for ( int Y=0; Y<600; Y += 50 ) | |
g.drawLine(0,Y,799,Y); // vertical |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment