开发者

Draw bottom rounded corner

开发者 https://www.devze.com 2023-02-12 01:10 出处:网络
How can i draw a shape, that is only rounded at it\'s bottom, without using flex libraries? var开发者_如何学运维 _myShape:Shape = new Shape();

How can i draw a shape, that is only rounded at it's bottom, without using flex libraries?

Draw bottom rounded corner

  var开发者_如何学运维 _myShape:Shape = new Shape();
      _myShape.graphics.lineStyle(4,0x000000,1,true,....);
      _myShape.graphics.drawRoundRect(0,0,50,50,10);


if you don't want to use Flex libraries (as you've commented on Glenn's answer) and if you're only concerned will fills, you could employ a masking technique on your sprites.

var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xFF0000, 1.0);
sprite.graphics.drawRoundRect(0, 0, 300, 200, 100, 100);
sprite.graphics.endFill();

var spriteMask:Shape = new Shape();
spriteMask.graphics.beginFill(0);
spriteMask.graphics.drawRect(0, sprite.height / 2, sprite.width, sprite.height / 2);
spriteMask.graphics.endFill();

sprite.mask = spriteMask;
sprite.addChild(spriteMask);

addChild(sprite);

including strokes is a little trickier, but still possible.


See this page: Why is drawRoundRectComplex() not documented in ActionScript?

You need "drawRoundRectComplex"

EDIT: If you can't the Flex SDK, your only other "real" drawing option is to use a combination of lineTo and curveTo. The easiest way to do this is to copy the code from the GraphicsUtil class in the Flex SDK. I'm not clear if it's considered open-source or not, so I'm not going to post it here.


You can emulate a stroke by using a GlowFilter, although it will be more expensive than a true stroke.

You also don't need a mask -- just draw two boxes.

var s:Sprite = new Sprite;
addChild(s);

s.graphics.beginFill(0xff0000);
s.graphics.drawRoundRect(0,0,50,50,10);
s.graphics.endFill();

s.graphics.beginFill(0xff0000);
s.graphics.drawRect(0,0,50,20);
s.graphics.endFill();

s.filters = [new GlowFilter(0x0, 4, 8,8, 40)];
0

精彩评论

暂无评论...
验证码 换一张
取 消