Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Samples.bundle/base64.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Samples.bundle/shapes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions SwiftDraw/Renderer.CGText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,11 @@ public final class CGTextRenderer: Renderer {
}

func draw(image: LayerTree.Image) {
lines.append("ctx.saveGState()")
lines.append("ctx.translateBy(x: 0, y: image.height)")
lines.append("ctx.scaleBy(x: 1, y: -1)")
lines.append("ctx.draw(image, in: CGRect(x: 0, y: 0, width: image.width, height: image.height)")
lines.append("ctx.restoreGState()")
}

func draw(linear gradient: LayerTree.Gradient, from start: String, to end: String) {
Expand Down
9 changes: 7 additions & 2 deletions SwiftDraw/Renderer.CoreGraphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ final class CGTransformingPattern: Equatable {
}

struct CGProvider: RendererTypeProvider {

typealias Types = CGTypes

func createFloat(from float: LayerTree.Float) -> CGFloat {
Expand Down Expand Up @@ -412,8 +413,12 @@ struct CGRenderer: Renderer {
}

func draw(image: CGImage) {
let rect = CGRect(x: 0, y: 0, width: image.width, height: image.height)
ctx.draw(image, in: rect)
let rect = CGRect(x: 0, y: 0, width: image.width, height: image.height)
pushState()
translate(tx: 0, ty: rect.height)
scale(sx: 1, sy: -1)
ctx.draw(image, in: rect)
popState()
}

func draw(linear gradient: CGGradient, from start: CGPoint, to end: CGPoint) {
Expand Down