简体   繁体   English

在Flex / Actionscript中绘制形状

[英]Drawing shapes in Flex / Actionscript

I want to develop an image editing application in Flex 4. My initial requirement is to draw various shapes like Line, Rectablge, Triangle, Circle, Star etc in appication. 我想在Flex 4中开发一个图像编辑应用程序。我的最初要求是在应用程序中绘制各种形状,例如直线,矩形,三角形,圆形,星形等。 I want to facilitate user to draw shapes using rubber banding like professional applications do. 我想像专业应用程序一样方便用户使用橡皮筋绘制形状。

All shapes would be vector and should look smooth in an size. 所有形状都是矢量,并且在大小上应该看起来很平滑。 So, can't use bitmap and scale them. 因此,不能使用位图缩放它们。

What are better methods to achieve this? 有什么更好的方法可以做到这一点?

if you don't want to start from scratch with the basic shapes, there is this framework called degrafa: http://www.degrafa.org/ 如果您不想从基本的形状重新开始,可以使用以下称为degrafa的框架: http : //www.degrafa.org/

they have plenty of parametric shapes & curves and advanced features to organize them together. 它们具有大量的参数形状和曲线以及先进的功能,可以将它们组织在一起。

Make shape editor with some control points. 使用一些控制点制作形状编辑器。 Control points are draggable sprites (circles or squares as you like). 控制点是可拖动的精灵(您喜欢的圆形或正方形)。 When control point is moved, editor must be updated - it may be resize or move action. 移动控制点时,必须更新编辑器-可以调整大小或移动动作。 On resize, draw your vector shape according to new size. 调整大小时,根据新大小绘制矢量形状。 The easiest way to make sprite draggable is startDrag() function - you can also set limits there (to stay in editor area or to disable negative sizes). 使Sprite可拖动的最简单方法是startDrag()函数-您也可以在那里设置限制(以留在编辑器区域或禁用负数大小)。

I have done such editors based on Sprites, added into Flex application with rawChildren.addChild, but you can try to use Canvases instead of Sprites if you wish. 我已经完成了基于Sprites的此类编辑器,并通过rawChildren.addChild将其添加到Flex应用程序中,但是您可以根据需要尝试使用Canvases而不是Sprites。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM