0

hello

i'm trying to draw a kind of arrow with an specific thickness. i've already this:

public void paintComponent(Graphics g){
			super.paintIcon(comp, g, width, height);
			for(int i=0;i<thickness;i++){
				Polygon arrow=new Polygon();
				arrow.addPoint(7*scale, 0*scale+i);
				arrow.addPoint(14*scale-i, 9*scale-i);
				arrow.addPoint(10*scale-i, 9*scale-i);
				arrow.addPoint(10*scale-i, 29*scale-i);
				arrow.addPoint(4*scale+i, 29*scale-i);
				arrow.addPoint(4*scale+i, 9*scale-i);
				arrow.addPoint(0*scale+i, 9*scale-i);
				g.drawPolygon(arrow);
			}
			g.setColor(Color.BLUE);
			Polygon arrow=new Polygon();
			arrow.addPoint(7*scale, 0*scale+thickness-1);
			arrow.addPoint(14*scale-thickness+1, 9*scale-thickness+1);
			arrow.addPoint(10*scale-thickness+1, 9*scale-thickness+1);
			arrow.addPoint(10*scale-thickness+1, 29*scale-thickness+1);
			arrow.addPoint(4*scale+thickness-1, 29*scale-thickness+1);
			arrow.addPoint(4*scale+thickness-1, 9*scale-thickness+1);
			arrow.addPoint(0*scale+thickness-1, 9*scale-thickness+1);
			g.fillPolygon(arrow);
		}

The problem is that the edge isn't proportional to the original figure.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by hfx642
0

Okay...
Instead of doing the loop, only create 2 polygons and use fillPoly().
Create your second polygon in relation to your first.

Edited by hfx642: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.