虚线箭头填充颜色
Dashed Arrow Head Filled With Color
我使用 konvajs 使用虚线创建 Konva.Arrow 形状。但是,箭头未填充颜色。如何让箭头有颜色?
这是我用来制作箭头的代码的基础。
lineConfig['dash'] = [12, 8];
lineConfig['points'] = [pos.x, pos.y];
arrowLine = new Konva.Arrow(lineConfig);
也尝试将 fill
属性 添加到您的箭头中,例如 fill: 'black'
。我试着在没有那个的情况下画一个箭头 属性,结果和你描述的一样。
这是工作示例:
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/konva@7.2.5/konva.min.js"></script>
<meta charset="utf-8" />
<title>Konva Arrow Demo</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
var width = window.innerWidth;
var height = window.innerHeight;
var stage = new Konva.Stage({
container: "container",
width: width,
height: height
});
var layer = new Konva.Layer();
var arrow = new Konva.Arrow({
x: stage.width() / 4,
y: stage.height() / 4,
points: [0, 0, 10, 100],
pointerLength: 20,
dash: [12, 8],
pointerWidth: 20,
// Comment the following line to get your issue
fill: "black",
stroke: "black",
strokeWidth: 4
});
// add the shape to the layer
layer.add(arrow);
// add the layer to the stage
stage.add(layer);
</script>
</body>
</html>
我使用 konvajs 使用虚线创建 Konva.Arrow 形状。但是,箭头未填充颜色。如何让箭头有颜色?
这是我用来制作箭头的代码的基础。
lineConfig['dash'] = [12, 8];
lineConfig['points'] = [pos.x, pos.y];
arrowLine = new Konva.Arrow(lineConfig);
也尝试将 fill
属性 添加到您的箭头中,例如 fill: 'black'
。我试着在没有那个的情况下画一个箭头 属性,结果和你描述的一样。
这是工作示例:
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/konva@7.2.5/konva.min.js"></script>
<meta charset="utf-8" />
<title>Konva Arrow Demo</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
var width = window.innerWidth;
var height = window.innerHeight;
var stage = new Konva.Stage({
container: "container",
width: width,
height: height
});
var layer = new Konva.Layer();
var arrow = new Konva.Arrow({
x: stage.width() / 4,
y: stage.height() / 4,
points: [0, 0, 10, 100],
pointerLength: 20,
dash: [12, 8],
pointerWidth: 20,
// Comment the following line to get your issue
fill: "black",
stroke: "black",
strokeWidth: 4
});
// add the shape to the layer
layer.add(arrow);
// add the layer to the stage
stage.add(layer);
</script>
</body>
</html>