osb 1.1.1 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ac326d1ca7ffd249550ff8762b4b8f1f3a56aad69dd567a5f4146938ae9ca70
4
- data.tar.gz: e832ae17332a76d259c2813da3d5f602945bf9017f00080539042d7225caa029
3
+ metadata.gz: 980e34cc00ef3f8142dbc6822035f28264324006ec8ec89192e8505c1cb242cf
4
+ data.tar.gz: 2aa3495b686ae9b93ec8fce0fd8e240d3d363abafb83c8f080c0de4895cae4d2
5
5
  SHA512:
6
- metadata.gz: 1620c4004ef265061b2060969b115d02c28d848dd9f99cf1f3ef9045d3a5ce809025266a1637dbf19c72201d9c56dd10f618af81a8fede0cfe7caf8fca53962f
7
- data.tar.gz: af61c900d6ced4c4f19007a1b569e96fcd089f64e9f2f2a8503095746ad195c5334a0abd847ef98d8bc75558afb16f7bb874f9ad063b1213370d40ddc2962d7c
6
+ metadata.gz: 8bcb0418f74689d8c49fce3471ed59cda8900a90875e5f3c3b499d086623aaf24921c48bdffd900045b1fc603c69834ebea1c56a623e487f1e5508ef2a8793ed
7
+ data.tar.gz: a85a9feea55408ea18498e1355c317e9d7ddd6376cded2946153958151280699953dd2aed4fc6c7351466576fe011b045c05e81ff09c68ed30bff536738f6121
data/.yardopts CHANGED
@@ -1,3 +1,2 @@
1
1
  --no-private
2
- -
3
- README.md
2
+ --markup=markdown
data/lib/osb/assert.rb CHANGED
@@ -31,7 +31,6 @@ module Osb
31
31
  end
32
32
 
33
33
  # @private
34
- # @type [Hash{Class => Hash{Class => Object}}]
35
34
  T = {
36
35
  Array => {
37
36
  Numeric => TypedArray.new(Numeric),
@@ -6,7 +6,7 @@ module Osb
6
6
  # @private
7
7
  attr_reader :command
8
8
 
9
- # @param [String] file_name location of the background image relative to the beatmap directory.
9
+ # @param [String] file_path location of the background image relative to the beatmap directory.
10
10
  def initialize(file_path:)
11
11
  Internal.assert_type!(file_path, String, "file_path")
12
12
  Internal.assert_file_name_ext!(file_path, %w[png jpg jpeg])
data/lib/osb/color.rb CHANGED
@@ -3,16 +3,17 @@
3
3
  module Osb
4
4
  # Represents an RGB color.
5
5
  class Color
6
- attr_accessor :r, :g, :b
7
- # @attribute [rw] r
8
- # @return Red value.
9
- # @attribute [rw] g
10
- # @return Green value.
11
- # @attribute [rw] b
12
- # @return Blue value.
13
-
14
- # @param [Integer, String, Array<Integer>] r red value, a hex +String+,
15
- # or an +Array+ of 3 +{Integer}+s.
6
+ # @return [Integer] Red value.
7
+ attr_accessor :r
8
+
9
+ # @return [Integer] Green value.
10
+ attr_accessor :g
11
+
12
+ # @return [Integer] Blue value.
13
+ attr_accessor :b
14
+
15
+ # @param [Integer, String, Array<Integer>] r red value, a hex String,
16
+ # or an Array of 3 {Integer}s.
16
17
  # @param [Integer] g green value
17
18
  # @param [Integer] b blue value
18
19
  def initialize(r, g = nil, b = nil)
@@ -47,6 +48,7 @@ module Osb
47
48
 
48
49
  # Returns whether 2 colors are not equal.
49
50
  # @param [Color] color
51
+ # @return [Boolean]
50
52
  def !=(color)
51
53
  Internal.assert_type!(color, Color, "color")
52
54
 
@@ -54,9 +56,9 @@ module Osb
54
56
  end
55
57
 
56
58
  # Converts an HSL color value to RGB.
57
- # @param [Integer] hue
58
- # @param [Integer] saturation
59
- # @param [Integer] lightness
59
+ # @param [Integer] h hue
60
+ # @param [Integer] s saturation
61
+ # @param [Integer] l lightness
60
62
  # @return [Color]
61
63
  def self.from_hsl(h, s, l)
62
64
  Internal.assert_type!(h, Integer, "h")
@@ -100,7 +102,7 @@ module Osb
100
102
  return p
101
103
  end
102
104
 
103
- # Create a +{Color}+ object from hex string.
105
+ # Create a {Osb::Color} object from hex string.
104
106
  # @param [String] hex
105
107
  # @return [Color]
106
108
  def self.from_hex(hex)
@@ -112,9 +114,9 @@ module Osb
112
114
  end
113
115
  end
114
116
 
115
- # Create a new rgb +{Color}+.
116
- # @param [Integer, String, Array<Integer>] r red value, a hex +String+,
117
- # or an +Array+ of 3 +{Integer}+s.
117
+ # Create a new rgb {Osb::Color}.
118
+ # @param [Integer, String, Array<Integer>] r red value, a hex String,
119
+ # or an Array of 3 {Integer}s.
118
120
  # @param [Integer] g green value
119
121
  # @param [Integer] b blue value
120
122
  # @return [Color]
@@ -122,10 +124,10 @@ module Osb
122
124
  Color.new(r, g, b)
123
125
  end
124
126
 
125
- # Create a new hsl +{Color}+.
126
- # @param [Integer] hue
127
- # @param [Integer] saturation
128
- # @param [Integer] lightness
127
+ # Create a new hsl {Osb::Color}.
128
+ # @param [Integer] h hue
129
+ # @param [Integer] s saturation
130
+ # @param [Integer] l lightness
129
131
  # @return [Color]
130
132
  def hsl(h, s, l)
131
133
  Color.from_hsl(h, s, l)
@@ -63,7 +63,7 @@ module Osb
63
63
 
64
64
  end_time = "" if start_time == end_time
65
65
  tabs = " " * self.tab_level
66
- command = "#{tabs}F,#{start_time},#{end_time},#{start_opacity}"
66
+ command = "#{tabs}F,#{easing},#{start_time},#{end_time},#{start_opacity}"
67
67
  command += ",#{end_opacity}" if end_opacity != start_opacity
68
68
  @commands << command
69
69
  end
@@ -103,7 +103,7 @@ module Osb
103
103
  end_time = "" if start_time == end_time
104
104
  tabs = " " * self.tab_level
105
105
  command =
106
- "#{tabs}M,#{start_time},#{end_time},#{start_position.x},#{start_position.y}"
106
+ "#{tabs}M,#{easing},#{start_time},#{end_time},#{start_position.x},#{start_position.y}"
107
107
  if end_position != start_position
108
108
  command += ",#{end_position.x},#{end_position.y}"
109
109
  end
@@ -133,7 +133,7 @@ module Osb
133
133
 
134
134
  end_time = "" if start_time == end_time
135
135
  tabs = " " * self.tab_level
136
- command = "#{tabs}MX,#{start_time},#{end_time},#{start_x}"
136
+ command = "#{tabs}MX,#{easing},#{start_time},#{end_time},#{start_x}"
137
137
  command += ",#{end_x}" if end_x
138
138
  @commands << command
139
139
  end
@@ -161,7 +161,7 @@ module Osb
161
161
 
162
162
  end_time = "" if start_time == end_time
163
163
  tabs = " " * self.tab_level
164
- command = "#{tabs}MY,#{start_time},#{end_time},#{start_y}"
164
+ command = "#{tabs}MY,#{easing},#{start_time},#{end_time},#{start_y}"
165
165
  command += ",#{end_y}" if end_y != start_y
166
166
  @commands << command
167
167
  end
@@ -205,7 +205,7 @@ module Osb
205
205
  raise InvalidValueError,
206
206
  "start_scale and end_scale must be either both Numeric values or Vector2-like values."
207
207
  end
208
- command = "#{tabs}S,#{start_time},#{end_time},#{start_scale}"
208
+ command = "#{tabs}S,#{easing},#{start_time},#{end_time},#{start_scale}"
209
209
  command += ",#{end_scale}" if end_scale != start_scale
210
210
  @commands << command
211
211
  else
@@ -218,7 +218,7 @@ module Osb
218
218
  end_scale = Osb::Vector2.new(end_scale) if end_scale.is_a?(Array)
219
219
 
220
220
  command =
221
- "#{tabs}V,#{start_time},#{end_time},#{start_scale.x},#{start_scale.y}"
221
+ "#{tabs}V,#{easing},#{start_time},#{end_time},#{start_scale.x},#{start_scale.y}"
222
222
  command += ",#{end_scale.x},#{end_scale.y}" if end_scale
223
223
  @commands << command
224
224
  end
@@ -247,7 +247,7 @@ module Osb
247
247
 
248
248
  end_time = "" if start_time == end_time
249
249
  tabs = " " * self.tab_level
250
- command = "#{tabs}R,#{start_time},#{end_time},#{start_angle}"
250
+ command = "#{tabs}R,#{easing},#{start_time},#{end_time},#{start_angle}"
251
251
  command += ",#{end_angle}" if end_angle != start_angle
252
252
  @commands << command
253
253
  end
@@ -287,7 +287,7 @@ module Osb
287
287
  end_time = "" if start_time == end_time
288
288
  tabs = " " * self.tab_level
289
289
  command =
290
- "#{tabs}C,#{start_time},#{end_time},#{start_color.r},#{start_color.g},#{start_color.b}"
290
+ "#{tabs}C,#{easing},#{start_time},#{end_time},#{start_color.r},#{start_color.g},#{start_color.b}"
291
291
  if end_color != start_color
292
292
  command += ",#{end_color.r},#{end_color.g},#{end_color.b}"
293
293
  end
@@ -105,7 +105,7 @@ module Osb
105
105
  end
106
106
 
107
107
  # Set the background image for the beatmap.
108
- # @param [String] file_name location of the background image relative to the beatmap directory.
108
+ # @param [String] file_path location of the background image relative to the beatmap directory.
109
109
  # @return [void]
110
110
  def background(file_path:)
111
111
  self.raise_unless_inside_storyboard!
@@ -114,7 +114,7 @@ module Osb
114
114
  end
115
115
 
116
116
  # Set the video for the beatmap.
117
- # @param [String] file_name location of the video file relative to the beatmap directory.
117
+ # @param [String] file_path location of the video file relative to the beatmap directory.
118
118
  # @param [Integer] start_time when the video starts.
119
119
  # @return [void]
120
120
  def video(file_path:, start_time:)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osb
4
+ # Easing enums.
4
5
  module Easing
5
6
  Linear = 0
6
7
  Out = 1
@@ -37,6 +38,7 @@ module Osb
37
38
  InBounce = 32
38
39
  OutBounce = 33
39
40
  InOutBounce = 34
41
+ # @private
40
42
  ALL = 0..34
41
43
  end
42
44
  end
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osb
4
+ # Storyboard layer enums.
4
5
  module Layer
5
6
  Background = "Background"
6
7
  Fail = "Fail"
7
8
  Pass = "Pass"
8
9
  Foreground = "Foreground"
9
10
  Overlay = "Overlay"
11
+ # @private
10
12
  ALL = %w[Background Fail Pass Foreground Overlay]
11
13
  end
12
14
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osb
4
+ # Storyboard object origin enums.
4
5
  module Origin
5
6
  TopLeft = "TopLeft"
6
7
  TopCentre = "TopCentre"
@@ -16,6 +17,7 @@ module Osb
16
17
  BottomCentre = "BottomCentre"
17
18
  BottomCenter = "BottomCentre"
18
19
  BottomRight = "BottomRight"
20
+ # @private
19
21
  ALL = %w[
20
22
  TopLeft
21
23
  TopCentre
data/lib/osb/integer.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # A number of methods have been added to the Ruby Integer class to do units conversions.
3
4
  class Integer
4
5
  # Does nothing. Just a way to tell people it's represented in milliseconds.
5
6
  # @return [Integer]
@@ -67,9 +67,10 @@ module Osb
67
67
 
68
68
  # When designing storyboard, we often want to group storyboard elements
69
69
  # that are used in a similar context (eg. a scene), so this class' purpose
70
- # is only to act as a container. You can add the elements directly to the
71
- # +Osb::Storyboard+ object, but we recommend you to split the project into multiple
72
- # +Osb::Group+ so it will be easier to manage.
70
+ # is only to act as a container. You can add every element directly to the
71
+ # {Osb::Storyboard} object, but we recommend you to split the project into
72
+ # multiple {Osb::Group} so it will be easier to manage. A {Osb::Group} can
73
+ # have multiple nested {Osb::Group}s in itself.
73
74
  class Group
74
75
  # @private
75
76
  attr_reader :layers
@@ -78,7 +79,7 @@ module Osb
78
79
  @layers = Internal::LayerManager.new
79
80
  end
80
81
 
81
- # Add an +Osb::Sprite+, +Osb::Animation+, +Osb::Sample+ or +Osb::Group+ to
82
+ # Add an {Osb::Sprite}, {Osb::Animation}, {Osb::Sample} or {Group} to
82
83
  # this group.
83
84
  # @param [Osb::Group, Osb::Sprite, Osb::Animation, Osb::Sample] object
84
85
  # @return [self]
@@ -106,8 +107,9 @@ module Osb
106
107
  return self
107
108
  end
108
109
 
109
- # Add an +Osb::Sprite+, +Osb::Animation+, +Osb::Sample+ or +Osb::Group+ to
110
- # this group. Alias for +#add+.
110
+ # Alias for {#add}.
111
+ # Add a {Osb::Sprite}, {Osb::Animation}, {Osb::Sample} or {Group} to
112
+ # this group.
111
113
  # @param [Osb::Group, Osb::Sprite, Osb::Animation, Osb::Sample] object
112
114
  # @return [self]
113
115
  def <<(object)
@@ -116,8 +118,8 @@ module Osb
116
118
  end
117
119
 
118
120
  # Represent an osu! storyboard. Each sprite or animation can be added directly
119
- # to the storyboard instance, or through an intermediate group. A group can
120
- # have multiple nested groups in itself.
121
+ # to the storyboard instance, or through an intermediate group. A {Osb::Group}
122
+ # can have multiple nested {Osb::Group}s in itself.
121
123
  class Storyboard
122
124
  # @private
123
125
  attr_reader :layers
@@ -126,8 +128,8 @@ module Osb
126
128
  @layers = Internal::LayerManager.new
127
129
  end
128
130
 
129
- # Add an +Osb::Sprite+, +Osb::Animation+, +Osb::Sample+, +Osb::Video+,
130
- # +Osb::Background+ or +Osb::Group+ to this storyboard.
131
+ # Add a {Osb::Sprite}, {Osb::Animation}, {Osb::Sample}, {Osb::Video},
132
+ # {Osb::Background} or {Osb::Group} to this storyboard.
131
133
  # @param [Osb::Group, Osb::Sprite, Osb::Animation, Osb::Sample, Osb::Video,
132
134
  # Osb::Background] object
133
135
  # @return [self]
@@ -155,8 +157,9 @@ module Osb
155
157
  return self
156
158
  end
157
159
 
158
- # Add an +Osb::Sprite+, +Osb::Animation+, +Osb::Sample+, +Osb::Video+,
159
- # +Osb::Background+ or +Osb::Group+ to this storyboard. Alias for +#add+.
160
+ # Alias for {#add}.
161
+ # Add a {Osb::Sprite}, {Osb::Animation}, {Osb::Sample}, {Osb::Video},
162
+ # {Osb::Background} or {Osb::Group} to this storyboard.
160
163
  # @param [Osb::Group, Osb::Sprite, Osb::Animation, Osb::Sample, Osb::Video,
161
164
  # Osb::Background] object
162
165
  # @return [self]
data/lib/osb/vector2.rb CHANGED
@@ -3,15 +3,14 @@
3
3
  module Osb
4
4
  # Represents a 2d point or vector.
5
5
  class Vector2
6
- attr_accessor :x, :y
7
- # @!attribute [rw] x
8
- # @return x coordinate of this vector
9
- # @!attribute [rw] y
10
- # @return y coordinate of this vector
6
+ # @return [Numeric] x coordinate of this vector
7
+ attr_accessor :x
8
+ # @return [Numeric] y coordinate of this vector
9
+ attr_accessor :y
11
10
 
12
11
  # @param [Numeric, Array<Numeric>] x
13
- # x coordinate of this +{Vector2}+, or an +Array+ of 2 numbers.
14
- # @param [Numeric] y y coordinate of this +{Vector2}+
12
+ # x coordinate of this vector, or an +Array+ of 2 {Numeric} values.
13
+ # @param [Numeric] y y coordinate of this vector
15
14
  def initialize(x = 0, y = 0)
16
15
  Internal.assert_type!(x, [Numeric, Internal::T[Array][Numeric]], "x")
17
16
  Internal.assert_type!(y, Numeric, "y")
@@ -28,7 +27,7 @@ module Osb
28
27
  end
29
28
  end
30
29
 
31
- # Add another +{Vector2}+ to this one.
30
+ # Add another 2d vector to this one.
32
31
  # @param [Vector2] vector
33
32
  # @return [Vector2]
34
33
  def +(vector)
@@ -36,7 +35,7 @@ module Osb
36
35
  Vector2.new(self.x + vector.x, self.y + vector.y)
37
36
  end
38
37
 
39
- # Subtract another +{Vector2}+ from this one.
38
+ # Subtract another 2d vector from this one.
40
39
  # @param [Vector2] vector
41
40
  # @return [Vector2]
42
41
  def -(vector)
@@ -44,7 +43,7 @@ module Osb
44
43
  Vector2.new(self.x - vector.x, self.y - vector.y)
45
44
  end
46
45
 
47
- # Returns whether two +{Vector2}+ are equal within tolerance
46
+ # Returns whether two 2d vector are equal within tolerance
48
47
  # @param [Vector2] vector
49
48
  # @return [Boolean]
50
49
  def ==(vector)
@@ -52,14 +51,14 @@ module Osb
52
51
  Math.fuzzy_equal(self.x, vector.x) && Math.fuzzy_equal(self.y, vector.y)
53
52
  end
54
53
 
55
- # Returns whether two +{Vector2}+ are not equal within tolerance
54
+ # Returns whether two 2d vector are not equal within tolerance
56
55
  # @param [Vector2] vector
57
56
  # @return [Boolean]
58
57
  def !=(vector)
59
58
  !(self == vector)
60
59
  end
61
60
 
62
- # Makes a copy of this +{Vector2}+.
61
+ # Makes a copy of this 2d vector.
63
62
  # @return [Vector2]
64
63
  def clone
65
64
  Vector2.new(self.x, self.y)
@@ -71,23 +70,24 @@ module Osb
71
70
  [self.x, self.y]
72
71
  end
73
72
 
74
- # Returns a string representation of this +{Vector2}+.
73
+ # Returns a string representation of this 2d vector.
75
74
  # @return [String]
76
75
  def to_s
77
76
  self.to_a.to_s
78
77
  end
79
78
 
80
- # Returns the length of this +{Vector2}+.
79
+ # Returns the length of this 2d vector.
81
80
  # @return [Float]
82
81
  def length
83
82
  Math.sqrt(self.x**2 + self.y**2)
84
83
  end
85
84
  end
86
85
 
87
- # Create a +{Vector2}+.
86
+ # Create a 2d vector.
88
87
  # @param [Numeric, Array<Numeric>] x
89
- # x coordinate of this +{Vector2}+, or an +Array+ of 2 numbers.
90
- # @param [Numeric] y y coordinate of this +{Vector2}+
88
+ # x coordinate of this 2d vector, or an +Array+ of 2 numbers.
89
+ # @param [Numeric] y y coordinate of this 2d vector
90
+ # @return [Vector2]
91
91
  def vec2(x = 0, y = 0)
92
92
  Vector2.new(x, y)
93
93
  end
data/lib/osb.rb CHANGED
@@ -20,7 +20,7 @@ require_relative "osb/dsl/object"
20
20
  require_relative "osb/dsl/commands"
21
21
 
22
22
  module Osb
23
- VERSION = "1.1.0"
23
+ VERSION = "1.1.3"
24
24
  end
25
25
 
26
26
  # Extend the main object with the DSL commands.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dinh Vu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-23 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple framework for building osu! storyboard.
14
14
  email: dinhvu2509@gmail.com
@@ -17,7 +17,6 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - ".yardopts"
20
- - README.md
21
20
  - lib/osb.rb
22
21
  - lib/osb/animation.rb
23
22
  - lib/osb/assert.rb
@@ -56,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
55
  - !ruby/object:Gem::Version
57
56
  version: '0'
58
57
  requirements: []
59
- rubygems_version: 3.4.18
58
+ rubygems_version: 3.1.6
60
59
  signing_key:
61
60
  specification_version: 4
62
61
  summary: osu! storyboard framework
data/README.md DELETED
@@ -1,64 +0,0 @@
1
- # osb
2
- A simple osu! storyboard framework written in Ruby.
3
-
4
- ## Installation
5
-
6
- Install with Gem:
7
- ```sh
8
- gem install osb
9
- ```
10
-
11
- ## Usage
12
-
13
- Create a storyboard container:
14
- ```rb
15
- require "osb"
16
- include Osb
17
- sb = Storyboard.new
18
- ```
19
-
20
- Create a static image:
21
- ```rb
22
- sp = Sprite.new(file_path: "test.png")
23
- ```
24
-
25
- Describe what it does:
26
- ```rb
27
- sp.fade(start_time: 1000, start_opacity: 1)
28
- sp.move(start_time: 2000, start_position: [320, 640], end_position: [100, 100])
29
- sp.scale(start_time: 100, end_time: 200, start_scale: 1, end_scale: 2)
30
- ```
31
-
32
- Add it to the container:
33
- ```rb
34
- sb << sp
35
- ```
36
-
37
- Generate your storyboard file:
38
- ```rb
39
- sb.generate("path/to/your_storyboard_file.osb")
40
- ```
41
-
42
- osb also supports DSL syntax.
43
-
44
- ```rb
45
- storyboard do
46
- out_path "path/to/your_storyboard_file.osb"
47
-
48
- sprite file_path: "test.png" do
49
- fade start_time: 1000, start_opacity: 1
50
-
51
- move start_time: 2000, start_position: [320, 640], end_position: [100, 100]
52
- end
53
- end
54
- ```
55
-
56
- Full documentation is available at https://rubydoc.info/gems/osb/index.
57
-
58
- ## Contributing
59
-
60
- Bug reports and pull requests are welcome on GitHub at https://github.com/nanachi-code/osb-ruby.
61
-
62
- ## License
63
-
64
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).