caleb531 / jcanvas

A jQuery plugin that makes the HTML5 canvas easy to work with.
https://projects.calebevans.me/jcanvas/
MIT License
626 stars 192 forks source link

about img index Top #338

Closed LinCaster closed 6 years ago

LinCaster commented 6 years ago

I need to put IMG on the top and cover other contents.
But every time a new img is added, he will be covered by the new img. The new img will continue to increase and he needs to run at the earliest. At the same time, at the top

Thank you for your help.

    canvas
.addLayer({
    layer: true,
    type:'image',
    name:'men_left_1',
    source:'img/image/men_left_1.png',
    x:a,
    y:0,
    index:42,
    width:375*body,
    height:633*body,
    fromCenter:false,
}).drawLayers();

this.click(function(){ canvas.addLayer({ layer: true, type:'image', name:'shou_12', groups: ['dh_4'], source:'img/image/shou_12.png', x:win1.14, y:win0.525, index:20, width:91body, height:70body, fromCenter:false, }).drawLayers(); })

nallias commented 6 years ago

can you reproduce the problem with the sandbox https://projects.calebevans.me/jcanvas/sandbox/ ?

LinCaster commented 6 years ago

@nallias @caleb531 image I want to be at without changing the rendering order. Black covered in red

wschleter commented 6 years ago

I believe you need to use layers to do this (add layer=true), and the index is not an arbitrary value, it is the index into the layers array. Had to use drawLayers to get it to take affect. Also see moveLayers

$('canvas').drawArc({ fillStyle: '#000', x: 100, y: 100, radius: 50, layer: true, });

var abc = $('canvas').drawArc({ fillStyle: '#f00', x: 150, y: 150, radius: 50, layer: true, index: 0 // index 0 is the bottommost layer }) $('canvas').drawLayers();

From: LinCaster Sent: Thursday, October 11, 2018 7:59 AM To: caleb531/jcanvas Cc: Subscribed Subject: Re: [caleb531/jcanvas] about img index Top (#338)

@nallias @caleb531

I want to be at without changing the rendering order. Black covered in red — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

LinCaster commented 6 years ago

@wschleter Thank My problem has been solved

caleb531 commented 6 years ago

Thanks, @nallias and @wschleter, for helping to resolve this issue before I've even had a chance to look at it. The help is very much appreciated. :)