跳到主要内容

HTML5 Canvas 椭圆教程

要使用 Konva 创建椭圆,可以实例化一个 Konva.Ellipse() 对象。

有关完整的属性和方法列表,请参阅 Ellipse API 参考

import Konva from 'konva';

const stage = new Konva.Stage({
container: 'container',
width: window.innerWidth,
height: window.innerHeight
});

const layer = new Konva.Layer();
stage.add(layer);

const ellipse = new Konva.Ellipse({
x: stage.width() / 2,
y: stage.height() / 2,
radiusX: 100,
radiusY: 50,
fill: 'yellow',
stroke: 'black',
strokeWidth: 4
});

layer.add(ellipse);