Skip to content

Instantly share code, notes, and snippets.

@shwang
Created September 15, 2022 21:24
Show Gist options
  • Save shwang/d1de16e3ac452da25147515a7d406989 to your computer and use it in GitHub Desktop.
Save shwang/d1de16e3ac452da25147515a7d406989 to your computer and use it in GitHub Desktop.
Thu Sept 15 Processing
import random
def setup():
size(400, 400)
ellipse(width/2, height/2, 50, 50)
background(255)
stroke(0)
fill(150, 100, 100)
rect(0, 80, 100, 100, 10)
visualize_array(ARRAY)
saveFrame("output.png")
ARRAY = [[1, 0, 0], [0, 0, 1], [1, 1, 1]]
def visualize_array(arr):
rows = len(ARRAY)
cols = len(ARRAY[0])
box_h = height / cols
box_w = width / cols
for r in range(rows):
for c in range(cols):
val = ARRAY[r][c]
if val:
fill(150, 250, 150, 80)
else:
noFill()
rect(c*box_w, r*box_h, box_w, box_h, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment