computePixelBounds

This commit is contained in:
Ryan Oldenburg 2021-05-29 16:11:18 -05:00
parent f960349518
commit e76549368e

View file

@ -985,7 +985,7 @@ proc shapesToSegments(shapes: seq[seq[Vec2]]): seq[(Segment, int16)] =
result.add((segment, winding)) result.add((segment, winding))
proc computeBounds(segments: seq[(Segment, int16)]): Rect = proc computePixelBounds(segments: seq[(Segment, int16)]): Rect =
## Compute the bounds of the segments. ## Compute the bounds of the segments.
var var
xMin = float32.high xMin = float32.high
@ -1011,9 +1011,9 @@ proc computeBounds(segments: seq[(Segment, int16)]): Rect =
result.w = xMax - xMin result.w = xMax - xMin
result.h = yMax - yMin result.h = yMax - yMin
proc computeBounds*(path: Path): Rect = proc computePixelBounds*(path: Path): Rect =
## Compute the bounds of the path. ## Compute the bounds of the path.
path.commandsToShapes().shapesToSegments().computeBounds() path.commandsToShapes().shapesToSegments().computePixelBounds()
proc partitionSegments( proc partitionSegments(
segments: seq[(Segment, int16)], top, height: int segments: seq[(Segment, int16)], top, height: int
@ -1177,7 +1177,7 @@ proc fillShapes(
rgbx = color.asRgbx() rgbx = color.asRgbx()
blender = blendMode.blender() blender = blendMode.blender()
segments = shapes.shapesToSegments() segments = shapes.shapesToSegments()
bounds = computeBounds(segments) bounds = computePixelBounds(segments)
startX = max(0, bounds.x.int) startX = max(0, bounds.x.int)
startY = max(0, bounds.y.int) startY = max(0, bounds.y.int)
stopY = min(image.height, (bounds.y + bounds.h).int) stopY = min(image.height, (bounds.y + bounds.h).int)
@ -1287,7 +1287,7 @@ proc fillShapes(
# rasterize only within the total bounds # rasterize only within the total bounds
let let
segments = shapes.shapesToSegments() segments = shapes.shapesToSegments()
bounds = computeBounds(segments) bounds = computePixelBounds(segments)
startX = max(0, bounds.x.int) startX = max(0, bounds.x.int)
startY = max(0, bounds.y.int) startY = max(0, bounds.y.int)
stopY = min(mask.height, (bounds.y + bounds.h).int) stopY = min(mask.height, (bounds.y + bounds.h).int)