Morepretty.
This commit is contained in:
parent
ef20501ce1
commit
b83a5ee726
2 changed files with 14 additions and 10 deletions
|
@ -1,8 +1,7 @@
|
||||||
## Load SVG files.
|
## 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
|
pixie/paths, strutils, tables, vmath, xmlparser, xmltree
|
||||||
|
|
||||||
when defined(pixieDebugSvg):
|
when defined(pixieDebugSvg):
|
||||||
import strtabs
|
import strtabs
|
||||||
|
|
||||||
|
|
|
@ -675,7 +675,7 @@ proc commandsToShapes(
|
||||||
pow(t, 3) * to
|
pow(t, 3) * to
|
||||||
|
|
||||||
var
|
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
|
step = 1.float32 # How far we want to try to move along the curve
|
||||||
prev = at
|
prev = at
|
||||||
next = compute(at, ctrl1, ctrl2, to, t + step)
|
next = compute(at, ctrl1, ctrl2, to, t + step)
|
||||||
|
@ -706,7 +706,7 @@ proc commandsToShapes(
|
||||||
pow(t, 2) * to
|
pow(t, 2) * to
|
||||||
|
|
||||||
var
|
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
|
step = 1.float32 # How far we want to try to move along the curve
|
||||||
prev = at
|
prev = at
|
||||||
next = compute(at, ctrl, to, t + step)
|
next = compute(at, ctrl, to, t + step)
|
||||||
|
@ -825,7 +825,7 @@ proc commandsToShapes(
|
||||||
let arc = endpointToCenterArcParams(at, radii, rotation, large, sweep, to)
|
let arc = endpointToCenterArcParams(at, radii, rotation, large, sweep, to)
|
||||||
|
|
||||||
var
|
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
|
step = 1.float32 # How far we want to try to move along the curve
|
||||||
prev = at
|
prev = at
|
||||||
while t != 1:
|
while t != 1:
|
||||||
|
@ -2330,7 +2330,8 @@ when defined(pixieSweeps):
|
||||||
let
|
let
|
||||||
sweepHeight = cutLines[currCutLine + 1] - cutLines[currCutLine]
|
sweepHeight = cutLines[currCutLine + 1] - cutLines[currCutLine]
|
||||||
yFracTop = ((y.float32 - cutLines[currCutLine]) / sweepHeight).clamp(0, 1)
|
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
|
var i = 0
|
||||||
while i < sweep.len:
|
while i < sweep.len:
|
||||||
let
|
let
|
||||||
|
@ -2352,11 +2353,13 @@ when defined(pixieSweeps):
|
||||||
nw = vec2(sweep[i+0].atx, cutLines[currCutLine])
|
nw = vec2(sweep[i+0].atx, cutLines[currCutLine])
|
||||||
sw = vec2(sweep[i+0].tox, cutLines[currCutLine + 1])
|
sw = vec2(sweep[i+0].tox, cutLines[currCutLine + 1])
|
||||||
for x in minWi ..< maxWi:
|
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
|
coverages[x - startX] += (area * 255).uint8
|
||||||
|
|
||||||
let x = maxWi
|
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
|
var midArea8 = (midArea * 255).uint8
|
||||||
for x in maxWi ..< minEi:
|
for x in maxWi ..< minEi:
|
||||||
# TODO: Maybe try coverages of uint16 to prevent streeks in solid white fill?
|
# 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])
|
ne = vec2(sweep[i+1].atx, cutLines[currCutLine])
|
||||||
se = vec2(sweep[i+1].tox, cutLines[currCutLine + 1])
|
se = vec2(sweep[i+1].tox, cutLines[currCutLine + 1])
|
||||||
for x in minEi ..< maxEi:
|
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
|
coverages[x - startX] += (area * 255).uint8
|
||||||
|
|
||||||
i += 2
|
i += 2
|
||||||
|
@ -2382,7 +2386,8 @@ when defined(pixieSweeps):
|
||||||
inc currCutLine
|
inc currCutLine
|
||||||
if currCutLine == sweeps.len:
|
if currCutLine == sweeps.len:
|
||||||
break
|
break
|
||||||
coverages.computeCoverage(scanLine, startX, cutLines, currCutLine, sweeps[currCutLine])
|
coverages.computeCoverage(scanLine, startX, cutLines, currCutLine,
|
||||||
|
sweeps[currCutLine])
|
||||||
|
|
||||||
image.fillCoverage(
|
image.fillCoverage(
|
||||||
rgbx,
|
rgbx,
|
||||||
|
|
Loading…
Reference in a new issue