-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpriteBlueprint.swift
More file actions
40 lines (32 loc) · 1.03 KB
/
SpriteBlueprint.swift
File metadata and controls
40 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// SpriteBlueprint.swift
// Jikoku
//
// Created by Raphaël Calabro on 08/08/2017.
// Copyright © 2017 Raphaël Calabro. All rights reserved.
//
import Foundation
import Melisse
import GLKit
struct SpriteBlueprint : Hashable, Equatable, Packable {
var paintedShapes: [PaintedShape]
var size: Size<GLfloat>
var shadow: SpriteBlueprint {
return SpriteBlueprint(paintedShapes: [PaintedShape(shape: paintedShapes[0].shape, paint: ShadowPaint())], size: size * 1.5)
}
init(paintedShapes: [PaintedShape], size: Size<GLfloat>) {
self.paintedShapes = paintedShapes
self.size = size
}
var packSize: Size<Int> {
return Size(width: Int(size.width), height: Int(size.height))
}
var hashValue: Int {
return paintedShapes.hashValue &* 37
&+ size.hashValue &* 181
}
static func ==(lhs: SpriteBlueprint, rhs: SpriteBlueprint) -> Bool {
return lhs.paintedShapes == rhs.paintedShapes
&& lhs.size == rhs.size
}
}