J'essaie d'utiliser le port de traitement javascript trouvé à http://ejohn.org/blog/processingjs/ Je veux utiliser le constructeur suivant. Processing(CanvasElement, "some massive block of code");
Je sais que javascript ne supporte pas nativement les chaînes multilignes mais est-il possible de passer quelque chose comme ceci sans avoir à concaténer chaque ligne et échapper tous les caractères spéciaux?Chaîne multiligne contenant des caractères spéciaux en javascript?
/**
* Array.
*
* An array is a list of data. Each piece of data in an array
* is identified by an index number representing its position in
* the array. Arrays are zero based, which means that the first
* element in the array is [0], the second element is [1], and so on.
* In this example, an array named "coswav" is created and
* filled with the cosine values. This data is displayed three
* separate ways on the screen.
*/
size(200, 200);
float[] coswave = new float[width];
for (int i = 0; i < width; i++) {
float amount = map(i, 0, width, 0, PI);
coswave[i] = abs(cos(amount));
}
for (int i = 0; i < width; i++) {
stroke(coswave[i]*255);
line(i, 0, i, height/3);
}
for (int i = 0; i < width; i++) {
stroke(coswave[i]*255/4);
line(i, height/3, i, height/3*2);
}
for (int i = 0; i < width; i++) {
stroke(255 - coswave[i]*255);
line(i, height/3*2, i, height);
}
Ceci est une solution rapide et sale à un problème, donc je ne veux pas aller sur la route ajax si je peux l'éviter. Voir cette question. http://stackoverflow.com/questions/460085/best-language-for-quickly-creating-user-interfaces-with-out-drag-and-drop – Jared