Created
May 24, 2011 17:11
-
-
Save agiletalk/989147 to your computer and use it in GitHub Desktop.
[예제] Path 객체 그리기
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onDraw(Canvas canvas) { | |
Path path = new Path(); | |
canvas.drawColor(Color.WHITE); | |
Paint Pnt = new Paint(); | |
Pnt.setStrokeWidth(5); | |
Pnt.setColor(Color.RED); | |
Pnt.setStyle(Paint.Style.STROKE); | |
// 원, 사각형을 패스로 정의한 후 출력 | |
path.addRect(100, 00, 150, 90, Path.Direction.CW); | |
path.addCircle(50, 50, 40, Path.Direction.CW); | |
canvas.drawPath(path, Pnt); | |
// 직선 곡선을 패스로 정의한 후 출력 | |
path.reset(); | |
path.moveTo(10, 110); | |
path.lineTo(50, 150); | |
path.rLineTo(50, -30); | |
path.quadTo(120, 170, 200, 110); | |
Pnt.setStrokeWidth(3); | |
Pnt.setColor(Color.BLUE); | |
canvas.drawPath(path, Pnt); | |
// 곡선 패스 출력 | |
path.reset(); | |
path.moveTo(10, 220); | |
path.cubicTo(80, 150, 150, 220, 220, 180); | |
Pnt.setStrokeWidth(2); | |
Pnt.setColor(Color.BLACK); | |
canvas.drawPath(path, Pnt); | |
// 곡선 패스 위에 텍스트 출력 | |
Pnt.setTextSize(20); | |
Pnt.setStyle(Paint.Style.FILL); | |
Pnt.setAntiAlias(true); | |
canvas.drawTextOnPath("Curved Text on Path.", path, 0, 0, Pnt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment