Monday, May 31, 2010
honey
// use the mouse
// was thinking of a hexagonal memory
// structure, addressable in 3
// directions, but got sidetracked
// after a glass of hungarian wine
// handmade font, based on a 14 segment display.
// 201006010628: insomnia made me make
// this really CPU heavy.
int frames;
int[] font = {12044, 13063, 15360, 13059, 15372, 11276, 15620, 3852, 12291,
5888, 3160, 7168, 4032, 3984, 16128, 11788, 16144, 11804,
12676, 8195, 7936, 3168, 3888, 240, 193, 12384, 16224, 832,
13836, 13060, 2828, 14604, 15628, 8257, 16140, 11020, 14607,
255, 15, 12, 96, 4108, 15360, 13056, 80, 160, 4096, 0
};
char[] alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '$', '*', '+', '-', '/', '=', '[', ']',
'(', ')', '_', ' '
};
void draw_cell(int x,int y,float size)
{
int sides=6;
beginShape();
for (int i=1; i<=sides; i++)
{
float a=(i/(float)sides)*2*PI;
vertex(x+size*sin(a),
y+size*cos(a));
}
endShape();
}
void draw_honeycomb(int w, int h, int f)
{
char[] word = {'S','L','U','B','M','E','M','O','R','Y','L','O','S','S'};
fill(0);
strokeWeight(3);
for (int x=0; x<w; x++)
{
for (int y=0; y<h; y++)
{
float px = 50 + x * 57 + (y % 2 ? 0 : 28);
float py = 50 + y * 50;
float size =(sin(x * mouseX * 0.002 + f * 0.05 + y * mouseY * 0.002) + 1.0) * 0.5;
stroke(0);
fill(size * 255);
draw_cell(px,py,size*30);
stroke(128);
pushMatrix();
translate(px - (size * 8),py -(size * 8));
scale(size);
drawLetter(word[int((size + 1.0) * 0.5 * word.length)]);
popMatrix();
}
}
}
void setup()
{
background(255);
size(500,300);
smooth();
frames = 0;
}
int t=0;
void draw()
{
background(255);
drawMessage();
// fill(255);
noStroke();
// rect(0,0,800,300);
fill(0);
draw_honeycomb(7,5,t);
t++;
}
void drawMessage() {
stroke(200);
pushMatrix();
translate(0, 100);
scale(4);
char[] word = {'*', ' ', 'S', 'L', 'U', 'B', ' ', 'L', 'O', 'V', 'E', 'S', ' ', '$', 'Y', 'O', 'U', ' ', '*'};
drawText(word, 125, frames * 3);
++frames;
popMatrix();
}
void drawText(char[] word, int sz, int offset) {
strokeWeight(3);
int chars = (sz / 20) + 1;
pushMatrix();
translate(0 - offset % 20, 0);
for (int i = 0; i < chars; ++i) {
int j = int(offset / 20) + i;
drawLetter(word[j % word.length]);
translate(20, 0);
}
popMatrix();
}
void drawLetter(char letter) {
int l = 0;
for (int n = 0; n < alphabet.length; ++n) {
if (alphabet[n] == letter) {
l = font[n];
}
}
for (int i = 0; i < 14; ++i) {
if((l & int(pow(2, 13-i))) != 0) {
switch(i) {
case 0: line(0, 0, 16, 0); break; // t
case 1: line(0, 20, 16, 20); break; // b
case 2: line(0, 0, 0, 10); break; // lt
case 3: line(0, 10, 0, 20); break; // lb
case 4: line(16, 0, 16, 10); break; // rt
case 5: line(16, 10, 16, 20); break; // rb
case 6: line(0, 0, 8, 10); break; // dtl
case 7: line(16, 0, 8, 10); break; // dtr
case 8: line(0, 20, 8, 10); break; // dbl
case 9: line(16, 20, 8, 10); break; // dbr
case 10: line(0, 10, 8, 10); break; // ml
case 11: line(8, 10, 16, 10); break; // mr
case 12: line(8, 0, 8, 10); break; // mt
case 13: line(8, 10, 8, 20); break; // mb
}
}
}
}
// was thinking of a hexagonal memory
// structure, addressable in 3
// directions, but got sidetracked
// after a glass of hungarian wine
// handmade font, based on a 14 segment display.
// 201006010628: insomnia made me make
// this really CPU heavy.
int frames;
int[] font = {12044, 13063, 15360, 13059, 15372, 11276, 15620, 3852, 12291,
5888, 3160, 7168, 4032, 3984, 16128, 11788, 16144, 11804,
12676, 8195, 7936, 3168, 3888, 240, 193, 12384, 16224, 832,
13836, 13060, 2828, 14604, 15628, 8257, 16140, 11020, 14607,
255, 15, 12, 96, 4108, 15360, 13056, 80, 160, 4096, 0
};
char[] alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '$', '*', '+', '-', '/', '=', '[', ']',
'(', ')', '_', ' '
};
void draw_cell(int x,int y,float size)
{
int sides=6;
beginShape();
for (int i=1; i<=sides; i++)
{
float a=(i/(float)sides)*2*PI;
vertex(x+size*sin(a),
y+size*cos(a));
}
endShape();
}
void draw_honeycomb(int w, int h, int f)
{
char[] word = {'S','L','U','B','M','E','M','O','R','Y','L','O','S','S'};
fill(0);
strokeWeight(3);
for (int x=0; x<w; x++)
{
for (int y=0; y<h; y++)
{
float px = 50 + x * 57 + (y % 2 ? 0 : 28);
float py = 50 + y * 50;
float size =(sin(x * mouseX * 0.002 + f * 0.05 + y * mouseY * 0.002) + 1.0) * 0.5;
stroke(0);
fill(size * 255);
draw_cell(px,py,size*30);
stroke(128);
pushMatrix();
translate(px - (size * 8),py -(size * 8));
scale(size);
drawLetter(word[int((size + 1.0) * 0.5 * word.length)]);
popMatrix();
}
}
}
void setup()
{
background(255);
size(500,300);
smooth();
frames = 0;
}
int t=0;
void draw()
{
background(255);
drawMessage();
// fill(255);
noStroke();
// rect(0,0,800,300);
fill(0);
draw_honeycomb(7,5,t);
t++;
}
void drawMessage() {
stroke(200);
pushMatrix();
translate(0, 100);
scale(4);
char[] word = {'*', ' ', 'S', 'L', 'U', 'B', ' ', 'L', 'O', 'V', 'E', 'S', ' ', '$', 'Y', 'O', 'U', ' ', '*'};
drawText(word, 125, frames * 3);
++frames;
popMatrix();
}
void drawText(char[] word, int sz, int offset) {
strokeWeight(3);
int chars = (sz / 20) + 1;
pushMatrix();
translate(0 - offset % 20, 0);
for (int i = 0; i < chars; ++i) {
int j = int(offset / 20) + i;
drawLetter(word[j % word.length]);
translate(20, 0);
}
popMatrix();
}
void drawLetter(char letter) {
int l = 0;
for (int n = 0; n < alphabet.length; ++n) {
if (alphabet[n] == letter) {
l = font[n];
}
}
for (int i = 0; i < 14; ++i) {
if((l & int(pow(2, 13-i))) != 0) {
switch(i) {
case 0: line(0, 0, 16, 0); break; // t
case 1: line(0, 20, 16, 20); break; // b
case 2: line(0, 0, 0, 10); break; // lt
case 3: line(0, 10, 0, 20); break; // lb
case 4: line(16, 0, 16, 10); break; // rt
case 5: line(16, 10, 16, 20); break; // rb
case 6: line(0, 0, 8, 10); break; // dtl
case 7: line(16, 0, 8, 10); break; // dtr
case 8: line(0, 20, 8, 10); break; // dbl
case 9: line(16, 20, 8, 10); break; // dbr
case 10: line(0, 10, 8, 10); break; // ml
case 11: line(8, 10, 16, 10); break; // mr
case 12: line(8, 0, 8, 10); break; // mt
case 13: line(8, 10, 8, 20); break; // mb
}
}
}
}