Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: tools/lua/gradients.lua

Issue 2140293002: Fix Lua bugs, nit name change (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lua/gradients.lua
diff --git a/tools/lua/gradients.lua b/tools/lua/gradients.lua
index fb43017b1d8c6cb20d72d467d56c7b74fa7ad26e..4e24c9694aae8129a8fdef268f87616fbaac7d07 100644
--- a/tools/lua/gradients.lua
+++ b/tools/lua/gradients.lua
@@ -1,10 +1,10 @@
function sk_scrape_startcanvas(c, fileName) end
function sk_scrape_endcanvas(c, fileName) end
-SkScalarNearlyZero = 1.0 / bit32.lshift(1.0, 12)
+LuaDoubleNearlyZero = 1.0 / bit32.lshift(1.0, 12)
-function SkScalarNearlyEqual(a, b)
- return math.abs(a,b) <= SkScalarNearlyZero
+function LuaDoubleNearlyEqual(a, b)
+ return math.abs(a-b) <= LuaDoubleNearlyZero
end
gradients = {}
@@ -24,20 +24,21 @@ function sk_scrape_accumulate(t)
gradients[i].type = g.type
gradients[i].tile = g.tile
- numHardStops = 0
isEvenlySpaced = true
- for j = 2, g.colorCount, 1 do
- if not SkScalarNearlyEqual(g.positions[j], j/(g.colorCount-1)) then
+ for j = 1, g.colorCount, 1 do
+ if not LuaDoubleNearlyEqual(g.positions[j], (j-1)/(g.colorCount-1)) then
isEvenlySpaced = false
end
+ end
+ gradients[i].isEvenlySpaced = isEvenlySpaced
- if SkScalarNearlyEqual(g.positions[j], g.positions[j-1]) then
+ numHardStops = 0
+ for j = 2, g.colorCount, 1 do
+ if LuaDoubleNearlyEqual(g.positions[j], g.positions[j-1]) then
numHardStops = numHardStops + 1
end
end
-
- gradients[i].isEvenlySpaced = isEvenlySpaced
- gradients[i].numHardStops = numHardStops;
+ gradients[i].numHardStops = numHardStops;
gradients[i].positions = {}
for j = 1, g.colorCount, 1 do
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698