Skip to content

Commit cc2bb82

Browse files
committed
Added ability to apply transforms to arbitrary points
Added the following functionality: * RenderableEntity: * public func applyTransforms(toPoint:Point, transforms:[Transform]? = nil) -> Point * public func applyTransforms(toPoints:[Point], transforms:[Transform]? = nil) -> [Point]
1 parent 0402721 commit cc2bb82

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

.dir-locals.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
;;; For more information see (info "(emacs) Directory Variables")
33

44
((swift-mode
5-
(flycheck-swift-include-search-paths "/usr/local/lib/merlin/Igis-1.1.5/Igis/.build/debug")))
5+
(flycheck-swift-include-search-paths "/usr/local/lib/merlin/Igis-1.2.0/Igis/.build/debug")))

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Scenes
22
_Scenes_ provides a Swift object library with support for **Scene**s, **Layer**s, and **RenderableEntity**s along with an event **Dispatcher**. _Scenes_ runs on top of IGIS.
3-
3+
44
## Usage
55

66
### Library
@@ -146,8 +146,15 @@ In order to support the EntityMouse* events, the following methods are available
146146
**RenderableEntity**s support alpha and transforms. The following methods may be invoked:
147147
```swift
148148
// This function should only be invoked during init(), setup(), or calculate()
149-
public func setTransforms(transforms:[Transform]?)
149+
public func setTransforms(transforms:[Transform]?)
150+
151+
// To convert an arbitrary point (for example, globalLocation) to its actual location
152+
// using either specific or current transforms:
153+
public func applyTransforms(toPoint:Point, transforms:[Transform]? = nil) -> Point
150154

155+
// To convert a series of arbitrary points to their actual location
156+
// using either specific or current transforms:
157+
public func applyTransforms(toPoints:[Point], transforms:[Transform]? = nil) -> [Point]
151158

152159
// This function should only be invoked during init(), setup(), or calculate()
153160
public func setAlpha(alpha:Alpha?)

Sources/Scenes/RenderableEntity.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,30 @@ open class RenderableEntity {
141141
self.alpha = alpha
142142
}
143143

144+
// Applies specified or current transforms to the specified point
145+
// If no transforms are current, returns the original point
146+
public func applyTransforms(toPoint:Point, transforms:[Transform]? = nil) -> Point {
147+
if let transforms = transforms ?? self.transforms {
148+
let matrix = Transform.multiply(transforms:transforms)
149+
let transformedPoint = matrix.apply(toPoint:toPoint)
150+
return transformedPoint
151+
} else {
152+
return toPoint
153+
}
154+
}
155+
156+
// Applies specified or current transforms to the specified points
157+
// If no transforms are current, returns the original points
158+
public func applyTransforms(toPoints:[Point], transforms:[Transform]? = nil) -> [Point] {
159+
if let transforms = transforms ?? self.transforms {
160+
let matrix = Transform.multiply(transforms:transforms)
161+
let transformedPoints = matrix.apply(toPoints:toPoints)
162+
return transformedPoints
163+
} else {
164+
return toPoints
165+
}
166+
}
167+
144168
public var layer : Layer {
145169
guard let owningLayer = owningLayer else {
146170
fatalError("owningLayer required")

dylib.manifest

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Igis 1.1.5
1+
Igis 1.2.0
2+

0 commit comments

Comments
 (0)