I m从事以超5为基础的游戏,在这种游戏中,我想要将不同的半圆环带融为一体,从一个电网中抽取数百个广场。 影响像热图一样。 在进行了一些研究之后,我发现了Simon Sarris上文记载的“影子”技术。
采用这一技术是我所希望的。 我也认为很容易理解。 然而,在实践中,我发现,与我先前的提炼数千个填充物的技术(无论多么没有吸引力)相比,甚至使少数(约150)阴影变得更慢。
因此,我决定作一些分析。 我撰写了一些基本的 Java本(可在上看到的经修改的版本),以便从1250x600 canvas的五个不同类型中提取2000年版本,在五种主要桌面浏览器和移动式观测台的最新版本中记录这五项业务的历时。 (Sorry, desktop Sato)。 我也没有什么灵丹妙药来测试。 然后,我尝试了不同的效果组合,记录了过去的时间。
这里是一个简化的例子,说明Im 如何绘制两个梯度,其外观与影子相类似:
var gradient1 = context.createRadialGradient(75,100,2,75,100,80);
gradient1.addColorStop(0,"yellow");
gradient1.addColorStop(1,"black");
var gradient2 = context.createRadialGradient(125,100,2,125,100,80);
gradient2.addColorStop(0,"blue");
gradient2.addColorStop(1,"black");
context.beginPath();
context.globalCompositeOperation = "lighter";
context.globalAlpha = 0.5;
context.fillStyle = gradient1;
context.fillRect(0,0,200,200);
context.fillStyle = gradient2;
context.fillRect(0,0,200,200);
context.globalAlpha = 1.0;
context.closePath();
http://www.ohchr.org。
(2000年非重叠形状、全球沥青、梯度用于梯度,但不用于影子)
IE 11 (64-bit Windows 10)
Rects = 4 ms
Arcs = 35 ms
Gradients = 57 ms
Images = 8 ms
Shadows = 160 ms
Edge (64-bit Windows 10)
Rects = 3 ms
Arcs = 47 ms
Gradients = 52 ms
Images = 7 ms
Shadows = 171 ms
Chrome 48 (64-bit Windows 10)
Rects = 4 ms
Arcs = 10 ms
Gradients = 8 ms
Images = 8 ms
Shadows = 203 ms
Firefox 44 (64-bit Windows 10)
Rects = 4 ms
Arcs = 21 ms
Gradients = 7 ms
Images = 8 ms
Shadows = 468 ms
Opera 34 (64-bit Windows 10)
Rects = 4 ms
Arcs = 9 ms
Gradients = 8 ms
Images = 8 ms
Shadows = 202 ms
Mobile Safari (iPhone5, iOS 9)
Rects = 12 ms
Arcs = 31 ms
Gradients = 67 ms
Images = 82 ms
Shadows = 32 ms
OBSERVATIONS
- Among filled shapes, filled rects are consistently the fastest operation in all browsers and environments tested.
- Filled full arcs (circles) are about 10x slower in IE 11 and Edge than filled rects, compared to about 3.5x slower in the other major browsers.
- Gradients are roughly 3x slower than rects in IE 11, Chrome 48, and Opera 34, but a remarkable 100x slower in Firefox 44 (see Bugzilla report 728453).
- Images via drawImage() are roughly 1.5x as fast as filled rects in all desktop browsers.
- Shadowed filled arcs are slowest of all, ranging from around 50x slower than filled rects in IE, Edge, Chrome and Opera to 100x slower in Firefox.
- Chrome 48 and Opera 34 are both remarkably speedy in every category of shape except shadowed filled arcs, but they re no worse than other browsers there.
- Chrome and Opera crash when drawImage() draws 1000 shapes where either shadowOffsetX or shadowOffsetY is given a value outside the physical screen resolution.
- IE 11 and Edge are slower to paint arcs and gradients than other desktop browsers.
- drawImage() is slow on mobile Safari. It s actually faster to draw multiple gradients and shadowed arcs than to draw one copy many times with drawImage().
- Drawing in Firefox is sensitive to prior operations: drawing shadows and gradients makes drawing arcs slower. Fastest times are shown.
- Drawing in Mobile Safari is sensitive to prior operations: shadows make gradients slower; gradients and arcs make drawImage() even slower than it normally is. Fastest times are shown.
<>strong>ANALYSIS
虽然“影子”特征是一种简单和直观有效的混合方式,但比所有其他技术要慢得多。 这限制了其用途,而这种应用只需要汲取几个阴影,而不需要迅速和反复地利用许多阴影。 此外,在使用提款权时,投了阴影。 犯罪 X或影子 Y 价值大于3 000个 causes48和34号 Opera,几乎一分钟hang,耗时CPU周期,然后坠毁我的NVidia显示司机,甚至在更新后。 谷歌搜索发现,当一大笔阴影和 draw合使用时,没有用于 Ch的丑闻描述这一错误。
对于需要混合的异构体的用途,对影子采用最直观的类似做法是,将全球复合物作业设定为“灯光”并使用具有全球升值的提纲,以反复提取预设的半衰变体,或者在需要不同的颜色时提取单个梯度。 这并不完全与重叠的影子相匹配,而是紧密,避免进行每轮计算。 (然而,我们注意到,在流动游乐中,直接投影填满的弧体实际上比梯度和提纲更快。) 在为“灯光”而开展全球合作行动的同时,IE 11和Her在提炼弧方面比使用所有主要台式浏览器的影子更快,而且速度仅比在流动航道上填满的影子慢两倍。
http://www.ohchr.org。
If your only target platform is iPad/iPhone, the fastest method for nice-looking blended shapes is shadowed filled arcs. Otherwise, the fastest method with comparable appearance that I have found so far that works in all of the major desktop browsers is drawing radial gradients with globalCompositeOperation set to "lighter" and controlling opacity with globalAlpha.
<>说明: 在我进行的绘画测试中,有一些明显的改进方法。 尤其是,将每一形状的每一种情况都推向一个冲淡的缓冲地带,然后把整个缓冲带上可见的透镜,将大大改善业绩。 但是,这将否定这一检验的目标,即比较在可见的血管上绘制不同形状的相对速度。