can i put proverb on the photo in this processing?
in
Programming Questions
•
2 years ago
import processing.opengl.*;
///////
PFont[] fontList = new PFont[14];
float xx = random(0, 13);
int yy = int(xx);
float zz = random(0, 61);
int aa = int(zz);
///////
class Photo{
PImage img;
float x;
float y;
float smallWidth;
float smallHeight;
float currentWidth;
float currentHeight;
int id;
boolean loading;
public Photo(String url,float nx,float ny,int _id){
img = requestImage(url);
id = _id;
loading = true;
x = nx;
y = ny;
}
public void doneLoading(){
loading = false;
if(img.width > img.height){
currentWidth = smallWidth = 50;
currentHeight = smallHeight = img.height*(50/(float)img.width);
}
else{
currentWidth = smallWidth = img.width*(50/(float)img.height);
currentHeight = smallHeight = 50;
}
}
public void drawImage(PGraphics g){
g.beginShape();
g.texture(img);
g.vertex(x*50 + (50-currentWidth)/2, y*50+(50-currentHeight)/2, 0, 0);
g.vertex(x*50+currentWidth+(50-currentWidth)/2, y*50+(50-currentHeight)/2, 1, 0);
g.vertex(x*50+currentWidth+(50-currentWidth)/2, y*50+currentHeight+(50-currentHeight)/2, 1, 1);
g.vertex(x*50+(50-currentWidth)/2, y*50+currentHeight+(50-currentHeight)/2, 0, 1);
g.endShape();
}
}
int NUMOFIMAGES = 1;
XMLElement xml;
ArrayList photos;
void setup(){
size(595,842,OPENGL);
background(random(255),random(255),random(255));
////////
fontList[0] = createFont("Centaur", 19);
fontList[1] = createFont("Garamond", 19);
fontList[2] = createFont("GoudyOldStyleT-Regular", 19);
fontList[3] = createFont("TimesNewRomanPSMT", 19);
fontList[4] = createFont("PalatinoLinotype-Roman", 19);
fontList[5] = createFont("BaskOldFace", 19);
fontList[6] = createFont("BodoniMT", 19);
fontList[7] = createFont("CenturySchoolbook", 19);
fontList[8] = createFont("FranklinGothic-Book", 19);
fontList[9] = createFont("GillSansMT", 19);
fontList[10] = createFont("Perpetua", 19);
fontList[11] = createFont("CooperBlack", 19);
fontList[12] = createFont("LucidaSans", 19);
fontList[13] = createFont("Rockwell", 19);
String [] words = {"A full belly is the mother of all evil","A gift in season is a double favor to the needy","A man that has no virtue in himself, ever envies virtue in others","A minute's success pays the failure of years","A poet is the painter of the soul","Absence makes the heart grow fonder","All fortune is to be conquered by bearing it","All good things which exist are the fruits of originality","Appearances are deceptive","Better is to bow than break","Better the last smile than the first laughter","Books are ships which pass through the vast seas of time","By doubting we come at the truth","Courage is very import!ant Like a muscle, it is strengthened by use","Education is the best provision for old age","Envy and wrath shorten the life","Error is the discipline through which we advance","Faith is a higher faculty than reason","Faith without deeds is useless","Forgiveness is better than revenge","Give me liberty, or give me death","Good fences makes good neighbors","Great art is an instant arrested in eternity","Habit is second nature","He is greatest who is most often in men's good thoughts","He that has no shame has no conscience","He who spares the rod hates his son, but he who loves him is careful to discipline him","Heaven gives its favourites - early death","I never think of the future It comes soon enough","In giving advice, seek to help, not to please, your friend","In the morning of life, work; in the midday, give counsel; in the evening, pray","It is a wise father that knows his own child","Let thy speech be short, comprehending much in few words","Life is the art of drawing sufficient conclusions from insufficient premises","Life itself is a quotation","Love your neighbor as yourself","Music is a beautiful opiate, if you dont take it too seriously","Nature never deceives us; it is always we who deceive ourselves","Only the just man enjoys peace of mind","Pain past is pleasure","Painless poverty is better than embittered wealth","Suspicion follows close on mistrust","The difficulty in life is the choice","The most beautiful thing in the world is, of course, the world itself","The will of a man is his happiness","The world is a beautiful book, but of little use to him who cannot read it","Things are always at their best in the beginning","Think like a man of action and act like man of thought","Time is but the stream I go a-fishing in","To be trusted is a greater compliment than to be loved","To doubt is safer than to be secure","To jaw-jaw is better than to war-war","United we stand, divided we fall","Until the day of his death, no man can be sure of his courage","Waste not fresh tears over old griefs","We give advice, but we cannot give conduct","We never know the worth of water till the well is dry","Weak things united become strong","When money speaks, the truth keeps silent","Where there is no desire, there will be no industry","Who begins too much accomplishes little","Who knows much believes the less"};
int index = int(random(words.length));
textAlign(CENTER);
fill(random(255),random(255),random(255));
textFont(fontList[yy], 19);
text(words[index], width/2, 250);
////////
photos = new ArrayList();
xml = new XMLElement(this, "http://api.flickr.com/services/rest/?method=flickr.photos.getRecent&api_key=99835d77b01b776f3115b56180c6c4f4&per_page="+NUMOFIMAGES);
XMLElement photoList = xml.getChild(0);
int childCount = photoList.getChildCount();
int perRow = childCount/1;
int yPos = 0;
for(int i = 0; i < childCount;i++){
String farm = photoList.getChild(i).getAttribute("farm");
String server = photoList.getChild(i).getAttribute("server");
String id = photoList.getChild(i).getAttribute("id");
String secret = photoList.getChild(i).getAttribute("secret");
if(i%perRow == 0){
yPos++;
}
photos.add(new Photo("http://farm"+farm+".static.flickr.com/"+server+"/"+id+"_"+secret+".jpg",i%perRow,yPos,i+1));
}
imageMode(CENTER);
textureMode(NORMALIZED);
noStroke();
smooth();
}
void draw(){
scale(11);
translate(2,-30);
for(int i = 0; i< photos.size();i++){
Photo p = (Photo)photos.get(i);
if(p.loading && p.img.width >0){
p.doneLoading();
}
p.drawImage(g);
}
}
//////////////////////////////////////////////////////////////
Now I'm making "Random Proverb maker" with the gorgeous programming form (
http://forum.processing.org/topic/flickr-image-wall)
Simply speaking, this is just one random proverb and one random photo.
And a viewer can make meaning by connecting these.
But I couldn't find the way to put a proverb on the photo.
If someone know the way, please help me..
1