processing-coding-diary
processing-coding-diary
Coding Diary
38 posts
Processing, JavaScript
Don't wanna be here? Send us removal request.
processing-coding-diary 7 years ago
Photo
Tumblr media
size(600, 400); background(0);
//for (int x=0; x<width; x++) { // 聽set(x, 200, color(255,0,0)); //}
//loadPixels(); //for (int i=0; i <pixels.length; i++){ //pixels[i] = color(random(255),0,random(3,250)); //} //updatePixels();
loadPixels(); for (int x = 0; x < width; x++) { 聽for (int y = 0; y < height; y++){ 聽 聽float d = dist(x,y,width/2,height/2); 聽 聽int loc = x+y*width; 聽 聽pixels[loc]=color(d); 聽} } updatePixels();
0 notes
processing-coding-diary 7 years ago
Photo
Tumblr media
size(600, 400); background(0);
//for (int x=0; x<width; x++) { // 聽set(x, 200, color(255,0,0)); //}
loadPixels(); for (int i=0; i <pixels.length; i++){ pixels[i] = color(random(130),random(20,200),random(30,50)); } updatePixels();
1 note View note
processing-coding-diary 7 years ago
Photo
Tumblr media
size(600, 400); background(0);
//for (int x=0; x<width; x++) { // 聽set(x, 200, color(255,0,0)); //}
loadPixels(); for (int i=0; i <pixels.length; i++){ pixels[i] = color(random(25),0,random(30,250)); } updatePixels();
2 notes View notes
processing-coding-diary 7 years ago
Photo
Tumblr media
size(600, 400); background(0);
//for (int x=0; x<width; x++) { // 聽set(x, 200, color(255,0,0)); //}
loadPixels(); for (int i=0; i <pixels.length; i++){ pixels[i] = color(random(255),0,random(3,250)); } updatePixels();
1 note View note
processing-coding-diary 7 years ago
Video
tumblr
int maxImages = 10; int imageIndex = 0;
PImage[] images = new PImage [maxImages];
void setup() { 聽size(500, 500);
聽for (int i=0; i <images.length; i++) { 聽 聽images[i] = loadImage( "number" + i + ".jpg" ); 聽} }
void draw() { 聽image(images[imageIndex], 0, 0); }
void mousePressed() { 聽imageIndex = int(random(images.length)); }
0 notes
processing-coding-diary 7 years ago
Video
tumblr
int maxImages = 9; int imageIndex = 0;
PImage[] images = new PImage [maxImages];
void setup() { 聽size(400, 300);
聽for (int i=0; i <images.length; i++) { 聽 聽images[i] = loadImage( "number" + i + ".jpg" ); 聽 聽 frameRate(5); 聽} }
void draw() { 聽background(0); 聽image(images[imageIndex], 0, 0); 聽// increment image index by one each cycle 聽// use modulo " % "to return to 0 once the end of the array is reached 聽imageIndex = (imageIndex + 1) % images.length; }
0 notes
processing-coding-diary 7 years ago
Text
int maxImages = 10; // Total # of images
int imageIndex = 0; // Initial image to be displayed is the first
// Declaring an array of images. PImage[] images = new PImage[maxImages];
void setup() { 聽size(200, 200);
聽// Loading the images into the array 聽// Don't forget to put the JPG files in the data folder! 聽for (int i = 0; i < images.length; i ++ ) { 聽 聽images[i] = loadImage( "animal" + i + ".jpg" ); 聽} }
void draw() { 聽// Displaying one image 聽image(images[imageIndex], 0, 0); }
void mousePressed() { 聽// A new image is picked randomly when the mouse is clicked 聽// Note the index to the array must be an integer! 聽imageIndex = int(random(images.length)); }
0 notes
processing-coding-diary 7 years ago
Video
tumblr
PImage devilRay; Bubble b1; Bubble b2;
void setup() { 聽size(640, 360); 聽devilRay = loadImage("Devil_Rays_01.jpg"); 聽b1=new Bubble(150);//calling constructor 聽b2=new Bubble(120); }
void draw() { 聽background(255); 聽//imageMode(CENTER); 聽image(devilRay, 0, 0); 聽b1.ascend(); 聽b1.display(); 聽b1.top();
聽b2.ascend(); 聽b2.display(); 聽b2.top(); }
//void mousePressed() { //b.pop(); //} //////////////////////////////////////////////
class Bubble { 聽float x; 聽float y; 聽float diameter;
聽Bubble(float tempD) { 聽 聽x=width/2; 聽 聽y=height; 聽 聽diameter=tempD; 聽}
聽void ascend() { 聽 聽y--; 聽 聽x=x+random(-5, 5); 聽}
聽void display() { 聽 聽//stroke(0); 聽 聽//fill(127); 聽 聽//ellipse(x, y, diameter, diameter); 聽 聽//tint(255,127);//alpha 聽 聽imageMode(CENTER); 聽 聽image(devilRay, x, y, diameter, diameter); 聽}
聽void top() { 聽 聽if (y<diameter/2) 聽 聽 聽y=diameter/2; 聽} }
0 notes
processing-coding-diary 7 years ago
Photo
Tumblr media
String[] words; IntDict concordance;
void setup() { 聽size (600, 400); 聽String[] lines = loadStrings("hamlet.txt"); 聽String allthetxt = join(lines, " "); 聽words = splitTokens(allthetxt, " ,.:;!"); 聽concordance = new IntDict();
聽for (int i=0; i<words.length; i++) { 聽 聽concordance.increment(words[i]); 聽} 聽println(concordance); }
0 notes
processing-coding-diary 7 years ago
Video
tumblr
String[] words; int index;
void setup() { 聽size(600, 400); 聽background(0); 聽String[] lines=loadStrings("hamlet.txt"); 聽String entireplay=join(lines, " "); 聽println(lines); 聽words=splitTokens(entireplay, ",.?!: "); 聽printArray(words); 聽frameRate(5); }
void draw() { 聽background(0); 聽fill(255); 聽textSize(64); 聽textAlign(CENTER); 聽text(words[index]. toLowerCase(), width/2, height/2); 聽index++; }
2 notes View notes
processing-coding-diary 7 years ago
Video
tumblr
String[] words; int index;
void setup() { 聽size(600, 400); 聽background(0); 聽String[] lines=loadStrings("hamlet.txt"); 聽String entireplay=join(lines, " "); 聽println(lines); 聽words=splitTokens(entireplay, ",.?!: "); 聽printArray(words); 聽frameRate(5); }
void draw() { 聽background(0); 聽fill(255); 聽textSize(64); 聽textAlign(CENTER); 聽text(words[index], width/2, height/2); 聽index++; }
0 notes
processing-coding-diary 7 years ago
Video
tumblr
String[] words; int index;
void setup() { 聽size(600, 400); 聽background(0); 聽String[] lines=loadStrings("hamlet.txt"); 聽String entireplay=join(lines, " "); 聽println(lines); 聽words=split(entireplay, " "); }
void draw() { 聽background(0); 聽fill(255); 聽textSize(64); 聽textAlign(CENTER); 聽text(words[index], width/2, height/2); 聽index++; }
0 notes
processing-coding-diary 7 years ago
Photo
Tumblr media
String s="To be or not to be."; String[] words;
void setup() { 聽size(600, 400); 聽background(0); 聽String[] lines=loadStrings("hamlet.txt"); 聽printArray(lines); 聽words=split(s, " "); }
void draw() { 聽for (int i=0; i<words.length; i++) { 聽 聽fill(255, 127); 聽 聽stroke(255); 聽 聽textSize(32); 聽 聽text(words[i], 50+i*100, 200); 聽} }
0 notes
processing-coding-diary 7 years ago
Photo
Tumblr media
String s="To be or not to be."; String[] words;
void setup() { 聽size(600, 400); 聽background(0); 聽words=split(s, " "); }
void draw() { 聽for (int i=0; i<words.length; i++) { 聽 聽fill(255, 127); 聽 聽stroke(255); 聽 聽textSize(32); 聽 聽text(words[i],50+i*100,200); 聽} }
0 notes
processing-coding-diary 7 years ago
Photo
Tumblr media
size(600,400); background(0); String s="10,20,30,40,50,60,70,80,90,100,10,20,30,40,50";
String[] nums = split(s,",");
int[] vals=int(nums);
for (int i=0; i<nums.length; i++){ 聽ellipse(i*50,200,vals[i],vals[i]); }
0 notes
processing-coding-diary 7 years ago
Text
PImage hog; PImage apple;
void setup(){ 聽size(600,400); hog=loadImage("hog.jpg"); apple=loadImage("apple.jpeg"); }
void draw(){ 聽background(0); 聽image(apple,0,0,mouseX,mouseY); 聽image(hog,0,0,mouseX/2,mouseY/2);
聽fill(0,255,0); 聽tint(200,mouseY,mouseX); 聽ellipse(300,200,10,10); }
0 notes
processing-coding-diary 7 years ago
Video
tumblr
Bubble[] bubbles = new Bubble[100];
int total=0;
void setup() { 聽size(640, 360); 聽for (int i =0; i<bubbles.length; i++) { 聽 聽bubbles[i] = new Bubble(random(20, 40)); 聽} }
void mousePressed() { 聽total=total+1; }
void keyPressed() { 聽total=total-1; }
void draw() { 聽background(255); 聽for (int i =0; i<total; i++) { 聽 聽bubbles[i].ascend(); 聽 聽bubbles[i].display(); 聽 聽bubbles[i].top(); 聽} 聽//saveFrame("output/multiple_bubbles_size_flexible_####.png"); }
class Bubble { 聽float x; 聽float y; 聽float diameter; 聽float yspeed;
聽Bubble(float tempD) { 聽 聽x=random(width); 聽 聽y=height; 聽 聽diameter=tempD; 聽 聽yspeed=random(0.5,2.5); 聽}
聽void ascend() { 聽 聽y=y-yspeed; 聽 聽x=x+random(-2, 2); 聽}
聽void display() { 聽 聽stroke(0); 聽 聽noFill(); 聽 聽//fill(255,50);// color yellow bubbles 聽 聽ellipse(x, y, diameter, diameter); 聽}
聽void top() { 聽 聽if (y<diameter/2) 聽 聽 聽y=diameter/2; 聽} }
0 notes