Letter joint wireframe??
in
Programming Questions
•
1 year ago
Hi,
I just want to know if someone can help me with this....I have this code here:
PFont f;
PFont font;
String[] lines;
String joinedText;
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZÇ1234567890<>'^*`ÄÖÜß,.;:!? ";
int[] counters = new int[alphabet.length()];
boolean[] drawLetters = new boolean[alphabet.length()];
int ledTest = 13;
float soufleX;
float charSize;
color charColor = 0;
int posX = 20;
int posY = 50;
boolean drawGreyLines = false;
boolean drawColoredLines = true;
boolean drawText = true;
String[] poem = {
"L'art web, l'art au bout des doigts",
};
//gets the number of lines
int numLines = poem.length;
//declare a 2D array, one element (x,y) for ach letter
Letter[][] p1 = new Letter[numLines][];
void setup() {
size(1056,706);
f = createFont("Helvetica", 12, true);
textFont(f);
// loop over each line
for (int y = 0; y < p1.length; y++)
{
//loop over the letters in that line
p1[y] = new Letter[poem[y].length()];
for (int x = 0; x < p1[y].length; x++) {
// create a new letter in each spot
p1[y][x] = new Letter();
// set the letter, x and y
p1[y][x].ch = poem[y].charAt(x);
p1[y][x].x = 50 + x*7;
p1[y][x].y = 50 + y*30;
}
}
}
void draw() {
background(255);
// draw each letter
for (int y= 0; y < p1.length; y++) {
for (int x = 0; x < p1[y].length; x++) {
p1[y][x].display();
}
}
//when mouse is released the letters shake randomly
if (!mousePressed) {
for (int y= 0; y < p1.length; y++) {
for (int x = 0; x < p1[y].length; x++) {
p1[y][x].shake();
}
}
}
//when mouse is pressed the letters form a text
else if (mousePressed) {
for (int y= 0; y < p1.length; y++) {
for (int x = 0; x < p1[y].length; x++) {
p1[y][x].home(pmouseX + x*6.6, pmouseY + y*15); // the letters follow the mouse
}
}
}
}
class Letter
{
float x, y;
char ch;
void display() {
fill(0);
textAlign(CENTER);
text(ch, x, y);
}
void shake() {
x += random(-1, 1);
y += random(-1, 1);
}
void home(float homeX, float homeY) {
x = lerp(x, homeX, .02);
y = lerp(y, homeY, .02);
}
}
and I want to know if it's possible to joint the letters together like in this the picture below and I want to know if it's possible to make them moved with the mousemoved and not the mousepressed ?
Thank you!!
I just want to know if someone can help me with this....I have this code here:
PFont f;
PFont font;
String[] lines;
String joinedText;
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZÇ1234567890<>'^*`ÄÖÜß,.;:!? ";
int[] counters = new int[alphabet.length()];
boolean[] drawLetters = new boolean[alphabet.length()];
int ledTest = 13;
float soufleX;
float charSize;
color charColor = 0;
int posX = 20;
int posY = 50;
boolean drawGreyLines = false;
boolean drawColoredLines = true;
boolean drawText = true;
String[] poem = {
"L'art web, l'art au bout des doigts",
};
//gets the number of lines
int numLines = poem.length;
//declare a 2D array, one element (x,y) for ach letter
Letter[][] p1 = new Letter[numLines][];
void setup() {
size(1056,706);
f = createFont("Helvetica", 12, true);
textFont(f);
// loop over each line
for (int y = 0; y < p1.length; y++)
{
//loop over the letters in that line
p1[y] = new Letter[poem[y].length()];
for (int x = 0; x < p1[y].length; x++) {
// create a new letter in each spot
p1[y][x] = new Letter();
// set the letter, x and y
p1[y][x].ch = poem[y].charAt(x);
p1[y][x].x = 50 + x*7;
p1[y][x].y = 50 + y*30;
}
}
}
void draw() {
background(255);
// draw each letter
for (int y= 0; y < p1.length; y++) {
for (int x = 0; x < p1[y].length; x++) {
p1[y][x].display();
}
}
//when mouse is released the letters shake randomly
if (!mousePressed) {
for (int y= 0; y < p1.length; y++) {
for (int x = 0; x < p1[y].length; x++) {
p1[y][x].shake();
}
}
}
//when mouse is pressed the letters form a text
else if (mousePressed) {
for (int y= 0; y < p1.length; y++) {
for (int x = 0; x < p1[y].length; x++) {
p1[y][x].home(pmouseX + x*6.6, pmouseY + y*15); // the letters follow the mouse
}
}
}
}
class Letter
{
float x, y;
char ch;
void display() {
fill(0);
textAlign(CENTER);
text(ch, x, y);
}
void shake() {
x += random(-1, 1);
y += random(-1, 1);
}
void home(float homeX, float homeY) {
x = lerp(x, homeX, .02);
y = lerp(y, homeY, .02);
}
}
and I want to know if it's possible to joint the letters together like in this the picture below and I want to know if it's possible to make them moved with the mousemoved and not the mousepressed ?
Thank you!!
1