MEDA102: Digital Coding
Burning Flag
For this piece, I tried to abstract a burning flag. Originally I had decided to try and recreate Vera Molnar’s “Structure du Quadrilatere”. I wrote up a function that generates a series of squares (this was the function I shared in the Week 6’s workshop). After some time experimenting with the squares in different formations and set-ups, I decided to go with a grid, and implemented a perlin noise map to determine the colour and distortion of each set of squares. At this point, I decided to instead recreate a burning flag rather than Vera’s work, so I “weighted” the distortion of the squares toward the right of the piece to give the impression of fabric moving in the wind, so the further to the right of the piece, the more the squares distort (still in accordance with the noise map of course, as I believe the patches of more orderly squares give it a sense of uncontrollable burning).
Source Code
void setup() { size(850,650); background(255); noLoop(); } void draw() { //set stroke weight to something a little lighter than default to allow for more noticeable overlap between squares strokeWeight(0.5); //these two for loops define the grid, 20 pixel intervals. //the loops start at 30 pixels and end slightly earlier than expected to add padding around the piece. for(float i = 30; i < 800 ; i = i + 20){ for(float j = 30; j < 600 ; j = j + 20){ //this sets the stroke colour to a value between black and red based on a perlin noise map stroke(noise(i / 100, j / 100) * 275, 0, 0); /* creates 3 squares at the given point on the grid, 20x20 pixels each the noise() function here sets the variation based on the same perlin noise map meaning the more red an area is, the more distorted the squares there are also. however, it also multiplies it by the X coordinate of the current square divided by 30 meaning that squares toward the right of the piece distort more than the left side */ squares(i, j, 3, 20, noise(i / 100, j / 100) * i / 30); } } } /* squares() draws a set number of squares at a fixed point usage: squares(x, y, count, size, variation); x/y = coordinates of the top left point of the squares count = the number of squares size = the width of each square variation defines the upper limit for the random amount of variation at each point of the square in pixels. higher numbers result in more distorted looking squares, a variation of 0 is a perfect square. */ void squares(float x, float y, float count, float size, float variation) { //set to no fill so that the overlapping of each square is more defined noFill(); //repeats for as long as defined by "count" for (int i = 0; i < count; i++) { //draws the actual square, the variation value gets added to the position of each point beginShape(); vertex(x + random(variation),y + random(variation)); //first point vertex(x + size + random(variation), y + random(variation)); //second point vertex(x + size + random(variation), y + size + random(variation)); //third point vertex(x + random(variation), y + size + random(variation)); //fourth point endShape(CLOSE); } }










