Openlayers RegularShape radius 1 和 radius 2 应该如何生成星星?

How should Openlayers RegularShape radius 1 and radius 2 be used to generate a star?

ol.style.RegularShape 的 Openlayers 文档说:

radius  number | undefined   Radius of a regular polygon.
radius1 number | undefined   Inner radius of a star.
radius2 number | undefined   Outer radius of a star.

我的解释是,对于正常的 多边形 (三角形、正方形、五边形等),我会使用 radius 但不应使用任何一个 radius1radius2。果然这工作正常。

同样,我将其解释为对于 ,我不应该使用 radius,我应该同时使用 radius1radius2 并且 radius1 应该小于 radius2。然而,这产生了一个看起来很奇怪的符号,我可以在其中看到星星的一部分,但它似乎被方形蒙版裁剪了。

为了获得我想要的结果(在检查了 Openlayers 示例代码之后),我最终使用了 radiusradius2,其中 radius2 是较小的数字!

下面是 javascript 的两个版本,唯一的区别是使用了各种 radius(X) 参数。

看来我对文档的理解不正确(或者 documentation/implementation 有问题)。

我想知道我的新代码为何有效。那么谁能解释一下各种 radius(X) 参数应该如何工作,并帮助我更好地理解所有三个参数的描述?

这段代码产生了一个看起来很奇怪的符号,有点像被方形掩码切断的星星:

new ol.style.Style({
    image: new ol.style.RegularShape({
        stroke: new ol.style.Stroke({
            color: '#333333FF',
            width: 6.0
        }),
        radius1: 24,
        radius2: 60,
        points: 5
    })
})

此代码生成正确的星标:

new ol.style.Style({
    image: new ol.style.RegularShape({
        stroke: new ol.style.Stroke({
            color: '#333333FF',
            width: 6.0
        }),
        radius: 60,
        radius2: 24,
        points: 5
    })
})

你是对的。文档不正确。我用修复程序创建了 https://github.com/openlayers/openlayers/pull/6604

您必须使用 radius1radius 作为恒星的外半径,而 radius2 作为内半径。您的第一个示例不起作用的原因是符号大小由 radiusradius1 确定。如果那是较小的半径,符号大小将无法容纳整个星星。