Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created January 12, 2021 11:25
Show Gist options
  • Select an option

  • Save hyuki/f4f2552bd5cf51760d32f8ed88f8e96b to your computer and use it in GitHub Desktop.

Select an option

Save hyuki/f4f2552bd5cf51760d32f8ed88f8e96b to your computer and use it in GitHub Desktop.
processing-newsletter-banner.java - Processingで結城浩ニュースレターのバナー作成
int MAX = 100;
int COUNT = 3;
int SIZE = 400;
int HUES = 100;
int FONTBASESIZE = 200;
int FONTRANGESIZE = 800;
size(1280, 670);
noStroke();
String[] fontlist = PFont.list();
for (int i = 0; i < 300 /* fontlist.length */; i++){
println(i + ":" + fontlist[i]);
}
int id = 100;
for (int hue = 0; hue < HUES; hue += 2) {
for (int count = 0; count < 2; count++) {
colorMode(RGB, 255);
background(255);
colorMode(HSB, MAX, MAX, MAX);
float bgsaturation = 5 + random(30);
float bgbrightness = 90 + random(10);
background(hue, bgsaturation, bgbrightness);
for(int i = 0; i < COUNT; i++) {
float fontsize = FONTBASESIZE + random(FONTRANGESIZE);
PFont f = createFont("Zapfino", fontsize);
// PFont f = createFont("HiraginoSans-W3", fontsize);
// PFont f = createFont("Wingdings2", fontsize);
// PFont f = createFont("BodoniOrnamentsITCTT", fontsize); // kararimoji
textFont(f);
textAlign(CENTER);
// float hue = random(MAX);
float saturation = random(MAX);
float brightness = random(MAX);
fill(hue, saturation, brightness, 50);
float mx = random(width);
float my = random(height);
float size = random(SIZE);
ellipse(mx, my, size, size);
String[] list = {
"Lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua","Ut","enim","ad","minim","veniam","quis","nostrud","exercitation","ullamco","laboris","nisi","ut","aliquip","ex","ea","commodo","consequat","Duis","aute","irure","dolor","in","reprehenderit","in","voluptate","velit","esse","cillum","dolore","eu","fugiat","nulla","pariatur","Excepteur","sint","occaecat","cupidatat","non","proident","sunt","in","culpa","qui","officia","deserunt","mollit","anim","id","est","laborum",
};
String s = "";
for (int c = 0; c < 10; c++) {
s += list[int(random(list.length))] + " ";
}
text(s, mx, my);
}
save("/Users/user/sand/newsletter-" + id + ".png");
id++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment