Skip to content

Commit

Permalink
#203 rename position to place of Pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Manin committed Jun 14, 2019
1 parent c7ff33a commit 1234f0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Source/model/draw/Pattern.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ open class Pattern: Fill {
public let content: Node
public let bounds: Rect
public let userSpace: Bool
public let position: Transform
public let place: Transform

public init(content: Node, bounds: Rect, viewBox: Rect, userSpace: Bool = false, position: Transform) {
public init(content: Node, bounds: Rect, viewBox: Rect, userSpace: Bool = false, place: Transform) {
self.viewBox = viewBox
self.content = content
self.bounds = bounds
self.userSpace = userSpace
self.position = position
self.place = place
}
}
2 changes: 1 addition & 1 deletion Source/render/ShapeRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ShapeRenderer: NodeRenderer {
}

let tileImage = renderer.renderToImage(bounds: viewBox, inset: 0)
ctx?.concatenate(pattern.position.toCG())
ctx?.concatenate(pattern.place.toCG())
ctx?.clip()
ctx?.draw(tileImage.cgImage!, in: patternBounds.toCG(), byTiling: true)
}
Expand Down
18 changes: 9 additions & 9 deletions Source/svg/SVGParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ open class SVGParser {
contentUserSpace = false
}

let position = getPatternPosition(element)
let place = getPatternPlace(element)

var contentNode: Node?
if pattern.children.isEmpty {
Expand All @@ -414,7 +414,7 @@ open class SVGParser {
}

if let contentNode = contentNode {
return UserSpacePattern(content: contentNode, bounds: bounds, viewBox: viewBox, userSpace: userSpace, contentUserSpace: contentUserSpace, position: position)
return UserSpacePattern(content: contentNode, bounds: bounds, viewBox: viewBox, userSpace: userSpace, contentUserSpace: contentUserSpace, place: place)
}
return .none
}
Expand All @@ -439,7 +439,7 @@ open class SVGParser {
return parseTransformationAttribute(transformAttribute)
}

fileprivate func getPatternPosition(_ element: SWXMLHash.XMLElement) -> Transform {
fileprivate func getPatternPlace(_ element: SWXMLHash.XMLElement) -> Transform {
guard let transformAttribute = element.allAttributes["patternTransform"]?.text else {
return .identity
}
Expand Down Expand Up @@ -692,14 +692,14 @@ open class SVGParser {
fileprivate func getPatternFill(pattern: UserSpacePattern, locus: Locus?) -> Pattern {
if pattern.userSpace == false && pattern.contentUserSpace == true {
let tranform = BoundsUtils.transformForLocusInRespectiveCoords(respectiveLocus: pattern.bounds, absoluteLocus: locus!)
return Pattern(content: pattern.content, bounds: pattern.bounds.applying(tranform), viewBox: pattern.viewBox, userSpace: true, position: pattern.position)
return Pattern(content: pattern.content, bounds: pattern.bounds.applying(tranform), viewBox: pattern.viewBox, userSpace: true, place: pattern.place)
}
if pattern.userSpace == true && pattern.contentUserSpace == false {
if let patternNode = BoundsUtils.createNodeFromRespectiveCoords(respectiveNode: pattern.content, absoluteLocus: locus!) {
return Pattern(content: patternNode, bounds: pattern.bounds, viewBox: pattern.viewBox, userSpace: pattern.userSpace, position: pattern.position)
return Pattern(content: patternNode, bounds: pattern.bounds, viewBox: pattern.viewBox, userSpace: pattern.userSpace, place: pattern.place)
}
}
return Pattern(content: pattern.content, bounds: pattern.bounds, viewBox: pattern.viewBox, userSpace: true, position: pattern.position)
return Pattern(content: pattern.content, bounds: pattern.bounds, viewBox: pattern.viewBox, userSpace: true, place: pattern.place)
}

fileprivate func getStroke(_ styleParts: [String: String], groupStyle: [String: String] = [:]) -> Stroke? {
Expand Down Expand Up @@ -1945,15 +1945,15 @@ fileprivate class UserSpacePattern {
let bounds: Rect
let userSpace: Bool
let contentUserSpace: Bool
let position: Transform
let place: Transform

init(content: Node, bounds: Rect, viewBox: Rect = Rect(x: 0, y: 0, w: 0, h: 0), userSpace: Bool = false, contentUserSpace: Bool = true, position: Transform = .identity) {
init(content: Node, bounds: Rect, viewBox: Rect = Rect(x: 0, y: 0, w: 0, h: 0), userSpace: Bool = false, contentUserSpace: Bool = true, place: Transform = .identity) {
self.viewBox = viewBox
self.content = content
self.bounds = bounds
self.userSpace = userSpace
self.contentUserSpace = contentUserSpace
self.position = position
self.place = place
}
}

Expand Down

0 comments on commit 1234f0b

Please sign in to comment.