Created
October 31, 2013 20:53
-
-
Save rewfergu/7256972 to your computer and use it in GitHub Desktop.
Colorize external SVG in Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Blob { | |
PShape s, stroke, fills, shadow, accentOne, accentTwo, accentThree; | |
int baseColor = floor(random(100)); | |
int x, y; | |
float hScale, vScale; | |
// constructor | |
Blob(int blob_x, int blob_y, int blob_w, int blob_h) { | |
x = blob_x; | |
y = blob_y; | |
s = loadShape("blob.svg"); | |
hScale = blob_w / s.width; | |
vScale = blob_h / s.height; | |
stroke = s.getChild("stroke"); | |
stroke.disableStyle(); | |
stroke.scale(hScale, hScale); | |
fills = s.getChild("fill"); | |
fills.disableStyle(); | |
fills.scale(hScale, hScale); | |
shadow = s.getChild("shadow"); | |
shadow.scale(hScale, hScale); | |
accentOne = s.getChild("accent1"); | |
accentOne.scale(hScale, hScale); | |
accentOne.disableStyle(); | |
accentTwo = s.getChild("accent2"); | |
accentTwo.disableStyle(); | |
accentTwo.scale(hScale, hScale); | |
accentThree = s.getChild("accent3"); | |
accentThree.disableStyle(); | |
accentThree.scale(hScale, hScale); | |
} | |
//draw blobs | |
void display() { | |
noStroke(); | |
fill(baseColor, 50, 15); | |
shape(stroke, x, y); | |
fill(baseColor, 50, 80); | |
shape(fills, x, y); | |
fill(baseColor+5, 50, 50); | |
shape(accentOne, x, y); | |
fill(baseColor+10, 50, 50); | |
shape(accentTwo, x, y); | |
fill(baseColor-5, 50, 50); | |
shape(accentThree, x, y); | |
shape(shadow, x, y); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int baseColor = floor(random(100)); | |
int canvasWidth = 1000; | |
int canvasHeight = 1000; | |
int gridSize = 200; | |
int cols = canvasWidth / gridSize; | |
int rows = canvasHeight / gridSize; | |
void setup() { | |
int rowCount = 0; | |
size(canvasWidth, canvasHeight); | |
smooth(); | |
colorMode(HSB, 100); | |
fill(50, 10, 75); | |
rect(0,0,width,height); | |
for (int i = 0; i < cols*rows; i++) { | |
if (i > 1 && i%cols == 0) { | |
rowCount += gridSize; | |
} | |
Blob b = new Blob((i%cols)*gridSize, rowCount, gridSize, gridSize); | |
b.display(); | |
} | |
//saveFrame("screen.jpg"); | |
} | |
void draw() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment