Dubai - Coding Challenge #49: Photo Mosaic with White House Social Media Images
Gebäude | Informationen | Videos | Emirates | Aussicht
In this Coding Challenge, I use a collection of Obama Administration's facebook images to create a "photo mosaic" of President Obama with Processing (Java). My Coding Challenge about social media data visualization with the White House data: https://youtu.be/UrznYJltZrU The White House Social Media Data is available here: https://www.whitehouse.gov/blog/2017/01/05/new-lenses-first-social-media-presidency The data and source code can be found with ITP "Obamathon" github repo: https://github.com/ITPNYU/Obamathon https://github.com/ITPNYU/Obamathon/tree/master/examples/Processing/ObamaMosaic Support this channel on Patreon: https://www.patreon.com/codingrainbow Send me your questions and coding challenges!: https://github.com/CodingRainbow/Rainbow-Topics Contact: https://twitter.com/shiffman Links discussed in this video: My Video on Pixel Arrays: https://youtu.be/EmtU0eloTlE Source Code for the all Video Lessons: https://github.com/CodingRainbow/Rainbow-Code p5.js: https://p5js.org/ Processing: https://processing.org For More Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH For an Introduction to Programming in the Processing Environment: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZYJC7L-r6rX6utt6wwJCyi Help us caption & translate this video! http://amara.org/v/2I4Y/
Bemerkungen
-
Wouldn't it be possible to use java8 streams to compute the averages?
-
Hi, I have a question. How can I save an image with the 'save' function without displaying it on the screen in Processing? 😅
-
if you use Processing image function to shrink the image to 1 pixel it should be an average color or the image.
-
Dan please stop with all the political references. I don't support Donald or Hillary, i really don't like when you bring politics in to the video.
-
please learn python and do coding challenges , i ve never touched js in my entire life and your videos are pretty much understandable..keep up good work nvm python thing
-
Where can I find all the pics to make the mosaic?
-
You are the best youtuber there is. Always so very happy :)
-
how to i add game over in this game ?? please i need game over because it is finally project
//Ultrasound plane, a game with a plane and an ultrsound sensor
int i, j;
int Score ;
float DistancePlaneBird;
float Hauteur; //en Y
float Angle;
int DistanceUltra;
int IncomingDistance;
//float Pas; //pour deplacements X
float BirdX;
float BirdY;
float GrassX ; //for X position
String DataIn; //incoming data
//5 a 32 cm
float [] CloudX = new float[6];
float [] CloudY = new float[6];
//vitesse constante hein
PImage Cloud;
PImage Bird;
PImage Plane;
PImage Grass;
// serial port config
import processing.serial.*;
Serial myPort;
//preparation
void setup()
{
myPort = new Serial(this, Serial.list()[1], 9600);
myPort.bufferUntil(10); //end the reception as it detects a carriage return
frameRate(30);
size(800, 600);
rectMode(CORNERS) ; //we give the corners coordinates
noCursor(); //why not ?
textSize(26);
Hauteur = 300; //initial plane value
Cloud = loadImage("cloud.png"); //load a picture
Bird = loadImage("bird.png");
Plane = loadImage("plane.png"); //the new plane picture
Grass = loadImage("grass.png"); //some grass
//int clouds position
for (int i = 1; i <= 5; i = i+1) {
CloudX[i]=random(1000);
CloudY[i]=random(400);
}
Score = 0;
}
//incoming data event on the serial port
void serialEvent(Serial p) {
DataIn = p.readString();
// println(DataIn);
IncomingDistance = int(trim(DataIn)); //conversion from string to integer
println(IncomingDistance); //checks....
if (IncomingDistance>1 && IncomingDistance<100 ) {
DistanceUltra = IncomingDistance; //save the value only if its in the range 1 to 100 }
}
}
//main drawing loop
void draw()
{
background(0, 0, 0);
Ciel(); //draw the sky
fill(5, 72, 0);
rect(0, 580, 800, 600); //some grass
text(Angle, 10, 30); //debug things...
text(Hauteur, 10, 60);
//new grass :
for (int i = -2; i <= 4; i = i+1) { //a loop to display the grass picture 6 times
image(Grass, 224*i + GrassX, 550, 224, 58); // 224 58 : picture size
}
//calculates the X grass translation. Same formulae than the bird
GrassX = GrassX - cos(radians(Angle))*10;
if (GrassX < -224) { //why 224 ? to have a perfect loop
GrassX=224;
}
text(Angle, 10, 30); //debug things...
text(Hauteur, 10, 60);
//new part : check the distance between the plane and bird and increase the score
DistancePlaneBird = sqrt(pow((400-BirdX), 2) + pow((Hauteur-BirdY), 2)) ;
if (DistancePlaneBird < 40) {
//we hit the bird
Score = Score+ 1;
//reset the bird position
BirdX = 900;
BirdY = random(600);
}
//here we draw the score
text("Score : ", 200, 30);
text( Score, 320, 30);
//Angle = mouseY-300; //uncomment this line and comment the next one if you want to play with the mouse
Angle = (18- DistanceUltra)*4; // you can increase the 4 value...
Hauteur = Hauteur + sin(radians(Angle))*10; //calculates the vertical position
//check the height range to keep the plane on the screen
if (Hauteur < 0) {
Hauteur=0;
}
if (Hauteur > 600) {
Hauteur=600;
}
TraceAvion(Hauteur, Angle);
BirdX = BirdX - cos(radians(Angle))*10;
if (BirdX < -30) {
BirdX=900;
BirdY = random(600);
}
//draw and move the clouds
for (int i = 1; i <= 5; i = i+1) {
CloudX[i] = CloudX[i] - cos(radians(Angle))*(10+2*i);
image(Cloud, CloudX[i], CloudY[i], 300, 200);
if (CloudX[i] < -300) {
CloudX[i]=1000;
CloudY[i] = random(400);
}
}
image(Bird, BirdX, BirdY, 109, 88); //displays the useless bird. 59 and 38 are the size in pixels of the picture
}
void Ciel() {
//draw the sky
noStroke();
rectMode(CORNERS);
for (int i = 1; i < 600; i = i+10) {
fill( 49 +i*0.165, 118 +i*0.118, 181 + i*0.075 );
rect(0, i, 800, i+10);
}
}
void TraceAvion(float Y, float AngleInclinaison) {
//draw the plane at given position and angle
noStroke();
pushMatrix();
translate(400, Y);
rotate(radians(AngleInclinaison)); //in degres !
/*
Drawing concept : ;-)
|\___o__
______>
*/
scale(0.6); //0.2 pas mal
//unless drawing the plane "by hands", just display the stored picture instead. Note that the parameters 2 and 3 are half the picture size, to make sure that the plane rotates in his center.
image(Plane, -111, -55, 323, 210); // 223 110 : picture size
popMatrix(); //end of the rotation matrix
}
//file end -
Hey Daniel! I have been watching your videos for some time now, being mostly a voyeur who doesn't interact much. However, I have a coding challenge for you (I am not sure where to post this, so here will do)! Curve shortening flow! Have the user draw a closed shape in your window/canvas, and create a program that minimizes the perimeter of said shape while keeping its area the same! Thanks for reading this, and I look forward to your future videos!
-
Your videos are very awesome ! i wish i had more hours to watch them all haha, Daniel i tried running your code but i got a NullPointerException error on line 41 D:, im really new at this so i dont know what it means, any idea what it means? thank you ! Looking forward to your next coding challenge
-
store a brightness to path mapping and load images lazily when you need them
-
can someone give me a location of where to download the photos as i cant find it on the website
-
Can you do some coding with java please because that is the language i am currently learning in Ap Computer Science and want to understand it better.
-
why use processing if you are using java? i use netbeans and it looks very different because i cannot see main methods. sopry if its dumb question i am new to programming
-
Question: Can you make, say, a full 2D game in processing? And if so, would it be efficient for physics-based games?
-
hello , DANIEL SHIFFMAN , is there any version of P5.JS for windows? cz i am using windows 8.1 and you know , i didn't find any way to run this p5.js on windows opereration ,
-
no offense but im starting to get a little annoyed with the white house challenges... mind moving on to something else? perhaps newtons second law of motion IN PROCESSING (with no extra libs to help you)... good luck with that if you eventually do that
-
I've used this code to make a sort-of present for my mother using old pictures but whatever I do, I can't use more than 10 images. How do I sample them down in advance or someother way that I can use the 100 images I collected (all less than 2 mb )?
-
4 persons voted for Trump
-
dude just wanna say, you rock!
697Bewertung