Skip to content

Commit 8ef2a16

Browse files
author
Abe Pazos
committed
Add new sketch and thumbs
1 parent ad00c6b commit 8ef2a16

File tree

44 files changed

+177
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+177
-26
lines changed
1.79 KB
7.39 KB
3.83 KB
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
Melt writer 25.02.2013
3+
4+
This program scans all the pixels on each draw()
5+
If pixels are below a brightness threshold, brightness
6+
is added, and neigboring pixels are darkened.
7+
8+
It searches for neighboring pixels using a spiral pattern,
9+
looking further and further for available pixels.
10+
11+
Not very efficient.
12+
13+
It would be more efficient to keep a map of active and inactive
14+
pixels.
15+
16+
Another option would be to affect only immediately neighboring
17+
pixels, which should then cascade. I did not do that because
18+
I fear this will provoke a rhombus shape. That's why I currently
19+
search in a circular pattern with increasing radius.
20+
21+
I would like paint to push outwards. Currently it "jumps" to
22+
a free location. This works for black and white, but if I was
23+
using colors it would not work.
24+
25+
I was also considering having a map of freshness, and the paint
26+
dries with time. The spreading of paint would only happen on
27+
wet areas. But ideally it should mix colors.
28+
*/
29+
final int SC_ITEMS = 997;
30+
float sinT[];
31+
float cosT[];
32+
PixelPusher pp;
33+
PGraphics canvas;
34+
35+
void setup() {
36+
size(400, 400);
37+
38+
canvas = createGraphics(width, height);
39+
canvas.beginDraw();
40+
canvas.background(255);
41+
canvas.strokeWeight(2);
42+
canvas.stroke(210,100);
43+
for(int y=0; y<height; y+=4) {
44+
canvas.bezier(
45+
0, y,
46+
map(noise(11, y/30.3), 0, 1, width*0.25, width*0.5), map(noise(6, y/23.3), 0, 1, y-12, y+12),
47+
map(noise(-3, y/11.5), 0, 1, width*0.5, width*0.75), map(noise(y/13.2, 5), 0, 1, y+12, y-12),
48+
width, y);
49+
}
50+
canvas.stroke(0);
51+
canvas.endDraw();
52+
53+
sinT = new float[SC_ITEMS];
54+
cosT = new float[SC_ITEMS];
55+
for (int i = 0; i < SC_ITEMS; i++) {
56+
sinT[i] = sin(float(SC_ITEMS) / float(i) * TWO_PI);
57+
cosT[i] = cos(float(SC_ITEMS) / float(i) * TWO_PI);
58+
}
59+
pp = new PixelPusher(200, 2);
60+
}
61+
void draw() {
62+
if(mousePressed) {
63+
canvas.beginDraw();
64+
canvas.line(pmouseX, pmouseY, mouseX, mouseY);
65+
pp.updateBwMap();
66+
}
67+
canvas.loadPixels();
68+
int a = frameCount;
69+
for (int y=0; y<height; y++) {
70+
for (int x=0; x<width; x++) {
71+
int i = x+y*width;
72+
if (pp.inc(i)) {
73+
float dist = 1;
74+
while (true) {
75+
a = (a + 303) % SC_ITEMS;
76+
int nx = x + int(dist * sinT[a]);
77+
int ny = y + int(dist * cosT[a]);
78+
int i2 = nx+ny*width;
79+
if(i2>=0 && i2<canvas.pixels.length) {
80+
if(pp.dec(i2)) {
81+
break;
82+
}
83+
}
84+
dist = dist + 0.5;
85+
}
86+
}
87+
}
88+
}
89+
canvas.updatePixels();
90+
canvas.endDraw();
91+
image(canvas, 0, 0);
92+
fill(#A8BC83);
93+
text("@fun_pro", width-70, height-10);
94+
}
95+
96+
// Changes the brightness of the given pixel
97+
// if its brightness is above or below the given threshold
98+
class PixelPusher {
99+
int threshold;
100+
int brightnessOffset;
101+
boolean bwMap[];
102+
103+
PixelPusher(int thresh, int off) {
104+
threshold = thresh;
105+
brightnessOffset = off;
106+
107+
bwMap = new boolean[canvas.width*canvas.height];
108+
updateBwMap();
109+
}
110+
boolean dec(int which) {
111+
if(bwMap[which]) {
112+
int newbri = int(brightness(canvas.pixels[which]) - brightnessOffset);
113+
canvas.pixels[which] = color(newbri);
114+
bwMap[which] = newbri > threshold;
115+
return true;
116+
}
117+
return false;
118+
}
119+
boolean inc(int which) {
120+
if(!bwMap[which]) {
121+
int newbri = int(brightness(canvas.pixels[which]) + brightnessOffset);
122+
canvas.pixels[which] = color(newbri);
123+
bwMap[which] = newbri > threshold;
124+
return true;
125+
}
126+
return false;
127+
}
128+
void updateBwMap() {
129+
canvas.loadPixels();
130+
for(int i=0; i<canvas.pixels.length; i++) {
131+
bwMap[i] = brightness(canvas.pixels[i]) > threshold;
132+
}
133+
}
134+
}
135+
136+
void keyPressed() {
137+
if(key == 's') {
138+
save("thumb.png");
139+
}
140+
}
Lines changed: 6 additions & 0 deletions
40 KB
8.64 KB
17.1 KB
3.17 KB
39.8 KB
3.74 KB
23.2 KB
5.85 KB
15.2 KB
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.png
99.7 KB
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.png

processing/ideas/2015/02/CCGame_Iterate001/CCGame_Iterate001.pde

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
PVector[] p;
1010
void setup() {
1111
size(1200, 1200);
12+
smooth(0);
1213
colorMode(HSB, 100);
1314
noStroke();
1415
doit();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.png
2+
*.png

processing/ideas/2015/09/noiseDirQuantized/noiseDirQuantized.pde

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ PGraphics route;
1010
PImage glow;
1111

1212
void setup() {
13-
size(1000, 1000);
14-
files = (new File("/home/funpro/Pictures - Nexus One/Instagram")).listFiles();
13+
size(1000, 1000, P2D);
14+
files = (new File("/home/funpro/Pictures/n1/Instagram")).listFiles();
1515

1616
glow = createImage(width, height, ARGB);
1717

@@ -137,4 +137,4 @@ void keyPressed() {
137137
if (key == 's') {
138138
save(System.currentTimeMillis() + ".png");
139139
}
140-
}
140+
}
6.88 KB
57.3 KB

processing/readme.md

Lines changed: 23 additions & 23 deletions

0 commit comments

Comments
 (0)