U
U
Uncle Vanya2019-03-20 18:23:55
JavaScript
Uncle Vanya, 2019-03-20 18:23:55

CANVAS canvas is not even in shape?

How to make a canvas canvas (not a circle, not a square, but a smou canvas) of an irregular shape, such as a blot or something like that.
Or you can leave the canvas itself in a square shape, insert a picture there and leave the entire area where there is no picture transparent so that the background of the site can be seen.
The task is as follows:
There is a background of the site, on it a canvas that will be erased, under the erased layer there is some element. The bottom line is that the canvas does not expose the background of the back to itself, but is transparent, and is filled only with an irregularly shaped image. Quarrel that it’s hard to explain, it’s just somehow difficult))
Black is what the canvas puts
5c925d5f05fd7202865883.png
Here is the code where I describe a little this whole thing

const canvas = {};

      canvas.node = document.createElement('canvas');
      canvas.context = canvas.node.getContext('2d');
      canvas.node.width = width;
      canvas.node.height = height;

      parent.appendChild(canvas.node);
  
      // if(!canDrawGrid){
      //   return canvas;
      // }

      const base_image = new Image();
      base_image.src = this.imgPath.canvasMask;



      base_image.onload = () => {
        canvas.context.drawImage(base_image, -43, -24);
      }
      
      return canvas;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2019-03-20
@QSem

e.g.
https://codepen.io/anon/pen/BbqzYe
https://bennettfeely.com/clippy/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question