如何解决填充颜色的虚线箭头
我使用 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,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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。