ws-cleanup: MeshFlatten, Zip and the SVG style parser reuse Types.Scene.mul, Types.Date.civilFromDays, Raster.multiply

This commit is contained in:
4DBug committed 2026-10-31 12:31:32 -05:00
1 parent 44a599f00c
commit f5cf02026d
4 files changed
+6 -36

No files matched your search

+2 -12
View File
@@ -19,6 +19,7 @@
-- Never throws: corrupt archives and bad arguments return nil, Err. Parsing runs interpreted (it is cold); the native
-- code it reaches (Deflate, Crc32) does not throw either.
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
local Deflate = require("@formats/codecs/compress/Deflate")
@@ -421,18 +422,7 @@ function Zip.writer(): any
end
-- days from 1970-01-01 to y-m-d (proleptic Gregorian)
local function civil(z: number): (number, number, number)
z += 719468
local era = (if z >= 0 then z else z - 146096) // 146097
local doe = z - era * 146097
local yoe = (doe - doe // 1460 + doe // 36524 - doe // 146096) // 365
local y = yoe + era * 400
local doy = doe - (365 * yoe + yoe // 4 - yoe // 100)
local mp = (5 * doy + 2) // 153
local d = doy - (153 * mp + 2) // 5 + 1
local m = if mp < 10 then mp + 3 else mp - 9
return (if m <= 2 then y + 1 else y), m, d
end
local civil = Types.Date.civilFromDays
local function daysFrom(y: number, m: number, d: number): number
y = if m <= 2 then y - 1 else y
local era = (if y >= 0 then y else y - 399) // 400