JSUI / MGraphics : instance to image - alpha channel bug ?


    Mar 16 2014 | 7:29 pm
    Hello !
    im trying to draw separate "mgraphics" context  into the Image , to reuse later within main context . Everything is working fine unless my drawings use alpha  .
    when alpha is provided im getting differences within colors .
    mgraphics.init();
    mgraphics.relative_coords = 0;
    mgraphics.autofill = 0;
    autowatch = 1;
    
    var image ;
    
    function offline(){
    	var mg = new MGraphics(100,100);
    
    	with(mg){
    		set_source_rgba(0, 1, 0, .5);
    		rectangle(0, 0, 100, 100);
    		fill();		
    	}
    
    	image = new Image(mg);
    
    };
    
    function paint(){
    
    	with(mgraphics){
    		save();
    
    		set_source_rgba(0, 1, 0, .5);
    		rectangle(0, 0, 100, 100);	
    		fill();	
    
    		restore();
    
    		translate(100, 0);
    		// set_source_rgba(0, 0, 0, 1); 
    		image_surface_draw(image);		
    	}
    };
    
    offline();
    mgraphics.redraw();
    

    • Mar 19 2014 | 8:44 pm
      I can confirm a bit of an issue here with the alpha calculation. Looks like its been this way since the beginning. We will take a closer look, thanks!
      -Ben
    • Mar 19 2014 | 9:36 pm
      thank you Ben