mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 13:15:35 +03:00
#203 rename position to place of Pattern
This commit is contained in:
parent
c7ff33a7d6
commit
1234f0bac1
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ open class SVGParser {
|
||||
contentUserSpace = false
|
||||
}
|
||||
|
||||
let position = getPatternPosition(element)
|
||||
let place = getPatternPlace(element)
|
||||
|
||||
var contentNode: Node?
|
||||
if pattern.children.isEmpty {
|
||||
@ -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
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
@ -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? {
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user