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 +4 -4
- data/.yardopts +2 -0
- data/lib/osb/assert.rb +0 -1
- data/lib/osb/background.rb +1 -1
- data/lib/osb/color.rb +23 -21
- data/lib/osb/dsl/object.rb +2 -2
- data/lib/osb/enums/easing.rb +2 -0
- data/lib/osb/enums/layer.rb +2 -0
- data/lib/osb/enums/origin.rb +2 -0
- data/lib/osb/integer.rb +1 -0
- data/lib/osb/storyboard.rb +15 -12
- data/lib/osb/vector2.rb +17 -17
- data/lib/osb.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32ca949f86da7674ea4bb25916deb932a6f104ab36660947c8edc6130515a164
|
4
|
+
data.tar.gz: b3ab443117c2e9e5a192f097731fd723ad953ecb7488aaaf1af5abf28bbad8d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59ad469e27d5872abe498740c708edbfc11816f80b37ed64dc155c2da802451640fdb23928f2fe1c67eb5d4ceb916fe95bb18cc3e3927465d49075a6eee8a54b
|
7
|
+
data.tar.gz: d93b6b82cf34bdcc6adaba0bd5a0816f5bf560a757227445180b673a8cbf10e49d3b588ac6ee8204651e5f8dbc3d7fc4ce493c67745bd0cc0bc3d022d997b7f6
|
data/.yardopts
ADDED
data/lib/osb/assert.rb
CHANGED
data/lib/osb/background.rb
CHANGED
@@ -6,7 +6,7 @@ module Osb
|
|
6
6
|
# @private
|
7
7
|
attr_reader :command
|
8
8
|
|
9
|
-
# @param [String]
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# @
|
10
|
-
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
#
|
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
|
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
|
116
|
-
# @param [Integer, String, Array<Integer>] r red value, a hex
|
117
|
-
# or an
|
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
|
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)
|
data/lib/osb/dsl/object.rb
CHANGED
@@ -105,7 +105,7 @@ module Osb
|
|
105
105
|
end
|
106
106
|
|
107
107
|
# Set the background image for the beatmap.
|
108
|
-
# @param [String]
|
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]
|
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:)
|
data/lib/osb/enums/easing.rb
CHANGED
data/lib/osb/enums/layer.rb
CHANGED
@@ -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
|
data/lib/osb/enums/origin.rb
CHANGED
@@ -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
data/lib/osb/storyboard.rb
CHANGED
@@ -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
|
71
|
-
#
|
72
|
-
#
|
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
|
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
|
-
#
|
110
|
-
#
|
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
|
120
|
-
# have multiple nested
|
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
|
130
|
-
#
|
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
|
-
#
|
159
|
-
#
|
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
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
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
|
14
|
-
# @param [Numeric] y y coordinate of this
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
86
|
+
# Create a 2d vector.
|
88
87
|
# @param [Numeric, Array<Numeric>] x
|
89
|
-
# x coordinate of this
|
90
|
-
# @param [Numeric] y y coordinate of this
|
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
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.
|
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-
|
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
|