Day/Night View of Experiment Township, NY

shulin zhang
Data Mining the City
3 min readSep 19, 2018

Title: Day/Night View of Experiment Township, NY

Sketch/Image:

Text:

This assignment is a further developed plan of the Experiment Township described in the previous assignment 1. White grids are residential blocks/buildings, red ones are commercial areas, and the central green area is the green space used for public gathering and other common usages.

During the daytime, residential buildings are flashing at a lower frequency compared to those busy commercial areas that flash at a higher frequency. Once we click the mouse, the plan switches to night hour. At that time, people went back home so residential buildings are a higher frequency compared to less busy commercial blocks.

The green space in the middle serving as a public gather plaza and neighborhood center is open all day so it is shown as lighting no matter day or night.

Gif:

Code:

CEL_SIZE, HALF_CEL = 50, 25
TIME, TIME_INCREMENT = 0,1
SMALL_SQUARE_SIZE = 50
FREQUENCY_OF_RED = 3
FREQUENCY_OF_WHITE = 20
STATUS = "Day"
FLAG = 1def setup():
global ROWS, COLS # filas e colunas
size(900,1000)
ROWS, COLS = height // CEL_SIZE, width // CEL_SIZE
rectMode(CENTER)
frameRate(20)
colorMode(RGB)
noStroke()
def draw():
global SQUARE_SIZE
global FLAG
global TIME
global FREQUENCY_OF_RED
global FREQUENCY_OF_WHITE
global STATUS
x = 100
TIME, TIME_INCREMENT = 0,1
FREQUENCY_OF_RED = 3
FREQUENCY_OF_WHITE = 20
STATUS = "Day"
def setup():
size(1000,1000)
rectMode(CENTER)
frameRate(20)
colorMode(RGB)
noStroke()
def draw():
global TIME
global FREQUENCY_OF_RED
global FREQUENCY_OF_WHITE
global STATUS
green_size = 100
red_size = 70
white_size = 50
x = 100
y = 120
spacing = 50
frequency_of_red = 5
frequency_of_white = 7
background(0)
textSize(44)
fill(80,120,45)
text(STATUS + " view of experiment township",50,50)

fill(0,255,0)
rect(680,203,20,20)
textSize(22)
fill(0,255,0)
text("Green space",700,210)


fill(255,0,0)
rect(680,233,20,20)
textSize(22)
fill(255,0,0)
text("Commercial",700,240)


fill(255,255,255)
rect(680,263,20,20)
textSize(22)
fill(255,255,255)
text("Residential",700,270)

fill(200,200,200)
rect(640,400,40,40)
textSize(16)
fill(200,200,200)
text("Press here to switch to night view",560,450)

for r in xrange(0,5):
for c in xrange(0,5):
if r == 2 and c == 2:
while green_size > 20:
fill(0, 255 + 3 * (green_size - 100) ,0)
rect(x + c * (white_size + spacing), y + r * (white_size + spacing), green_size, green_size)
green_size -= 10
elif (r == 1 or r == 3) and (c == 1 or c == 3):
if TIME % FREQUENCY_OF_RED != 0:
fill(255,0,0)
else:
fill(0,0,0)
rect(x + c * (white_size + spacing), y + r * (white_size + spacing), red_size, red_size)
else:
if TIME % FREQUENCY_OF_WHITE != 0:
fill(255,255,255)
else:
fill(0,0,0)
rect(x + c * (white_size + spacing), y + r * (white_size + spacing), white_size, white_size)

TIME += TIME_INCREMENT
if mousePressed and mouseX > 620 and mouseX < 660 and mouseY > 380 and mouseY < 420:
STATUS = "Night"
FREQUENCY_OF_RED = 20
FREQUENCY_OF_WHITE = 6

--

--