quad() shapes or lines in a grid?
in
Programming Questions
•
1 year ago
Hi everyone,
I've been trying to wrap my head around this annoying, yet probably simple solution: I have build this mouse attractor code, that affects a grid of points. Now, I want to draw either lines or quads between the points, so that I have a rectangular grid instead of just points.
Any suggestions to how I can do that? I've been trying to figure it out with PVector and 2D arrays, but I just can't get it to work.
Thanks in advance!
Here is the code:
- int step = 10;
- void setup() {
- size(800, 500);
- smooth();
- fill(100, 100);
- }
- void draw() {
- background(255);
- for (int x = step; x < width-step; x += step) {
- for (int y = step; y < height-step; y += step) {
- float d = dist(x, y, mouseX, mouseY);
- PVector mouse = new PVector(mouseX, mouseY);
- PVector center = new PVector(x, y);
- mouse.sub(center);
- mouse.div(0.1*d);
- pushMatrix();
- translate(x, y);
- point(mouse.x, mouse.y);
- popMatrix();
- }
- }
- }
1