我想使用在http://ejohn.org/blog/processingjs/發現處理的JavaScript端口我想使用下面的構造函數。 Processing(CanvasElement, "some massive block of code");
我知道javascript本身並不支持多行字符串,但有沒有辦法傳遞下面的內容,而不必連接每一行並轉義每個特殊字符?在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);
}
這是一個快速和骯髒的問題解決方案,所以如果我可以避免的話,不想去ajax路線。看到這個問題。 http://stackoverflow.com/questions/460085/best-language-for-quickly-creating-user-interfaces-with-out-drag-and-drop – Jared 2009-01-20 12:20:21