Here you can find the source of checkRadius(final BufferedImage src, final int x, final int y, final int opaqueLimit, final int radius)
private static boolean checkRadius(final BufferedImage src, final int x, final int y, final int opaqueLimit, final int radius)
//package com.java2s; /*/*w w w . j av a2 s. co m*/ * Copyright (C) 2012 Markus Niedermann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.awt.image.BufferedImage; public class Main { private static boolean checkRadius(final BufferedImage src, final int x, final int y, final int opaqueLimit, final int radius) { int minX = Math.max(x - radius, 0); int maxX = Math.min(src.getWidth(), x + radius); int minY = Math.max(y - radius, 0); int maxY = Math.min(src.getHeight(), y + radius); for (int curY = minY; curY < maxY; curY++) { for (int curX = minX; curX < maxX; curX++) { if (getDistance(curX, curY, x, y, radius) <= 1 && ((src.getRGB(curX, curY) >> 24) & 0xff) <= opaqueLimit) { return false; } } } return true; } private static double getDistance(final int curX, final int curY, final int x, final int y, final int radius) { return Math.sqrt((curX - x) * (curX - x) + (curY - y) * (curY - y)) / radius; } }