Morepretty.

This commit is contained in:
treeform 2021-12-03 17:32:14 -08:00
parent ef20501ce1
commit b83a5ee726
2 changed files with 14 additions and 10 deletions

View file

@ -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

View file

@ -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,