Code example for Path

Methods: addOvaladdRectlineTomoveTosetFillType

0
		super.dispatchDraw(canvas);
	} 
	 
	public static Path createArrow(Point left, Point right, int width, int line_width, int direction)
	{ 
		Path path = new Path();
		if (direction == DIRECTION_LEFT){
			Point tmp = right;
			right = left;
			left = tmp;
		}else{ 
			 
		} 
		float radius = (float) (width * 0.45);
		double angle = Math.atan2(right.y - left.y, right.x - left.x);
		path.setFillType(Path.FillType.WINDING);
		RectF oval = new RectF(left.x-radius, left.y - radius, left.x + radius, left.y + radius);
		path.addOval(oval, Path.Direction.CCW);
		if (direction == DIRECTION_LEFT){
			RectF line = new RectF(left.x, left.y - line_width, right.x+width/2, right.y + line_width);
			path.addRect(line, Path.Direction.CW);
		}else{ 
			RectF line = new RectF(left.x, left.y - line_width, right.x-width/2, right.y + line_width);
			path.addRect(line, Path.Direction.CCW);
		} 
			 
		path.moveTo(left.x, left.y);
		path.moveTo(right.x, right.y);
		path.lineTo(right.x - width * (float) Math.cos(angle - Math.PI / 6) ,right.y - width * (float) Math.sin(angle - Math.PI / 6) );
		path.moveTo(right.x, right.y);
		path.lineTo(right.x - width * (float) Math.cos(angle + Math.PI / 6) ,right.y - width * (float) Math.sin(angle + Math.PI / 6) );
		path.lineTo(right.x - width * (float) Math.cos(angle - Math.PI / 6) ,right.y - width * (float) Math.sin(angle - Math.PI / 6) );
		 
		return path;
		 
	}