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

Respects scale on rendering #680

Merged
merged 3 commits into from
Jul 29, 2020
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
4 changes: 2 additions & 2 deletions Source/model/scene/Shape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ open class Shape: Node {
}

fileprivate func createContext() -> CGContext? {

let screenScale: CGFloat = MMainScreen()?.mScale ?? 1.0
let smallSize = CGSize(width: 1.0, height: 1.0)

MGraphicsBeginImageContextWithOptions(smallSize, false, 1.0)
MGraphicsBeginImageContextWithOptions(smallSize, false, screenScale)

return MGraphicsGetCurrentContext()
}
Expand Down
2 changes: 1 addition & 1 deletion Source/render/GroupRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GroupRenderer: NodeRenderer {
renderers.removeAll()

renderers = group.contents.compactMap { child -> NodeRenderer? in
return RenderUtils.createNodeRenderer(child, view: view, parentRenderer: self)
RenderUtils.createNodeRenderer(child, view: view, parentRenderer: self)
}

var parent: NodeRenderer = self
Expand Down
3 changes: 2 additions & 1 deletion Source/render/NodeRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ class NodeRenderer {
}

func renderToImage(bounds: Rect, inset: Double = 0, coloringMode: ColoringMode = .rgb) -> MImage {
MGraphicsBeginImageContextWithOptions(CGSize(width: bounds.w + inset, height: bounds.h + inset), false, 1)
let screenScale: CGFloat = MMainScreen()?.mScale ?? 1.0
MGraphicsBeginImageContextWithOptions(CGSize(width: bounds.w + inset, height: bounds.h + inset), false, screenScale)
let tempContext = MGraphicsGetCurrentContext()!

// flip y-axis and leave space for the blur
Expand Down