js形状的内部还是外部

js形状的内部还是外部

本文介绍了检测点在raphael.js形状的内部还是外部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个raphael.js形状,正在上面绘制圆的形状.我只希望出现一个圆,如果该圆没有超出其绘制在其上的形状的边界.

I have a raphael.js shape which I am plotting circle's on top of. I only want a circle to appear if the circle does not go off the boundary of the shape it is being plotted on to.

为了更清楚地说明这一点,这是我不想发生的事情的一个示例:

To make this more clear, here is an example of what I do not want to happen:

示例http://img682.imageshack.us/img682/4168/shapeh. png

我希望灰色区域之外的圆圈不出现.我如何检测圆形在灰色形状的内部还是外部?

I want the circles outside of the grey area not to appear. How would I detect wether a circle is inside or outside of the grey shape?

推荐答案

您可以将剪切路径(应定义为示例中的灰色形状)应用于组(<g>元素)包含圆圈.

You could just apply a clip-path (that should be defined to be the grey shape you have in your example) on a group (<g> element) containing the circles.

请参见此示例 w3c SVG测试套件中>有关如何使用剪切路径的说明.

See this example from the w3c SVG testsuite for how to use clip-paths.

这篇关于检测点在raphael.js形状的内部还是外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:10