Skip to content

Commit

Permalink
Merge pull request #680 from amarunko/rendering-respects-screen-scale
Browse files Browse the repository at this point in the history
Respects scale on rendering
  • Loading branch information
ystrot authored Jul 29, 2020
2 parents e00baaa + dafca2d commit af19c93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
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

0 comments on commit af19c93

Please sign in to comment.