在 Flex、as3 中围绕任何形状(心形、圆形等)绘制图形边框

发布于 2024-12-11 07:11:39 字数 526 浏览 0 评论 0原文

好吧,从过去的几个月来看,我正在寻找一个解决方案,但找不到这个问题的确切答案

问题是:

假设我有这张图片(如下所示),并且我必须在该图片周围显示内部边框图像,我认为通过图形显示周围的边框是最好的,

但是图形有一些有限数量的函数,如drawRect,drawRoundedRect等,

我也从Senously.com看到了Path.as,

我想知道的是它可以围绕这个形状绘制内部边框或任何其他不规则形状(通过图形,我猜我需要找到图像周围的边框像素),

我不想使用任何虚线(此图像上的另一个图像)作为边框,我知道这是一个解决方案,:-),但是这次事情非常基于计算,所以你们中的任何一个人都有任何工作算法或任何类似的东西,可以让我在任何形状周围绘制虚线边框,这会很有帮助,

我是Flex 开发人员,所以我应该告诉你这张图片是在某些画布中,我正在将此图像的位图数据绘制到画布中

谢谢

在此处输入图像描述

Well from last few months, i am looking for one solution, but couldn't find the exact answer to this question

The problem is :

Suppose i have this image with me(shown below), and i have to show a inner border around this image and i think showing border around this would be best through graphics,

but graphics has some limited number of functions like drawRect, drawRoundedRect etc,

I also have seen Path.as from Senocular.com,

The thing which i want to know, is it possible to draw a inner border around this shape or any other irregular shape(through graphics, i need to find the border pixels around the image, i guess),

i don't want to use any dotted line(another image over this image) as a border, i know thats a solution, :-), but this time things are pretty based on calculation, so any one of you have any working algorithm or any things like that which could let me draw dotted border around any sort of shape, that would be much helpful,

I am flex developer, so i should tell you this image is in some canvas, i am drawing the bitmap data of this image in to the canvas

Thank You

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅黛梨妆こ 2024-12-18 07:11:39

如果您的符号非常基本(未屏蔽),您可以使用简单的 getBounds 或 getBoundsRect 属性。如果它们更复杂,您可能会发现这很有用:

public function getFullBounds ( displayObject:DisplayObject ) :Rectangle
{
    var bounds:Rectangle, transform:Transform, toGlobalMatrix:Matrix, currentMatrix:Matrix;
    transform = displayObject.transform;
    currentMatrix = transform.matrix;
    toGlobalMatrix = transform.concatenatedMatrix;
    toGlobalMatrix.invert();
    transform.matrix = toGlobalMatrix;
    bounds = transform.pixelBounds.clone();
    transform.matrix = currentMatrix;
    return bounds;
}

照顾:http://usecake.com/lab/find-the-height-and-width-of-a-sprite-with-a-scrollrect.html

You could use the simple getBounds or getBoundsRect properties if your symbols are pretty basic (not masked). If they're more complex, you might find this useful:

public function getFullBounds ( displayObject:DisplayObject ) :Rectangle
{
    var bounds:Rectangle, transform:Transform, toGlobalMatrix:Matrix, currentMatrix:Matrix;
    transform = displayObject.transform;
    currentMatrix = transform.matrix;
    toGlobalMatrix = transform.concatenatedMatrix;
    toGlobalMatrix.invert();
    transform.matrix = toGlobalMatrix;
    bounds = transform.pixelBounds.clone();
    transform.matrix = currentMatrix;
    return bounds;
}

Care of: http://usecake.com/lab/find-the-height-and-width-of-a-sprite-with-a-scrollrect.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文