gpt4 book ai didi

JavaFX 2.x : How to draw a dashed line effect on a path

转载 作者:太空宇宙 更新时间:2023-11-04 06:26:24 25 4
gpt4 key购买 nike

我正在使用一条路径来绘制一系列贝塞尔曲线。

但是,我需要使填充成为虚线效果,而不是实心填充。

我看过这篇文章:JavaFx 2.x : How to draw dashed or dotted lines? ,但它涉及将形状对象放置到舞台上,而我直接绘制到 GraphicsContext 来创建 jpg 图像。

可以这样做吗?

<小时/>

编辑:这就是我目前的划线方式:

// cv is a Canvas object, previously created and initialised earlier
cv.beginPath();
cv.moveTo(x, y);
cv.cubicTo(x1, y1, x2, y2, x3, y3);

// Either finish with this
cv.closePath();
cv.fill();

// or this
cv.setLineWidth(0.5);
cv.stroke();

最佳答案

根据RT-37999 ,它在 Java 8u40 中实现(固定),可下载以供早期访问。预计 GA 发布日期为 2015 年 3 月。

在那之前,我认为您需要自己实现解决方法,例如 JavaFX Canvas: Drawing dashed lines .

或者,阅读RT-37999的实现代码,如果不太复杂,可以通过扩展相关api类将其集成到您的项目中。

关于JavaFX 2.x : How to draw a dashed line effect on a path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26753018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com