Gradient fill in a canvas
Gradient fill in a canvas
How do you script a gradient fill in canvas ? If i do it like an on line html5 example . The editor crashes yet again .
The addendum needs some scripting examples for each function, similar to the main manual.
The addendum needs some scripting examples for each function, similar to the main manual.
Re: Gradient fill in a canvas
Hi
I don't think you apply it to the canvas itself as such . .
I think you have to create the Gradient and add Colors first . ..
Then you would make an object (rectangle) and Fill or Stroke it with your Gradient ...
Did some quick LED experiments and got it worked out
Will see about what I just described and get back to you . . .
MM
I don't think you apply it to the canvas itself as such . .
I think you have to create the Gradient and add Colors first . ..
Then you would make an object (rectangle) and Fill or Stroke it with your Gradient ...
Did some quick LED experiments and got it worked out
Will see about what I just described and get back to you . . .
MM
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: Gradient fill in a canvas
Hi
Try this as a draw() function - OnRedraw . . .
decl c = getobject();
decl rect = getattribute(c, 'rect');//get Canvas size
canvas_clear(c);//
decl grad = canvas_createLinearGradient(0,rect[3]/2,rect[2],rect[3]/2);//Make Gradient horizontal&middle via Canvas size
canvas_gradient_addColorStop(grad,0,{1,0,0});
canvas_gradient_addColorStop(grad,1,{0,1,0}); Add Color stops
canvas_setFillStyle(c, grad);
canvas_setStrokeStyle(c, 1);
canvas_setLineWidth(c, 1);
canvas_rect(c,0,0, rect[2],rect[3]);//Make Rect Canvas size
canvas_fill(c);
canvas_stroke(c);
Its one way to do it . . . .
Cheers
MM
PS I'm on Mac . . .
Try this as a draw() function - OnRedraw . . .
decl c = getobject();
decl rect = getattribute(c, 'rect');//get Canvas size
canvas_clear(c);//
decl grad = canvas_createLinearGradient(0,rect[3]/2,rect[2],rect[3]/2);//Make Gradient horizontal&middle via Canvas size
canvas_gradient_addColorStop(grad,0,{1,0,0});
canvas_gradient_addColorStop(grad,1,{0,1,0}); Add Color stops
canvas_setFillStyle(c, grad);
canvas_setStrokeStyle(c, 1);
canvas_setLineWidth(c, 1);
canvas_rect(c,0,0, rect[2],rect[3]);//Make Rect Canvas size
canvas_fill(c);
canvas_stroke(c);
Its one way to do it . . . .
Cheers
MM
PS I'm on Mac . . .
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
-
- Liine Staff
- Posts: 285
- Joined: 01 Oct 2010 11:06
Re: Gradient fill in a canvas
Yes, there is a package of tutorial JZMLs for Canvas coming very soon. In the meantime, I've attached the example for using gradients.wul wrote:How do you script a gradient fill in canvas ? If i do it like an on line html5 example . The editor crashes yet again .
The addendum needs some scripting examples for each function, similar to the main manual.
- Attachments
-
- gradient_examples.zip
- (3.08 KiB) Downloaded 94 times
Re: Gradient fill in a canvas
** SNAP ** Perfect timing . . .
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: Gradient fill in a canvas
It was the decl grad line in the code that's causing the editor to crash,
Re: Gradient fill in a canvas
PC issue? Cant recall what you run . ..
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: Gradient fill in a canvas
The tutorials package will be most welcome! Im struggling myself here too! lol
Re: Gradient fill in a canvas
both macciza's example and nicks .jzmlib's crash the editor on windows xp
it appears to be the decl grad line thats the problem, macciza's crashes when compiling/verifying the script . the jzmlibs crash on launch
incidentlty there is a online html5 image to code editor here http://canvimation.github.io/ the code generated needs a bit of converting to suit lemur but it gives a bit of a clue as to the structure
so no authentic looking knobs, panels, or vu meters from me for the time being!
anyone else getting the distorted text issue in the editor ?
it appears to be the decl grad line thats the problem, macciza's crashes when compiling/verifying the script . the jzmlibs crash on launch
incidentlty there is a online html5 image to code editor here http://canvimation.github.io/ the code generated needs a bit of converting to suit lemur but it gives a bit of a clue as to the structure
so no authentic looking knobs, panels, or vu meters from me for the time being!
anyone else getting the distorted text issue in the editor ?
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Gradient fill in a canvas
wul wrote:both macciza's example and nicks .jzmlib's crash the editor on windows xp
it appears to be the decl grad line thats the problem, macciza's crashes when compiling/verifying the script . the jzmlibs crash on launch
incidentlty there is a online html5 image to code editor here http://canvimation.github.io/ the code generated needs a bit of converting to suit lemur but it gives a bit of a clue as to the structure
so no authentic looking knobs, panels, or vu meters from me for the time being!
anyone else getting the distorted text issue in the editor ?
I'm getting the distorted text in Windows as well (Vista on the family PC). I haven't installed 5.0 on my music Mac yet to test it there. Since I've mainly been editing existing .jzml files outside Lemur and simply using the editor for small touchups, I can work with the distorted text. Long-term, obviously that needs to be addressed. Maybe anti-aliasing is turned off for the text editor?