The code below leads to the creation of a JavaFX Canvas that can be drawn with the mouse pointer, but skips some points, i.e. Leaves spaces if someone tries to draw a continuous line. The clearance increases with increasing pointer speed.
What causes this behavior and what can be done to achieve a well-connected line? (NB, I'm looking for an answer that explicitly switches every pixel that the pointer passes to black, and not operations such as smoothing or connecting dots, etc.)
public class DrawingSample extends Application {
public void start(Stage stage) {
FlowPane flowPane = new FlowPane();
Canvas canvas = new Canvas(300, 300);
flowPane.getChildren().add(canvas);
GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
graphicsContext.setFill(Color.WHITE);
graphicsContext.fillRect(0, 0, 300, 300);
canvas.setOnMouseDragged((event) -> {
graphicsContext.setFill(Color.BLACK);
graphicsContext.fillRect(event.getX(), event.getY(), 1, 1);
});
stage.setScene(new Scene(flowPane));
stage.show();
}
public static void main(String[] args) {
launch(DrawingSample.class);
}
}
The following figure shows three lines drawn from left to right with increasing speeds when moving down.

basse