-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshapes_view.rb
More file actions
42 lines (37 loc) · 1.35 KB
/
shapes_view.rb
File metadata and controls
42 lines (37 loc) · 1.35 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
41
42
class ShapesView < UIButton
def init
super
backgroundColor = UIColor.blackColor
# addSubview(image_view = UIImageView.new)
# image_view.image = UIImage.imageNamed('title')
# image_view.frame = [[32, 50], [256, 144]]
# @image_layer = image_view.layer
layer.addSublayer(@image_layer = CALayer.layer)
@image_layer.contents = UIImage.imageNamed('title').CGImage
@image_layer.position = [161, 122]
@image_layer.bounds = [[0, 0], [256, 144]]
@image_layer.speed = 0.2
self
end
def animate(_)
if @image_layer.opacity > 0.5
@image_layer.opacity = 0.5
@image_layer.position = [161, 235]
# @image_layer.transform = CATransform3DMakeRotation(Math::PI/1.5, 1, 0, 0)
# @image_layer.transform = CATransform3DMakeScale(0.5, 0.5, 1.0)
@image_layer.transform = CATransform3DConcat(
CATransform3DMakeRotation(Math::PI/1.5, 1, 0, 0),
CATransform3DMakeScale(0.5, 0.5, 1.0)
)
else
@image_layer.opacity = 1.0
@image_layer.position = [161, 122]
# @image_layer.transform = CATransform3DMakeRotation(Math::PI, 0, 0, 0)
# @image_layer.transform = CATransform3DMakeScale(1.0, 1.0, 1.0)
@image_layer.transform = CATransform3DConcat(
CATransform3DMakeRotation(Math::PI, 0, 0, 0),
CATransform3DMakeScale(1.0, 1.0, 1.0)
)
end
end
end