Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

konva crop outside width and height of image

var src = 'https://picsum.photos/id/237/200/300';

var stage = new Konva.Stage({
  container: 'container',
  width: 400,
  height: 300,
});

// with help of clipFunc on the layer
var layer = new Konva.Layer({
  clipFunc: function(ctx) {
    ctx.arc(130, 140, 70, 0, Math.PI * 2, false);
  }
});
stage.add(layer);

Konva.Image.fromURL('https://picsum.photos/id/237/200/300', function(theDog) {
  theDog.setAttrs({
    x: 0,
    y: 0,
    scaleX: 1,
    scaleY: 1,
  });
  layer.add(theDog);
  layer.batchDraw();
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #konva #crop #width #height #image
ADD COMMENT
Topic
Name
7+2 =