ruby2d-camera 1.1.1 → 1.2.0.pre.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.mdown +5 -0
- data/lib/ruby2d/camera/circle.rb +30 -6
- data/lib/ruby2d/camera/quad.rb +31 -12
- data/lib/ruby2d/camera/triangle.rb +26 -9
- data/lib/ruby2d/camera/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7cb8d6e9a5fc5471d273472c36336080cc975a323c3e8e68ad367b6d9e9c9d9
|
4
|
+
data.tar.gz: 04d27cefad0aef63d46b159cb2656963055b362c8a7dd64e1a2d507074479638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3b143c892900526f9a667157f7c168b8dcc8b96cef8b76f8caa3b446c6c65c14f1daecd701357d3a1eca6ec8cd1d92cf27bf1a5112a63480bff1c061f5dcc6f
|
7
|
+
data.tar.gz: d898f544cdb0cda38c53819edda7d5d175979f573521cb64e5bb352e40516a9043303a2bbe8888535c8f72814c7dbf1fc2a27f8372b8a9fe783c47a677439f81
|
data/CHANGELOG.mdown
CHANGED
@@ -6,6 +6,11 @@
|
|
6
6
|
![Deprecated](https://img.shields.io/badge/-Deprecated-orange)
|
7
7
|
![Removed](https://img.shields.io/badge/-Removed-red)
|
8
8
|
|
9
|
+
## 1.2.0-beta.1 - 2021-10-04
|
10
|
+
![Added](https://img.shields.io/badge/-Added-brightgreen)
|
11
|
+
- Added rotation functions for Triangles, Quads, and Circles
|
12
|
+
- Need to finish the rest of the shapes to be ready for release
|
13
|
+
|
9
14
|
## [1.1.1](https://github.com/realtradam/ruby2d-camera/releases/tag/1.1.1) - 2021-09-24
|
10
15
|
![Fixed](https://img.shields.io/badge/-Fixed-blue)
|
11
16
|
- Fixed changing z-index after the shape has been added not applying at all
|
data/lib/ruby2d/camera/circle.rb
CHANGED
@@ -11,12 +11,17 @@ module Ruby2D
|
|
11
11
|
return if @hide
|
12
12
|
|
13
13
|
angle = Camera.angle * (Math::PI / 180)
|
14
|
+
self_angle = self.angle * (Math::PI / 180)
|
14
15
|
half_width = Window.width * 0.5
|
15
16
|
half_height = Window.height * 0.5
|
16
17
|
temp_radius = @radius * Camera.zoom
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
# rotate the shape
|
19
|
+
temp1_x = (x_offset * Math.cos(self_angle)) - (y_offset * Math.sin(self_angle)) + x
|
20
|
+
temp1_y = (y_offset * Math.cos(self_angle)) + (x_offset * Math.sin(self_angle)) + y
|
21
|
+
# apply the camera modifications
|
22
|
+
temp2_x = (((temp1_x - Ruby2D::Camera.x - radius) * Math.cos(angle)) - ((temp1_y - Ruby2D::Camera.y - radius) * Math.sin(angle))) * Ruby2D::Camera.zoom + half_width
|
23
|
+
temp2_y = (((temp1_x - Ruby2D::Camera.x - radius) * Math.sin(angle)) + ((temp1_y - Ruby2D::Camera.y - radius) * Math.cos(angle))) * Ruby2D::Camera.zoom + half_height
|
24
|
+
Ruby2D::Circle.draw(x: temp2_x, y: temp2_y,
|
20
25
|
radius: temp_radius,
|
21
26
|
sectors: sectors,
|
22
27
|
color: [color.r, color.g, color.b, color.a])
|
@@ -24,13 +29,32 @@ module Ruby2D
|
|
24
29
|
|
25
30
|
def initialize(opts = {})
|
26
31
|
super(opts)
|
32
|
+
unless opts[:x_offset].nil?
|
33
|
+
self.x_offset = opts[:x_offset]
|
34
|
+
end
|
35
|
+
unless opts[:y_offset].nil?
|
36
|
+
self.y_offset = opts[:y_offset]
|
37
|
+
end
|
27
38
|
Ruby2D::Camera << self
|
28
39
|
Window.remove(self)
|
29
40
|
end
|
30
41
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
42
|
+
def angle
|
43
|
+
@angle ||= 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def angle=(angle)
|
47
|
+
@angle = (angle % 360)
|
48
|
+
end
|
49
|
+
|
50
|
+
attr_writer :x_offset, :y_offset
|
51
|
+
|
52
|
+
def x_offset
|
53
|
+
@x_offset ||= 0
|
54
|
+
end
|
55
|
+
|
56
|
+
def y_offset
|
57
|
+
@y_offset ||= 0
|
34
58
|
end
|
35
59
|
|
36
60
|
def remove
|
data/lib/ruby2d/camera/quad.rb
CHANGED
@@ -11,20 +11,31 @@ module Ruby2D
|
|
11
11
|
return if @hide
|
12
12
|
|
13
13
|
angle = Camera.angle * (Math::PI / 180)
|
14
|
+
self_angle = self.angle * (Math::PI / 180)
|
14
15
|
half_width = Window.width * 0.5
|
15
16
|
half_height = Window.height * 0.5
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
# rotate the shape
|
18
|
+
temp1_x1 = (x1 * Math.cos(self_angle)) - (y1 * Math.sin(self_angle))
|
19
|
+
temp1_y1 = (y1 * Math.cos(self_angle)) + (x1 * Math.sin(self_angle))
|
20
|
+
temp1_x2 = (x2 * Math.cos(self_angle)) - (y2 * Math.sin(self_angle))
|
21
|
+
temp1_y2 = (y2 * Math.cos(self_angle)) + (x2 * Math.sin(self_angle))
|
22
|
+
temp1_x3 = (x3 * Math.cos(self_angle)) - (y3 * Math.sin(self_angle))
|
23
|
+
temp1_y3 = (y3 * Math.cos(self_angle)) + (x3 * Math.sin(self_angle))
|
24
|
+
temp1_x4 = (x4 * Math.cos(self_angle)) - (y4 * Math.sin(self_angle))
|
25
|
+
temp1_y4 = (y4 * Math.cos(self_angle)) + (x4 * Math.sin(self_angle))
|
26
|
+
# apply the camera modifications
|
27
|
+
temp2_x1 = (((x + temp1_x1 - Camera.x) * Math.cos(angle)) - ((y + temp1_y1 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
|
28
|
+
temp2_y1 = (((x + temp1_x1 - Camera.x) * Math.sin(angle)) + ((y + temp1_y1 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
|
29
|
+
temp2_x2 = (((x + temp1_x2 - Camera.x) * Math.cos(angle)) - ((y + temp1_y2 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
|
30
|
+
temp2_y2 = (((x + temp1_x2 - Camera.x) * Math.sin(angle)) + ((y + temp1_y2 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
|
31
|
+
temp2_x3 = (((x + temp1_x3 - Camera.x) * Math.cos(angle)) - ((y + temp1_y3 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
|
32
|
+
temp2_y3 = (((x + temp1_x3 - Camera.x) * Math.sin(angle)) + ((y + temp1_y3 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
|
33
|
+
temp2_x4 = (((x + temp1_x4 - Camera.x) * Math.cos(angle)) - ((y + temp1_y4 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
|
34
|
+
temp2_y4 = (((x + temp1_x4 - Camera.x) * Math.sin(angle)) + ((y + temp1_y4 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
|
35
|
+
Ruby2D::Quad.draw(x1: temp2_x1, y1: temp2_y1,
|
36
|
+
x2: temp2_x2, y2: temp2_y2,
|
37
|
+
x3: temp2_x3, y3: temp2_y3,
|
38
|
+
x4: temp2_x4, y4: temp2_y4,
|
28
39
|
color: [
|
29
40
|
[c1.r, c1.g, c1.b, c1.a],
|
30
41
|
[c2.r, c2.g, c2.b, c2.a],
|
@@ -48,6 +59,14 @@ module Ruby2D
|
|
48
59
|
@hide = false
|
49
60
|
end
|
50
61
|
|
62
|
+
def angle
|
63
|
+
@angle ||= 0
|
64
|
+
end
|
65
|
+
|
66
|
+
def angle=(angle)
|
67
|
+
@angle = (angle % 360)
|
68
|
+
end
|
69
|
+
|
51
70
|
# Methods for moving the shape
|
52
71
|
attr_writer :x, :y
|
53
72
|
|
@@ -9,17 +9,26 @@ module Ruby2D
|
|
9
9
|
return if @hide
|
10
10
|
|
11
11
|
angle = Ruby2D::Camera.angle * (Math::PI / 180)
|
12
|
+
self_angle = self.angle * (Math::PI / 180)
|
12
13
|
half_width = Window.width * 0.5
|
13
14
|
half_height = Window.height * 0.5
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
# rotate the shape
|
16
|
+
temp1_x1 = (x1 * Math.cos(self_angle)) - (y1 * Math.sin(self_angle))
|
17
|
+
temp1_y1 = (y1 * Math.cos(self_angle)) + (x1 * Math.sin(self_angle))
|
18
|
+
temp1_x2 = (x2 * Math.cos(self_angle)) - (y2 * Math.sin(self_angle))
|
19
|
+
temp1_y2 = (y2 * Math.cos(self_angle)) + (x2 * Math.sin(self_angle))
|
20
|
+
temp1_x3 = (x3 * Math.cos(self_angle)) - (y3 * Math.sin(self_angle))
|
21
|
+
temp1_y3 = (y3 * Math.cos(self_angle)) + (x3 * Math.sin(self_angle))
|
22
|
+
# apply camera operations
|
23
|
+
temp2_x1 = (((x + temp1_x1 - Camera.x) * Math.cos(angle)) - ((y + temp1_y1 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
|
24
|
+
temp2_y1 = (((x + temp1_x1 - Camera.x) * Math.sin(angle)) + ((y + temp1_y1 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
|
25
|
+
temp2_x2 = (((x + temp1_x2 - Camera.x) * Math.cos(angle)) - ((y + temp1_y2 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
|
26
|
+
temp2_y2 = (((x + temp1_x2 - Camera.x) * Math.sin(angle)) + ((y + temp1_y2 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
|
27
|
+
temp2_x3 = (((x + temp1_x3 - Camera.x) * Math.cos(angle)) - ((y + temp1_y3 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
|
28
|
+
temp2_y3 = (((x + temp1_x3 - Camera.x) * Math.sin(angle)) + ((y + temp1_y3 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
|
29
|
+
Ruby2D::Triangle.draw(x1: temp2_x1, y1: temp2_y1,
|
30
|
+
x2: temp2_x2, y2: temp2_y2,
|
31
|
+
x3: temp2_x3, y3: temp2_y3,
|
23
32
|
color: [
|
24
33
|
[c1.r, c1.g, c1.b, c1.a],
|
25
34
|
[c2.r, c2.g, c2.b, c2.a],
|
@@ -43,6 +52,14 @@ module Ruby2D
|
|
43
52
|
@hide = false
|
44
53
|
end
|
45
54
|
|
55
|
+
def angle
|
56
|
+
@angle ||= 0
|
57
|
+
end
|
58
|
+
|
59
|
+
def angle=(angle)
|
60
|
+
@angle = (angle % 360)
|
61
|
+
end
|
62
|
+
|
46
63
|
# Methods for moving the shape
|
47
64
|
attr_writer :x, :y
|
48
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2d-camera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0.pre.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tradam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2d
|
@@ -71,9 +71,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: 2.4.0
|
72
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - ">"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 1.3.1
|
77
77
|
requirements: []
|
78
78
|
rubygems_version: 3.2.22
|
79
79
|
signing_key:
|