mgraphics set_line_width madness

    Aug 05 2016 | 3:21 am
    For some reason, set_line_width isn't working in jsui/mgraphics. I'm updating the line width based on the mouse position. If I post the value (or call get_line_width) to the Max window, I see values I would expect to see (example :jsui: 21.70 22.35 23.15 23.50 23.70 23.80 24.20 ), but all I get are lines 1 pixel thick (see attached image for demo).
    The code is below. Any help would be appreciated. Javascript is still a foreign beast to me.
    autowatch =1;
    var width = 550;
    var height = 550;
    var mouseX = 0;
    var mouseY = 0;
    mgraphics.relative_coords = 0;
    function paint(){
    	mgraphics.set_source_rgba(1, 1, 1, 1);
    	var circleRes = 2+ (80 - 2)*((mouseY -0)/ (height-0));
    	var rad = mouseX-width/2 + .5;
    	var angle = (Math.PI*2)/circleRes;
    	var wide = mouseY/20;
    	mgraphics.translate(width/2, height/2);
    	mgraphics.set_source_rgb(0,0, 0,0);	
    	for(var i=0;i

    • Aug 05 2016 | 1:34 pm
      Solved my own issue. I needed to add
      		mgraphics.stroke_preserve( );
      in the for loop that drew the lines.
    • Jul 13 2021 | 6:03 pm
      Hi all, puzzling over a similar problem. I'm trying to make a simple mouse drawing tool with mgraphics but when I change set_line_width I get these furry caterpillar lines. I love them but I was hoping for a smoother option. Here's my simple setup, adapted from the help file.
      I don't really know javascript, I'd also be curious to know if it would be necessary here. I've seen it used in the jsui context but I'm trying to assess if that rabbit hole is necessary here.
      Thanks for any advice
    • Jul 16 2021 | 3:58 pm
      This looks like an artifact that results from drawing very short lines