osb 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfa8c9fd46a2c0c25b5ae9b9d88d1043e2f16a74b01ff0ae1f8f7561d448f7f0
4
- data.tar.gz: 44a5c46b92e37bdb8f8f5694e8da2b28dabecc77d27793d43b15238ddc97382c
3
+ metadata.gz: 32ca949f86da7674ea4bb25916deb932a6f104ab36660947c8edc6130515a164
4
+ data.tar.gz: b3ab443117c2e9e5a192f097731fd723ad953ecb7488aaaf1af5abf28bbad8d2
5
5
  SHA512:
6
- metadata.gz: 96064b59c3bbca5233109df31a39cf1867a1c598bfdb4f5583f992af578d43c9b4659c46f81ef8fcedd870e112aaa415bc27e88c290025700d8f7ea35a26e812
7
- data.tar.gz: 601067ee4dd65cd6781b0a8719e988b5ba4f7888760a9dc4069b1d5369bfe497358314cf97ed01b3be9aee48a6cca0368e9bd6d0b31e59b930be818ba8be920b
6
+ metadata.gz: 59ad469e27d5872abe498740c708edbfc11816f80b37ed64dc155c2da802451640fdb23928f2fe1c67eb5d4ceb916fe95bb18cc3e3927465d49075a6eee8a54b
7
+ data.tar.gz: d93b6b82cf34bdcc6adaba0bd5a0816f5bf560a757227445180b673a8cbf10e49d3b588ac6ee8204651e5f8dbc3d7fc4ce493c67745bd0cc0bc3d022d997b7f6
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --no-private
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)
@@ -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.2"
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.0
4
+ version: 1.1.2
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-21 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple framework for building osu! storyboard.
14
14
  email: dinhvu2509@gmail.com
@@ -16,6 +16,7 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - ".yardopts"
19
20
  - lib/osb.rb
20
21
  - lib/osb/animation.rb
21
22
  - lib/osb/assert.rb