From b83a5ee726f9b33720b430ed83293ba91f1481a1 Mon Sep 17 00:00:00 2001 From: treeform <starplant@gmail.com> Date: Fri, 3 Dec 2021 17:32:14 -0800 Subject: [PATCH] Morepretty. --- src/pixie/fileformats/svg.nim | 3 +-- src/pixie/paths.nim | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/pixie/fileformats/svg.nim b/src/pixie/fileformats/svg.nim index ea4dd79..f786db8 100644 --- a/src/pixie/fileformats/svg.nim +++ b/src/pixie/fileformats/svg.nim @@ -1,8 +1,7 @@ ## Load SVG files. -import chroma, pixie/common, pixie/internal, pixie/images, pixie/paints, +import chroma, pixie/common, pixie/images, pixie/internal, pixie/paints, pixie/paths, strutils, tables, vmath, xmlparser, xmltree - when defined(pixieDebugSvg): import strtabs diff --git a/src/pixie/paths.nim b/src/pixie/paths.nim index 6352457..8f5c554 100644 --- a/src/pixie/paths.nim +++ b/src/pixie/paths.nim @@ -675,7 +675,7 @@ proc commandsToShapes( pow(t, 3) * to var - t: float32 # Where we are at on the curve from [0, 1] + t: float32 # Where we are at on the curve from [0, 1] step = 1.float32 # How far we want to try to move along the curve prev = at next = compute(at, ctrl1, ctrl2, to, t + step) @@ -706,7 +706,7 @@ proc commandsToShapes( pow(t, 2) * to var - t: float32 # Where we are at on the curve from [0, 1] + t: float32 # Where we are at on the curve from [0, 1] step = 1.float32 # How far we want to try to move along the curve prev = at next = compute(at, ctrl, to, t + step) @@ -825,7 +825,7 @@ proc commandsToShapes( let arc = endpointToCenterArcParams(at, radii, rotation, large, sweep, to) var - t: float32 # Where we are at on the curve from [0, 1] + t: float32 # Where we are at on the curve from [0, 1] step = 1.float32 # How far we want to try to move along the curve prev = at while t != 1: @@ -2330,7 +2330,8 @@ when defined(pixieSweeps): let sweepHeight = cutLines[currCutLine + 1] - cutLines[currCutLine] yFracTop = ((y.float32 - cutLines[currCutLine]) / sweepHeight).clamp(0, 1) - yFracBottom = ((y.float32 + 1 - cutLines[currCutLine]) / sweepHeight).clamp(0, 1) + yFracBottom = ((y.float32 + 1 - cutLines[currCutLine]) / + sweepHeight).clamp(0, 1) var i = 0 while i < sweep.len: let @@ -2352,11 +2353,13 @@ when defined(pixieSweeps): nw = vec2(sweep[i+0].atx, cutLines[currCutLine]) sw = vec2(sweep[i+0].tox, cutLines[currCutLine + 1]) for x in minWi ..< maxWi: - var area = pixelCover(nw - vec2(x.float32, y.float32), sw - vec2(x.float32, y.float32)) + var area = pixelCover(nw - vec2(x.float32, y.float32), sw - vec2( + x.float32, y.float32)) coverages[x - startX] += (area * 255).uint8 let x = maxWi - var midArea = pixelCover(nw - vec2(x.float32, y.float32), sw - vec2(x.float32, y.float32)) + var midArea = pixelCover(nw - vec2(x.float32, y.float32), sw - vec2( + x.float32, y.float32)) var midArea8 = (midArea * 255).uint8 for x in maxWi ..< minEi: # TODO: Maybe try coverages of uint16 to prevent streeks in solid white fill? @@ -2366,7 +2369,8 @@ when defined(pixieSweeps): ne = vec2(sweep[i+1].atx, cutLines[currCutLine]) se = vec2(sweep[i+1].tox, cutLines[currCutLine + 1]) for x in minEi ..< maxEi: - var area = midArea - pixelCover(ne - vec2(x.float32, y.float32), se - vec2(x.float32, y.float32)) + var area = midArea - pixelCover(ne - vec2(x.float32, y.float32), se - + vec2(x.float32, y.float32)) coverages[x - startX] += (area * 255).uint8 i += 2 @@ -2382,7 +2386,8 @@ when defined(pixieSweeps): inc currCutLine if currCutLine == sweeps.len: break - coverages.computeCoverage(scanLine, startX, cutLines, currCutLine, sweeps[currCutLine]) + coverages.computeCoverage(scanLine, startX, cutLines, currCutLine, + sweeps[currCutLine]) image.fillCoverage( rgbx,