如何在Graphics-Object中的任意位置绘制位图?
一样将位图绘制到图形对象
this.graphics.beginBitmapFill(bitmapData, matrix, false);
this.graphics.drawRect(0, 0, w, h);
this.graphics.endFill();
是否可以像偏移 ? 在 beginBitmapFill 之前进行简单的 moveTo(x, y)
调用不起作用:/ 更改drawRect的x和y值也不起作用...(这似乎与矩阵平移具有相同的效果...) 另外,我不想在单独的图形对象中绘制那个东西并将其添加到另一个图形对象中......
有任何线索吗?
Is it possible to draw a Bitmap to a Graphics-Object like
this.graphics.beginBitmapFill(bitmapData, matrix, false);
this.graphics.drawRect(0, 0, w, h);
this.graphics.endFill();
with an offset?
A simple moveTo(x, y)
call before beginBitmapFill does not work :/
Neither does changing the x and y value of drawRect... (That just seems to have the same effect as an translation with the matrix...)
Additionally I don't want do draw that thing in a separate Graphics-Object and add that one into the other...
Any clue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 BitmapData(位图的)draw() 或 copyPixels() 方法。
请参阅文档:
http://livedocs .adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#draw%28%29
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#copyPixels%28%29
you can use the BitmapData (of your bitmap) draw() or copyPixels() methods.
see the docs:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#draw%28%29
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#copyPixels%28%29
这里的答案有点晚了,但由于我在谷歌搜索该主题时发现了这个问题,我想无论如何我都会添加一个答案。
您可以使用矩阵平移和位置的组合来进行drawRect调用,以在图形对象中的任何位置绘制位图:
说实话,我从来没有真正完全理解矩阵是什么;)并且没有任何直观的感觉关于如何使用它,所以很可能还有其他,也许更好的方法来做到这一点,但上述方法对我有用。
A bit late answer here, but since I found this question when googling on the subject, I figured I'd add an answer anyway.
You can use a combination of matrix translation and position for the drawRect call to draw a bitmap at any position in the graphics object:
To be honest, I have never really fully understood what the matrix is ;) and don't have any intuitive feeling for how to use it, so there may very well be other, and perhaps better, ways to do it, but the above worked for me.