help wanted
Repository-Metriken
- Stars
- (6.431 Sterne)
- PR-Merge-Metriken
- (Keine gemergten PRs in 30 T)
Beschreibung
There is currently not an easy way to set a stroke to be a dashed line.
JavaFX has built in support for rendering strokes as dashed lines in the GraphicsContext class which is used by the FX2D rendered: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/canvas/GraphicsContext.html#setLineDashes-double...-
Here is a quick proof of concept code I added to PGraphicsFX2D.java to add APIs to enabled dashed lines:
public void strokeDash(double width, double offset) {
double[] dashes = { width };
context.setLineDashOffset(offset);
context.setLineDashes(dashes);
}
public void noDash() {
context.setLineDashOffset(0.0);
context.setLineDashes(null);
}
It is also possible to add to the default renderer (here is some processing 2 code i wrote to add dashed lines):
import java.awt.BasicStroke;
import java.awt.Graphics2D;
void strokeDash(float width) {
BasicStroke pen;
float[] dashes = { 2.0f};
pen = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 4.0f, dashes, 0.0f);
Graphics2D g2 = ((PGraphicsJava2D) g).g2;
g2.setStroke(pen);
}
Is this an API that the team would consider adding to processing?