Home

Lab 4

Read the notes about for() loops.

Gaudy motel carpets

Your task is to use for() loops and shapes and colors to recreate one of the following textures. You must recreate it exactly (within a few pixels); use the colors specified. You can use a different window size, if you want, but make it big enough for the texture to repeat a few times.

Option 1

Colors: #ab6623, #74340e, #e8a204.
This one has the simplest code, but requires some thinking to get the layering correct.

Option 2

Colors (in RGB+alpha): red = [203, 0, 0, 128], green = [86, 102, 35, 220].
The code for this one is simple, conceptually, but I found it quite difficult to position the lines correctly. And I have no idea why some green lines appear above, and others below the red bars. Maybe your solution won't have that problem.

Option 3

Colors: background = #4e4c4d, gray stroke: #b3b3b3, gray fill: #666666, yellow: #fbf9c9.
This code is a straight-forward rows/cols double-for()-loop. Assuming i is the row and j is the column, the there is a yellow fill when (i+2*j) % 4 == 0 and a yellow outline when (2*i+j) % 7 == 1. Be sure to use those rules to exactly recreate this image.

Option 4

Recreate this carpet, from The Shining:

I’ll be impressed if you can recreate the more famous carpet.

By famous, I mean, well,

CSCI 111 material by Joshua Eckroth is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Source code for this website available at GitHub.