跳到主要内容

点是可以渲染在位置 (x, y) 处的点。它们是最简单的显示元素,可以使用不同的颜色和大小进行样式设置。

import { InteractivePoint } from '@wangyaoshen/locus-interaction';

const point = new InteractivePoint({
position: [250, 150],
color: '#E91E63',
radius: 8,
});

多个点

在不同位置渲染多个点:

const points = [
{ position: [100, 100], color: '#E91E63' },
{ position: [200, 150], color: '#2196F3' },
{ position: [300, 100], color: '#4CAF50' },
].map(config => new InteractivePoint({
...config,
radius: 8,
}));

样式

点可以使用各种视觉属性进行自定义:

const styledPoint = new InteractivePoint({
position: [250, 150],
color: '#9C27B0',
radius: 12,
strokeColor: '#7B1FA2',
strokeWidth: 2,
opacity: 0.8,
});

属性

名称类型默认值描述
positionVector2[0, 0]点位置 [x, y]
colorstring'#E91E63'填充颜色
radiusnumber8点半径
strokeColorstring-描边颜色
strokeWidthnumber0描边宽度
opacitynumber1不透明度 (0-1)