Skip to content

Instantly share code, notes, and snippets.

@Nekodigi
Created June 24, 2020 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nekodigi/3cc6fa31140935b5a5677afa77754099 to your computer and use it in GitHub Desktop.
Save Nekodigi/3cc6fa31140935b5a5677afa77754099 to your computer and use it in GitHub Desktop.
float gSize=10;//grid size
void setup(){
size(500, 500);
background(255);
fill(0);
noStroke();
int x1 = 10;
int y1 = 10;
int x2 = 20;
int y2 = 40;
int dx = x2 - x1;
int dy = y2 - y1;
if(dx > dy){
for(int x = x1; x <= x2; x++){
int y = y1 + dy * (x - x1) / dx;
rect(x*10, y*10, 10, 10);
}
}else{
for(int y = y1; y <= y2; y++){
int x = x1 + dx * (y - y1) / dy;
rect(x*10, y*10, 10, 10);
}
}
}
void draw(){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment