Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Image Scale #781

Merged
merged 3 commits into from
Apr 21, 2022
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
2 changes: 1 addition & 1 deletion Macaw.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "Macaw"
s.version = "0.9.9"
s.version = "0.9.10"
s.summary = "Powerful and easy-to-use vector graphics library with SVG support written in Swift."

s.homepage = 'https://github.com/exyte/Macaw.git'
Expand Down
5 changes: 3 additions & 2 deletions Source/utils/CGMappings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ public extension CGAffineTransform {

public extension Node {

func toNativeImage(size: Size, layout: ContentLayout = .of()) throws -> MImage {
func toNativeImage(size: Size, layout: ContentLayout = .of(), scale: CGFloat = 0.0) throws -> MImage {
let renderer = RenderUtils.createNodeRenderer(self, view: nil)
let rect = size.rect()

MGraphicsBeginImageContextWithOptions(size.toCG(), false, 1)
MGraphicsBeginImageContextWithOptions(size.toCG(), false, scale)
let ctx = MGraphicsGetCurrentContext()!
ctx.clear(rect.toCG())

Expand All @@ -149,6 +149,7 @@ public extension Node {

defer {
MGraphicsEndImageContext()
renderer.dispose()
}

guard let img = MGraphicsGetImageFromCurrentImageContext() else {
Expand Down