Shanky
Shanky

Reputation: 203

how to define z-index valueof html5 shapes?

i have drawn html5 shapes rectangle, line ans curve using canvas.getContext('2d'). I am confusing that how can i give them z-index?

Upvotes: 1

Views: 458

Answers (1)

Madhu Magar
Madhu Magar

Reputation: 445

In Html5 canvas drawing API, you cannot set the z-index of any shape drawn in canvas. Because canvas is instant drawing mode once you draw you cannot access that drawn shape because canvas in not part of DOM. But fakeing the z-index you can draw shapes in some order that first drawn shape will take the 0 index and so on.

You can use EaselJS a javascript librabry which will provide you the retained display mode and you can set the index of each child and access that child easily.

Upvotes: 2

Related Questions