2009-12-16 29 views
5

Tôi đang cố gắng chạy nhiều bản phác thảo trên cùng một trang.Cách có nhiều bản phác thảo processing.js chạy cùng một lúc

Kịch bản init quy định rằng:

/* 
* This code searches for all the <script type="application/processing" target="canvasid"> 
* in your page and loads each script in the target canvas with the proper id. 
* It is useful to smooth the process of adding Processing code in your page and starting 
* the Processing.js engine. 
*/ 

Khi tôi xác định vải mục tiêu của từng nét bút, nó không hoạt động:

<script type="application/processing" target="canvas1">..</script> 
<script type="application/processing" target="canvas2">..</script> 

<canvas id="canvas1".. /> 
<canvas id="canvas2".. /> 

nhưng nó không làm việc? điều này thậm chí có thể? Bất kì sự trợ giúp nào đều được đánh giá cao. Tôi đang cố gắng để có một tài liệu với các yếu tố canvas inline chạy một bản phác thảo đồng bộ với nhau.

Trả lời

6

Got nó làm việc bằng cách thiết lập id cho các thẻ script và vải:

<script type="application/processing" id="script1">..</script> 
<script type="application/processing" id="script2">..</script> 

<canvas id="canvas1" width="200px" height="200px"></canvas> 
<canvas id="canvas2" width="200px" height="200px"></canvas> 
<script> 
    canvas1 = document.getElementById("canvas1"); 
    script1 = document.getElementById("script1").text; 
    canvas2 = document.getElementById("canvas2"); 
    script2 = document.getElementById("script2").text; 
    Processing(canvas1, script1); 
    Processing(canvas2, script2); 
</script> 
0

tôi không thể có được thực hiện ở trên để làm việc, nhưng hoạt động này đối với tôi ...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head> 
     <script src="processing-1.4.1.min.js"></script> 
     <title>title</title> 
    </head> 
    <body> 

     <script type="application/processing" id="script1" src="script1.pde" data-processing-target="pjs1"></script> 
     <canvas id="pjs1"> </canvas> 

     <script type="application/processing" id="script2" src="script2.pde" data-processing-target="pjs2"></script> 
     <canvas id="pjs2"> </canvas> 

    </body> 
    </html> 

Hãy "script1.pde" & "script2.pde" một chương trình xử lý hoạt động và lưu trữ trong cùng thư mục với trang html.

Các vấn đề liên quan