Skip to content

Commit

Permalink
Two changes from Felipe Gomes:
Browse files Browse the repository at this point in the history
 - If you're using the Processing JavaScript API you must now explicitly call .init() to start the rendering. Previously it wasn't possible to gain advantage from the
setup/draw functions (since they would never exist in time).
 - Made p.set() allow for the consumption of PImages, in addition to colors (effectively the same as doing p.image(img, x, y)).
  • Loading branch information
John Resig committed May 12, 2008
1 parent 33c4d44 commit 2f20f5a
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@

this.Processing = function Processing( aElement, aCode )
{
if ( typeof aElement == "string" )
aElement = document.getElementById( aElement );

var p = buildProcessing( aElement );
p.init( aCode );

if ( aCode )
p.init( aCode );

return p;
};

Expand Down Expand Up @@ -1353,12 +1359,20 @@ function buildProcessing( curElement ){
return getLoaded.get( x, y );
}

p.set = function set( x, y, color )
p.set = function set( x, y, obj )
{
var oldFill = curContext.fillStyle;
curContext.fillStyle = color;
curContext.fillRect( Math.round( x ), Math.round( y ), 1, 1 );
curContext.fillStyle = oldFill;
if ( obj && obj.img )
{
p.image( obj, x, y );
}
else
{
var oldFill = curContext.fillStyle;
var color = obj;
curContext.fillStyle = color;
curContext.fillRect( Math.round( x ), Math.round( y ), 1, 1 );
curContext.fillStyle = oldFill;
}
}

p.arc = function arc( x, y, width, height, start, stop )
Expand Down

0 comments on commit 2f20f5a

Please sign in to comment.