From 9f0eb4a149baef141ab1990cf45a3da0d11cf32a Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Tue, 22 Sep 2020 21:57:56 +1000 Subject: [PATCH] new: outlined squareGen --- squareGen/squareGen.pde | 42 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/squareGen/squareGen.pde b/squareGen/squareGen.pde index 4dbb59a..6a0d71e 100644 --- a/squareGen/squareGen.pde +++ b/squareGen/squareGen.pde @@ -1,6 +1,9 @@ +import java.util.*; + int size = 250; int weight = 20; -int gridSize = 20; +int cellSize = 20; +int gridSize = 5; int repetitions = int(random(5)); int dir = int(random(0, 2)); @@ -20,7 +23,38 @@ void draw() { stroke(0); strokeWeight(weight/2); //fill(255); - float startX = centerW + weight; - float startY = centerH + weight; - line(startX, startY, startX + (gridSize*repetitions*(1-dir)), startY + (gridSize*repetitions*dir)); + //float startX = centerW + weight; + //float startY = centerH + weight; + //line(startX, startY, startX + (gridSize*repetitions*(1-dir)), startY + (gridSize*repetitions*dir)); +} + +class Grid { + grid = int[gridSize][gridSize]; + + void fillGrid() { + // pick a random empty cell + int X = int(random(0, gridSize)); + int Y = int(random(0, gridSize)); + // pick a length for the line + int len = int(random(0, 5)); + // choose a direction to extend the 'head' of the line from + int dir = int(random(0, 4)); + + // repeat until length of line is reached + // repeat until grid is filled + } +} + +class Line { + LinkedList line = new LinkedList(); + + void add(int point) { + line.add(point); + } + + void draw() { + // for each point in the list + // draw a line for each adjacent point + // translate it to the screen position + } }