[AS3] 벡터 그래픽의 묘화

Programming/ActionScript 3.0 2007. 6. 15. 16:34
각각의 Shape, Sprite 및 MovieClip 오브젝트는 graphics 프롭퍼티를 갖고 있다. 각 오브젝트의 graphics 프롭퍼티는 Graphics 오브젝트로 Graphics 클래스에는 lines, fills, 셰이프를 묘화 해 조작하기 위한 프롭퍼티와 메소드가 포함된다.

예를 들어, 다음의 코드는 Shape 오브젝트로 오렌지를 묘화 한다.

import flash.display.*;
var circle:Shape = new Shape()
var xPos:Number = 100;
var yPos:Number = 100;
var radius:Number = 50;
circle.graphics.beginFill(0xFF8800);
circle.graphics.drawCircle(xPos, yPos, radius);
this.addChild(circle);
Graphics 클래스에는 단순한 셰이프를 간단하게 묘화하기 위한 다음의 메소드가 포함되어있다.
drawCircle()
drawEllipse()
drawRect()
drawRoundRect()
drawRoundRectComplex()

묘화 메소드를 호출하기 전에
linestyle()
lineGradientStyle()
beginFill()
beginGradientFill()
beginBitmapFill() 메소드를 호출하고  선스타일, fills, 또는 그 양쪽 모두를 정의하게 된다.

( 다른 표시 오브젝트를 포함한다) 표시 오브젝트 컨테이너이기도 하면서 타임 라인을 필요로 하지 않는 그래피컬 오브젝트를 작성하는 경우는 Sprite 클래스를 사용한다.

예를 들어, 다음의 Sprite 오브젝트에는 graphics 프롭퍼티로 묘화 한 circle의 아이 리스트내에 TextField 오브젝트가 있다.

var mySprite:Sprite = new Sprite();
mySprite.graphics.beginFill(0xFFCC00);
mySprite.graphics.drawCircle(30, 30, 30);
var label:TextField = new TextField();
label.text = "hello";
label.x = 20;
label.y = 20;
mySprite.addChild(label);
this.addChild(mySprite);
Sprite 또는 MovieClip 오브젝트의 그래픽 층은  항상 Sprite 또는 MovieClip의 아이 표시 오브젝트의 배후에 표시되지만 그래픽 층은 Sprite 또는 MovieClip의 아이 리스트에는 표시되지 않는다.

    

설정

트랙백

댓글