我正在尝试做一个消失的星球大战类型的事情,比如 this ,但是以编程方式。
他们所做的大部分工作都很容易编程(制作补间动画),但我也希望以编程方式生成基于文本的图形(例如,使用动态文本对象从文本生成)。
在我看来,问题(当然,我对其他看待它的方式持开放态度)是:有没有办法从我的动态中获得斜边矩形-文本对象?此处提到了scale9grid< /a> 不会这样做,我很确定。 我想指定四个点来获得菱形(如果这就是它的名字)。
I'm trying to do a vanishing Star Wars type thing like this, but programatically.
Most of what they've done is easy to program (make a motion tween), but I wish to generate the text-based graphic programatically as well (from text using a dynamic text obj, for example).
The question, as I see it (but I'm open to other ways of seeing it, of course) is: is there any way to get a slanty-sided rectangle from my dynamic-text object? The scale9grid mentioned here will not do it, I'm quite sure. I want to specify four points to get a rhombus (if that's what it's called).
发布评论
评论(3)
如果您正在为 Flash Player 10 进行编译(需要 CS4 或最新的 Flex sdk),则只需在 3D 中旋转文本字段:
还有一些问题,例如您需要使用字体嵌入,并获取消失点在视场的中心。
在 Flash Player 中执行此操作 < 10 位图也是可能的,如果你是受虐狂,并且不介意一些垂直锯齿。 这个想法是使用 BitmapData.draw() 绘制具有高度 1 剪切矩形的每条线,并进行变换以进行透视划分。 例如(在弯曲中):
我没有做过数学计算,所以我不知道这在物理上是否准确,但它应该给你一个想法。
If you are compiling for flash player 10 (which requires CS4 or a recent flex sdk), you can just rotate the text field in 3d:
There are a few more issues with this, such as you need to use font embedding, and getting the vanishing point in the center of the field.
Doing this in flash player < 10 with bitmaps is also possible, if you are masochistic, and don't mind some vertical aliasing. The idea would be to use BitmapData.draw() to draw each line with a height 1 clipping rect and a transform to do the perspective division. Eg (in flex):
I haven't done the maths, so I don't know if that's physically accurate, but it should give you an idea.
您可能会考虑将文本对象转换为图像,然后对图像执行此操作。
-亚当
You might consider converting the text object to an image, and then doing that to the image.
-Adam
在 Flash Player 9 及更早版本中,您实际上无法以简单的方式执行此操作。
Flash Player 10 和 Flash CS4 引入了对 3D 转换的一些基本支持,但这些支持非常简单,而且我想这种“极端”视角可能很难正确实现。 不过,我没有使用过 CS4 创作工具,所以那里可能更容易。
还有完整的 3D 引擎,例如 papervision 和 away3d 尽管它们有点矫枉过正。
我认为最好的可能是使用 DisplacementMapFilter ,我在网上找到任何好的例子时遇到了一些困难,而且我自己从未真正做过,但我认为 文档中的示例应该可以帮助您很好地入门。
如果您愿意,您也可以将所有像素绘制到位图上并逐一处理它们,这可能是编码中最有趣的事情,但它可能会非常慢并且看起来不太好;)
You can't really do this in a simple way in Flash Player 9 and earlier.
Flash player 10 and Flash CS4 introduces some basic support for 3D transformations, but these are quite simple, and i guess this "extreme" perspective could be tricky to get right. I have however not used the CS4 authoring tool, so it might be easier in there.
There are also the full 3D engines like papervision and away3d although they are a bit overkill.
What I think might be best is using a DisplacementMapFilter, I had some trouble finding any good examples of this online, and I've never actually done it myself, but I think the example in the docs should get you started just fine.
If you feel up for it you can also just draw all the pixels to a bitmap and have at them one by one, that might be the most fun thing to code, but it will likely be quite slow and not look as good ;)