gpt4 book ai didi

javascript - 拉斐尔的不透明度超出范围(负值)

转载 作者:行者123 更新时间:2023-11-28 09:39:16 28 4
gpt4 key购买 nike

我有一个页面抛出 JavaScript 异常:

Unhandled exception at line 5144, column 13 in raphael.js0x80048270 - JavaScript runtime error: Arg: Fraction out of range (0 to 1 allowed)

I'm using version 2.1.0 of Raphaël, and for debugging purposes using the uncompressed JavaScript file not the minimized one (i.e. the one copied from http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael.js)

If I break into a debugger (I'm using Visual Studio 2012) I find that the value of the variable 'opacity' is -0.23185589076263113 while it should be between 0 and 1. But I cannot see how it got to be negative. Here's the code (from raphael.js, i.e. it's library code not my code)

        opacity = mmin(mmax(opacity, 0), 1);
params["stroke-width"] == null && (width = a["stroke-width"]);
params["stroke-width"] && (stroke.weight = width);
width && width < 1 && (opacity *= width) && (stroke.weight = 1);
stroke.opacity = opacity;

当第一行明确将其限制为 [0, 1] 时,如何在这段代码的最后一行使用 opacity == -0.23185589076263113 ?

(注意,在 raphael.js 中,mmax 是 math.max,mmin 是 math.min。)

最佳答案

找到了。

width && width < 1 && (opacity *= width) && (stroke.weight = 1); 
如果宽度为负(在本例中为负),则

会破坏不透明度范围。宽度在我引用的 block 之前的行上设置(5139):

var width = (toFloat(params["stroke-width"]) || 1) * .75;

我需要调试我的代码以找出为什么 params["lines-width"] 为负数,我建议 Raphael 防止这种情况:https://github.com/DmitryBaranovskiy/raphael/issues/623

关于javascript - 拉斐尔的不透明度超出范围(负值),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12606455/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com