tests/codecs (m-z): comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:50:53 -05:00
1 parent 98b4ce533e
commit a6732d45f2
23 files changed
+46 -177

No files matched your search

+3 -9
View File
@@ -1,7 +1,5 @@
-- codecs/image/Raster tests: exact coverage of axis-aligned rectangles at fractional positions; areas of circles; random
-- polygons and curves under random transforms against an independent 12 x 12 supersampled winding-number reference
-- (both fill rules); clipping, the stroker (width, caps, joins against analytic areas), fill() compositing and paint
-- functions; malformed paths never throw. Glyph rendering against FreeType is in tests/font/ttf.luau.
-- codecs/image/Raster tests: coverage against a 12 x 12 supersampled winding reference, the stroker, fill().
-- Glyph rendering against FreeType is in tests/font/ttf.luau.
local T = require("@tests/T")
local R = require("@rosetta/codecs/image/Raster")
local Types = require("@rosetta/Types")
@@ -27,7 +25,6 @@ local function at(m: any, x: number, y: number): number
return buffer.readu8(m.coverage, j * m.width + i)
end
-- 1. rectangles: exact per-pixel coverage
do
local p = R.path():rect(1.25, 2.5, 3.5, 2)
local m = R.mask(p) :: any
@@ -54,7 +51,7 @@ for _, r in { 3, 10.5, 40 } do
t:check(math.abs(a - math.pi * r * r) < 0.01 * math.pi * r * r + 1, string.format("circle r=%g area %.2f", r, a))
end
-- 3. random paths against a supersampled winding reference
-- random paths against a supersampled winding reference
local function wind(polys: { { number } }, px: number, py: number): number
local w = 0
for _, poly in polys do
@@ -143,7 +140,6 @@ do
t:check(math.abs(sum(R.mask(q)) - 84) < 0.01, "nonzero hole with opposite winding")
end
-- 5. clipping: a shape larger than the clip, partly outside on every side
do
local m = R.mask(R.path():rect(-20.5, -3.25, 100, 50), { clip = { 0, 0, 16, 8 } }) :: any
t:check(m and m.x == 0 and m.y == 0 and m.width == 16 and m.height == 8, "clipped bounds")
@@ -178,7 +174,6 @@ do
t:check(math.abs(a - 2 * math.pi * 10) < 1, "circle outline " .. a)
end
-- 7. fill onto an image: colours, opacity, paint functions, compositing over existing pixels
do
local img = Types.Image.new(8, 8)
t:check(R.fill(img, R.path():rect(0, 0, 4, 8), { 255, 0, 0, 255 }), "fill red")
@@ -208,7 +203,6 @@ do
end) == false, "a failing paint function returns false")
end
-- 8. malformed paths and huge / non-finite coordinates never throw
do
local bad: { any } = {
{ { op = "moveTo" }, { op = "lineTo", 1 }, { op = "quadTo", 1, 2, "x", 4 }, { op = "close" } },