From: Christopher De Cairos Date: Fri, 3 Jun 2011 20:25:30 +0000 (-0400) Subject: MAJOR refactoring. way better now. ;) needs work still I think. X-Git-Tag: v0.7^2~31^2~16 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=7d828eff245f1fa305997823b6dd56a4e99a909e;p=popcorn-js.git MAJOR refactoring. way better now. ;) needs work still I think. --- diff --git a/plugins/processing/popcorn.processing.html b/plugins/processing/popcorn.processing.html index 98b0f2f..b8a4d22 100644 --- a/plugins/processing/popcorn.processing.html +++ b/plugins/processing/popcorn.processing.html @@ -15,35 +15,35 @@ end: 5, // seconds control: 'pause', target: 'processing-div', - sketch: 'var w = 100; var h = 100; float r = 0.0; void setup() { size(width, height); frameRate(8);}\nvoid draw(){ background(#000000); translate(width/2, height/2); for(int i = 0; i
-

This is within a DIV and was created by sending a string in "sketch:

-

> pause at 1 and resume at 5 seconds.

-

This is within a DIV and was created by sending a file in the sketch function

-

> pause at 5 and resume at 10 seconds. Then Pause again at 20 to 25 seconds to test multiple instructions

+
-

This is within a Canvas and was created by it having it's own sketch file

-

> pause at 10 and resume at 15 seconds.

- - -
- Call Function Test + + +
-

This is within a DIV and was created by sending a file in the sketch function

-

> change square to blue at 20 seconds.

- \ No newline at end of file + diff --git a/plugins/processing/popcorn.processing.js b/plugins/processing/popcorn.processing.js index d6da226..89f7c15 100644 --- a/plugins/processing/popcorn.processing.js +++ b/plugins/processing/popcorn.processing.js @@ -4,326 +4,110 @@ */ (function (Popcorn) { -/** -* ajax -* Author: Processing.js Community & Benjamin Chalovich (ben1amin) -* Date: 30/03/2011 -* Parameters: -* url : the url you want to fetch string data from -* returns: void -*/ -var ajax = function ajax(url) { - try{ - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, false); - xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); - xhr.send(null); - // failed request? - if (xhr.status !== 200 && xhr.status !== 0) { return false; } // Changed for the processing plug-in - return xhr.responseText; - }catch(err){ - return false; - } -}; - /** -* checkIfProcessingExists -* Author: Benjamin Chalovich (ben1amin) -* Date: 30/03/2011 -* Parameters: -* id : The id you wish to check to see if it is already initialized -* returns: true - A processing sketch is already running with that ID -* false - That sketch is not already running -*/ -var checkIfProcessingExists = function(id){ - //checks to see if the sketch has already been created - return(typeof(Processing.instanceIds[id])!='undefined'); -} - /** - * Authors note: This should be added to the Processing library -* addProcessingInstance: adds a processing instance to the DOM based on a given ID (starts it) -* Author: Processing.js Community & Benjamin Chalovich (ben1amin) -* Date: 30/03/2011 -* Parameters: -* canvasID : the id of the canvas (that has a processing data source defined) that you wish to be initialized -* returns: void -*/ - var addProcessingInstance = function(canvasID) { - // Ensures that you do not instantiate more than one processing instance at a time by seeing if it already exists - if(!checkIfProcessingExists(canvasID)){ - var canvas = document.getElementById(canvasID); - // datasrc and data-src are deprecated. - var processingSource = canvas.getAttribute('data-processing-sources'); - if (processingSource === null) { - // Temporary fallback for datasrc and data-src - processingSource = canvas.getAttribute('data-src'); - if (processingSource === null) { - processingSource = canvas.getAttribute('datasrc'); - } - } - if (processingSource) { - var filenames = processingSource.split(' '); - var code = ""; - for (var j = 0, fl = filenames.length; j < fl; j++) { - if (filenames[j]) { - var block = ajax(filenames[j]); - if (block !== false) { - code += ";\n" + block; - } - } - } - if(code!=""){ - Processing.addInstance(new Processing(canvas, code)); - }else{ - Processing.addInstance(new Processing(canvas, processingSource)); - } - } - }else{ - // purposefully void - A processing instance with the given id already exists - } -}; - /** - * Authors note: This should be added to the Popcorn library -* loadScript: adds a script to the DOM via. adding a + + + + + + +

+

Popcorn processing Plug-in Demo

+

+
+

+
    +
    +
    + +
    + + diff --git a/plugins/processing/popcorn.processing.unit.js b/plugins/processing/popcorn.processing.unit.js index e69de29..5e5182f 100644 --- a/plugins/processing/popcorn.processing.unit.js +++ b/plugins/processing/popcorn.processing.unit.js @@ -0,0 +1 @@ +//TODO: Write tests .. >.< diff --git a/plugins/processing/test.pjs b/plugins/processing/test.pjs index 7212b0c..589068f 100644 --- a/plugins/processing/test.pjs +++ b/plugins/processing/test.pjs @@ -35,4 +35,4 @@ void switch_status(){ }else{ colour = "white"; } -} \ No newline at end of file +} diff --git a/plugins/processing/test2.pjs b/plugins/processing/test2.pjs index 08587fa..4141d56 100644 --- a/plugins/processing/test2.pjs +++ b/plugins/processing/test2.pjs @@ -8,6 +8,7 @@ void setup() { // Frame rate frameRate(8); + noLoop(); } void draw() {