General
Gradient fill in a canvas
Started by wul on .
Sign in or create an account to join the conversation.
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.
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
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 . . .
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.
gradient_examples.zip
** SNAP ** Perfect timing . . .
It was the decl grad line in the code that's causing the editor to crash,
PC issue? Cant recall what you run . ..
The tutorials package will be most welcome! Im struggling myself here too! lol
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 ?
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?
getting both the crashes of nick's examples and the distorted text in editor - windows 7 32 and 64 bit
The distorted text in th editor doesnt really bother me - the crashing on things I wanted to study though.....arghhhh!
The distorted text in th editor doesnt really bother me - the crashing on things I wanted to study though.....arghhhh!
I opened one of the examples in a text editor and it seems that the line that crashes the editor is this:
canvas_setFillStyle(c, g);
canvas_setFillStyle(c, g);
Hi
Somewhat related as 'g' is the Gradient being defined in the other line . . .
Important to send details to Support including OS / Version etc
Sorry, but no dramas noticed on OSX so far . . .
Been gradually hacking away at HexaPads
Got 4 versions so far with rotated Hex, Diamond and Circle variants . . .
Draft versions of LEDs underway as well
And scouring the net for suitable Canvas tuts and resources
MM
Somewhat related as 'g' is the Gradient being defined in the other line . . .
Important to send details to Support including OS / Version etc
Sorry, but no dramas noticed on OSX so far . . .
Been gradually hacking away at HexaPads
Got 4 versions so far with rotated Hex, Diamond and Circle variants . . .
Draft versions of LEDs underway as well
And scouring the net for suitable Canvas tuts and resources
MM
Crashing here too... Win7 
Done that twice , had no acknowledgement thoughMacciza wrote:
Important to send details to Support including OS / Version
MM
Gradient library items crashing Lemur Editor here also... Windows 7 x64.
Just as well I have spare Macbooks eh?
[Edit]However, thanks for those gradient templates..... I get it now.
Just as well I have spare Macbooks eh?
[Edit]However, thanks for those gradient templates..... I get it now.
Apologies for the Lemur Editor crashes on Windows, we're working on this and will have a fix online as soon as possible.