Java examples for JavaFX:Shape
JavaFX draw Circle
//package com.java2s; import javafx.geometry.Point2D; import javafx.scene.image.PixelWriter; import javafx.scene.paint.Color; public class Main { /**// w w w .j av a 2s.co m * * @param center * @param r * @param color * @param pw */ public static void drawCircle(Point2D center, int r, Color color, PixelWriter pw) { { int x = 0, y = r; double d = 1.25 - r; circlePoints(center, x, y, color, pw); while (x <= y) { if (d < 0) { d += 2 * x + 3; } else { d += 2 * (x - y) + 5; y--; } x++; circlePoints(center, x, y, color, pw); } } } static void circlePoints(Point2D center, int x, int y, Color color, PixelWriter pw) { pw.setColor(x, y, color); pw.setColor(y, x, color); pw.setColor((int) (center.getX() - x), y, color); pw.setColor(y, (int) (center.getX() - x), color); pw.setColor(x, (int) (center.getY() - y), color); pw.setColor((int) (center.getY() - y), x, color); pw.setColor((int) (center.getX() - x), (int) (center.getY() - y), color); pw.setColor((int) (center.getY() - y), (int) (center.getX() - x), color); } }