开发者

Dividing PNG into layers (HTML5, JS)

开发者 https://www.devze.com 2023-03-14 11:58 出处:网络
I\'m working for a small non commercial project, what I\'m stuck on right now is that the script picks up a png image, however when I exported it, there are two layers, how do I divide this image into

I'm working for a small non commercial project, what I'm stuck on right now is that the script picks up a png image, however when I exported it, there are two layers, how do I divide this image into two different layers and manipulate one once its loaded up into convas?

<html>
<head>
    <title>test</title>
    <script type="text/javascript">
        function startup() {
            var canvas = document.getElementById('canvas');
            var ctx = canvas.getContext('2d');
            var img = new Image();
            img.src = 'brushes.开发者_如何学Cpng';
            img.onload = function() {
                ctx.translate(32, 120);
                ctx.rotate(40 * Math.PI/180);
                ctx.drawImage(img, -32, -120, 64, 120);
            }
        }
    </script>
</head>
<body onload='startup();'>
    <canvas id="canvas" style="position: absolute; left: 300px; top: 300px;" width="800" height="800"></canvas>
</body>


As far as I know PNG does not have any layers, so you would need to save one image for each layer to manipulate them separately.

0

精彩评论

暂无评论...
验证码 换一张
取 消