Good afternoon everyone,
I've been off a bit, so I could not check the forum.
Thanks jbum for Your reply.
Yes those things get closer to what I was looking for, but still...
Since I want to get into it, I decided to try it by myself. I guess it's not the most elegant way, the more as I thought that the tutorial-solution was much more concise / easier.
So here it is: 80 lines for the line-segment-coordinates (these could have been reduced by 50%, i know)
and less than 30 lines for processing them.
Any comment is welcome.
Thanks again to all of You and have a good weekend,
zz
- // I'm still learning...
// Kind regards from Luxembourg
// Zuidberg François francois.zuidberg [_at_] education.lu
// declare a constant array with the line-coordinates of
// each letter of the word 'Processing'
int lines[][] =
{ { 10, 260, 10, 202}, // P
{ 10, 202, 33, 202},
{ 33, 202, 36, 205},
{ 36, 205, 36, 234},
{ 36, 234, 33, 237},
{ 33, 237, 10, 237},
{ 57, 260, 57, 217}, // r
{ 57, 217, 57, 221},
{ 57, 221, 66, 217},
{ 66, 217, 72, 217},
{ 90, 217, 110, 217}, // o
{ 110, 217, 113, 220},
{ 113, 220, 113, 257},
{ 113, 257, 110, 260},
{ 110, 260, 90, 260},
{ 90, 260, 87, 257},
{ 87, 257, 87, 220},
{ 87, 220, 90, 217},
{ 156, 224, 156, 220}, // c
{ 156, 220, 153, 217},
{ 153, 217, 137, 217},
{ 137, 217, 134, 220},
{ 134, 220, 134, 257},
{ 134, 257, 137, 260},
{ 137, 260, 156, 260},
{ 176, 237, 202, 237}, // e
{ 202, 237, 202, 220},
{ 202, 220, 199, 217},
{ 199, 217, 179, 217},
{ 179, 217, 176, 220},
{ 176, 220, 176, 257},
{ 176, 257, 179, 260},
{ 179, 260, 199, 260},
{ 243, 217, 227, 217}, // s
{ 227, 217, 224, 220},
{ 224, 220, 224, 228},
{ 224, 228, 243, 249},
{ 243, 249, 243, 257},
{ 243, 257, 240, 260},
{ 240, 260, 224, 260},
{ 280, 217, 264, 217}, // s
{ 264, 217, 261, 220},
{ 261, 220, 261, 228},
{ 261, 228, 280, 249},
{ 280, 249, 280, 257},
{ 280, 257, 277, 260},
{ 277, 260, 261, 260},
{ 300, 217, 300, 260}, // i
{ 300, 200, 300, 200},
{ 319, 217, 319, 260}, // n
{ 319, 220, 322, 217},
{ 322, 217, 342, 217},
{ 342, 217, 345, 220},
{ 345, 220, 345, 260},
{ 369, 248, 366, 245}, // g
{ 366, 245, 366, 220},
{ 366, 220, 369, 217},
{ 369, 217, 389, 217},
{ 389, 217, 392, 220},
{ 392, 220, 392, 245},
{ 392, 245, 389, 248},
{ 389, 248, 369, 248},
{ 369, 248, 366, 251},
{ 366, 251, 366, 257},
{ 366, 257, 369, 260},
{ 369, 260, 389, 260},
{ 389, 260, 392, 263},
{ 392, 263, 392, 271},
{ 392, 271, 389, 274},
{ 389, 274, 369, 274} };
void setup()
{
// initialize graphics screen
size(400,300);
}
void draw()
{
// distances between the mouse and the edges of a line
int dA, dB;
// altered point coordinates, used to actually draw a line
int xA, yA, xB, yB;
// white background
background(255);
// draw all the lines in the array
for (int i = 0; i < 70; i ++ )
{
// calculate the distance between the mouse and
// the edges of the line, add 1 to be sure it is non zero!
dA = int(sqrt(sq(mouseX-lines[i][0])+sq(mouseY-lines[i][1]))) + 1;
dB = int(sqrt(sq(mouseX-lines[i][2])+sq(mouseY-lines[i][3]))) + 1;
// the smaller the distance, the more the line will tremble,
// so compute a scaled inverse proportionality
dA = 250/dA;
dB = 250/dB;
// calculate the actual coordinates which are
// random within the calculated amplitudes
xA = int(random(lines[i][0]-dA,lines[i][0]+dA+1));
yA = int(random(lines[i][1]-dA,lines[i][1]+dA+1));
xB = int(random(lines[i][2]-dB,lines[i][2]+dB+1));
yB = int(random(lines[i][3]-dB,lines[i][3]+dB+1));
// finally draw the line
line(xA, yA, xB, yB);
}
}