public
Description: A port of the Processing visualization language to JavaScript.
Home | Edit | New

size() bug

There seems to be a bug in the size() method of processing.js. It resets the line width when it is called (or more accurately, doesn’t preserve it like it does for the fill and stroke colors).

This can be seen by taking the basic example from the front page, starting it, and then changing the size dynamically – the circle border becomes much thinner.



FIX: Add two lines to the size method, preserving the lineWidth of the current context:
p.size = function size( aWidth, aHeight ) {
    var fillStyle = curContext.fillStyle;
    var strokeStyle = curContext.strokeStyle;
    var lineWidth = curContext.lineWidth;
curElement.width = p.width = aWidth; curElement.height = p.height = aHeight;
curContext.fillStyle = fillStyle; curContext.strokeStyle = strokeStyle; curContext.lineWidth = lineWidth; };

Last edited by edorfaus, Thu Aug 06 09:11:01 -0700 2009
Home | Edit | New
Versions: