[javascript-dev] jsui mysketch
Joshua Kit Clayton
jkc at musork.com
Thu Dec 20 13:13:15 MST 2007
- Previous message: [javascript-dev] jsui mysketch
- Next message: [javascript-dev] jsui mysketch
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Dec 20, 2007, at 6:27 AM, klaus filip wrote:
> hi
> i am trying to build a multi-2D slider as jsui and hanging at the
> very basics.
> since i don't want to redraw all sliders i want to use multiple
> sketches (like sprites).
> below is my basic misunderstanding, the function dsketch works,
> but the function dsketch2 is doing nothing...
Other sketch instances are not visible. They must be drawn into the
main sketch to see. This is demonstrated in the jsui_imagestuff-
example.pat, in the sketchpix() js function, which I've included
below. You can also copy sketch instances pixels to an image for use
with the other image drawing functions. Hope this gets you on the
right track.
-Joshua
// the sketchpix function demonstrates rendering into another
instance of sketch
// and then copying to the main Sketch object, this.sketch. this can
be useful
// to make sprites, or generating geometry based alpha masks, etc.
function sketchpix(x,y)
{
// create a new instance of sketch
var rendersketch = new Sketch(64,64);
// draw some things in new sketch instance
with (rendersketch) {
default2d();
glcolor(0,1,0,1);
moveto(0,0);
circle(0.7);
glcolor(1,0,0,1);
roundedplane(0.1,0.3);
}
// copy to main sketch instance
with (sketch) {
glclearcolor(0,0,1,1);
glclear();
if (myblend)
glenable("blend");
else
gldisable("blend");
copypixels(rendersketch,x,y);
}
refresh();
}
- Previous message: [javascript-dev] jsui mysketch
- Next message: [javascript-dev] jsui mysketch
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
