How to draw an 1 pixel line using Javafx Canvas?

后端 未结 2 576
时光说笑
时光说笑 2021-02-14 10:09

I\'ve been googling and searching, found some some related questions/posts but none of the address my problem.

I am drawing lines directly on canvas (JavaFX) using:

2条回答
  •  既然无缘
    2021-02-14 10:40

    Use coordinates in this notation x.5.

    Look my example:

        gc.setFill(Color.BLACK);
        gc.setLineWidth(1.0);
    
        gc.strokeRect(50, 100, 25.0, 25.0);
        gc.strokeRect(100.5, 100.5, 25.0, 25.0);
    

    You will get two squares, the second sharp.

    Reference: https://dlsc.com/2014/04/10/javafx-tip-2-sharp-drawing-with-canvas-api/

提交回复
热议问题