Here you can find the source of drawRTriangle(Graphics g, Color color, int x, int y, int r)
public static void drawRTriangle(Graphics g, Color color, int x, int y, int r)
//package com.java2s; /**//from ww w . j a va2s . com * * Copyright 2008 - 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * @project loon * @author cping * @email?javachenpeng@yahoo.com * @version 0.1 */ import java.awt.Color; import java.awt.Graphics; public class Main { public static void drawRTriangle(Graphics g, Color color, int x, int y, int r) { int x1 = x; int y1 = y + r; int x2 = x - (int) (r * Math.cos(Math.PI / 6.0)); int y2 = y - (int) (r * Math.sin(Math.PI / 6.0)); int x3 = x + (int) (r * Math.cos(Math.PI / 6.0)); int y3 = y - (int) (r * Math.sin(Math.PI / 6.0)); int[] xpos = new int[3]; xpos[0] = x1; xpos[1] = x2; xpos[2] = x3; int[] ypos = new int[3]; ypos[0] = y1; ypos[1] = y2; ypos[2] = y3; g.setColor(color); g.fillPolygon(xpos, ypos, 3); } }