Module: Osb
- Defined in:
- lib/osb.rb,
lib/osb/color.rb,
lib/osb/video.rb,
lib/osb/assert.rb,
lib/osb/sample.rb,
lib/osb/sprite.rb,
lib/osb/vector2.rb,
lib/osb/animation.rb,
lib/osb/background.rb,
lib/osb/dsl/object.rb,
lib/osb/storyboard.rb,
lib/osb/commandable.rb,
lib/osb/enums/layer.rb,
lib/osb/dsl/commands.rb,
lib/osb/enums/easing.rb,
lib/osb/enums/origin.rb
Defined Under Namespace
Modules: Commandable, Easing, Layer, Origin Classes: Animation, Background, Color, Group, Sample, Sprite, Storyboard, Vector2, Video
Constant Summary collapse
- VERSION =
"1.1.3"
Instance Method Summary collapse
-
#additive_color_blending(start_time:, end_time:) ⇒ void
Use additive-color blending instead of alpha-blending.
-
#animation(layer: Osb::Layer::Background, origin: Osb::Origin::Center, file_path:, initial_position: nil, frame_count:, frame_delay:, repeat: false) ⇒ void
Create a moving image.
-
#background(file_path:) ⇒ void
Set the background image for the beatmap.
-
#color(start_time:, end_time: start_time, easing: Easing::Linear, start_color:, end_color: start_color) ⇒ void
The virtual light source colour on the object.
-
#fade(start_time:, end_time: start_time, easing: Easing::Linear, start_opacity:, end_opacity: start_opacity) ⇒ void
Change the opacity of the object (how transparent it is).
-
#flip(start_time:, end_time:, horizontally: true, vertically: false) ⇒ void
Flip the object horizontally or vertically.
-
#group(name: nil) ⇒ void
Group multiple objects for clarity.
-
#hsl(h, s, l) ⇒ Color
Create a new hsl Color.
-
#move(start_time:, end_time: start_time, easing: Easing::Linear, start_position:, end_position: start_position) ⇒ void
Move the object to a new position in the play area.
-
#move_x(start_time:, end_time: start_time, easing: Easing::Linear, start_x:, end_x: start_x) ⇒ void
Move the object along the x axis.
-
#move_y(start_time:, end_time: start_time, easing: Easing::Linear, start_y:, end_y: start_y) ⇒ void
Move the object along the y axis.
-
#out_path(path) ⇒ Object
Set the output directory of this storyboard.
-
#rgb(r, g = nil, b = nil) ⇒ Color
Create a new rgb Color.
-
#rotate(start_time:, end_time: start_time, easing: Easing::Linear, start_angle:, end_angle: start_angle) ⇒ void
Rotate the object around its origin.
-
#sample(time:, layer:, file_path:, volume: 100) ⇒ Object
Add an audio sample to the storyboard.
-
#scale(start_time:, end_time: start_time, easing: Easing::Linear, start_scale:, end_scale: start_scale) ⇒ void
Change the size of the object relative to its original size.
-
#sprite(layer: Layer::Background, origin: Origin::Center, file_path:, initial_position: nil) ⇒ void
Create a still image.
-
#storyboard ⇒ void
Create an osu! storyboard.
-
#trigger(on:, start_time:, end_time:, &blk) ⇒ void
Add a group of commands on a specific condition.
-
#vec2(x = 0, y = 0) ⇒ Vector2
Create a 2d vector.
-
#video(file_path:, start_time:) ⇒ void
Set the video for the beatmap.
Instance Method Details
#additive_color_blending(start_time:, end_time:) ⇒ void
This method returns an undefined value.
Use additive-color blending instead of alpha-blending.
210 211 212 213 214 215 216 |
# File 'lib/osb/dsl/commands.rb', line 210 def additive_color_blending(start_time:, end_time:) self.raise_unless_inside_object! self.current_object.additive_color_blending( start_time: start_time, end_time: end_time ) end |
#animation(layer: Osb::Layer::Background, origin: Osb::Origin::Center, file_path:, initial_position: nil, frame_count:, frame_delay:, repeat: false) ⇒ void
This method returns an undefined value.
Create a moving image.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/osb/dsl/object.rb', line 77 def animation( layer: Osb::Layer::Background, origin: Osb::Origin::Center, file_path:, initial_position: nil, frame_count:, frame_delay:, repeat: false ) self.raise_unless_inside_storyboard! if @sprite || @animation raise RuntimeError, "Cannot create a new animation inside another animation/animation." end @animation = Animation.new( layer: layer, origin: origin, file_path: file_path, initial_position: initial_position, frame_count: frame_count, frame_delay: frame_delay, repeat: repeat ) @storyboard << @animation yield @animation = nil end |
#background(file_path:) ⇒ void
This method returns an undefined value.
Set the background image for the beatmap.
110 111 112 113 114 |
# File 'lib/osb/dsl/object.rb', line 110 def background(file_path:) self.raise_unless_inside_storyboard! @storyboard << Background.new(file_path: file_path) end |
#color(start_time:, end_time: start_time, easing: Easing::Linear, start_color:, end_color: start_color) ⇒ void
This method returns an undefined value.
The virtual light source colour on the object. The colours of the pixels on the object are determined subtractively.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/osb/dsl/commands.rb', line 173 def color( start_time:, end_time: start_time, easing: Easing::Linear, start_color:, end_color: start_color ) self.raise_unless_inside_object! self.current_object.color( start_time: start_time, end_time: end_time, easing: easing, start_color: start_color, end_color: end_color ) end |
#fade(start_time:, end_time: start_time, easing: Easing::Linear, start_opacity:, end_opacity: start_opacity) ⇒ void
This method returns an undefined value.
Change the opacity of the object (how transparent it is).
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/osb/dsl/commands.rb', line 27 def fade( start_time:, end_time: start_time, easing: Easing::Linear, start_opacity:, end_opacity: start_opacity ) self.raise_unless_inside_object! self.current_object.fade( start_time: start_time, end_time: end_time, easing: easing, start_opacity: start_opacity, end_opacity: end_opacity ) end |
#flip(start_time:, end_time:, horizontally: true, vertically: false) ⇒ void
This method returns an undefined value.
Flip the object horizontally or vertically.
196 197 198 199 200 201 202 203 204 |
# File 'lib/osb/dsl/commands.rb', line 196 def flip(start_time:, end_time:, horizontally: true, vertically: false) self.raise_unless_inside_object! self.current_object.flip( start_time: start_time, end_time: end_time, horizontally: horizontally, vertically: vertically ) end |
#group(name: nil) ⇒ void
This method returns an undefined value.
Group multiple objects for clarity.
65 66 |
# File 'lib/osb/dsl/object.rb', line 65 def group(name: nil) end |
#hsl(h, s, l) ⇒ Color
Create a new hsl Color.
132 133 134 |
# File 'lib/osb/color.rb', line 132 def hsl(h, s, l) Color.from_hsl(h, s, l) end |
#move(start_time:, end_time: start_time, easing: Easing::Linear, start_position:, end_position: start_position) ⇒ void
This method returns an undefined value.
Move the object to a new position in the play area.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/osb/dsl/commands.rb', line 51 def move( start_time:, end_time: start_time, easing: Easing::Linear, start_position:, end_position: start_position ) self.raise_unless_inside_object! self.current_object.move( start_time: start_time, end_time: end_time, easing: easing, start_position: start_position, end_position: end_position ) end |
#move_x(start_time:, end_time: start_time, easing: Easing::Linear, start_x:, end_x: start_x) ⇒ void
This method returns an undefined value.
Move the object along the x axis.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/osb/dsl/commands.rb', line 75 def move_x( start_time:, end_time: start_time, easing: Easing::Linear, start_x:, end_x: start_x ) self.raise_unless_inside_object! self.current_object.move_x( start_time: start_time, end_time: end_time, easing: easing, start_x: start_x, end_x: end_x ) end |
#move_y(start_time:, end_time: start_time, easing: Easing::Linear, start_y:, end_y: start_y) ⇒ void
This method returns an undefined value.
Move the object along the y axis.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/osb/dsl/commands.rb', line 99 def move_y( start_time:, end_time: start_time, easing: Easing::Linear, start_y:, end_y: start_y ) self.raise_unless_inside_object! self.current_object.move_x( start_time: start_time, end_time: end_time, easing: easing, start_y: start_y, end_y: end_y ) end |
#out_path(path) ⇒ Object
Set the output directory of this storyboard.
14 15 16 17 |
# File 'lib/osb/dsl/object.rb', line 14 def out_path(path) self.raise_unless_inside_storyboard! @out_path = path end |
#rgb(r, g = nil, b = nil) ⇒ Color
Create a new rgb Color.
123 124 125 |
# File 'lib/osb/color.rb', line 123 def rgb(r, g = nil, b = nil) Color.new(r, g, b) end |
#rotate(start_time:, end_time: start_time, easing: Easing::Linear, start_angle:, end_angle: start_angle) ⇒ void
This method returns an undefined value.
Rotate the object around its origin.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/osb/dsl/commands.rb', line 149 def rotate( start_time:, end_time: start_time, easing: Easing::Linear, start_angle:, end_angle: start_angle ) self.raise_unless_inside_object! self.current_object.rotate( start_time: start_time, end_time: end_time, easing: easing, start_angle: start_angle, end_angle: end_angle ) end |
#sample(time:, layer:, file_path:, volume: 100) ⇒ Object
Add an audio sample to the storyboard.
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/osb/dsl/object.rb', line 131 def sample(time:, layer:, file_path:, volume: 100) self.raise_unless_inside_storyboard! @storyboard << Sample.new( time: time, layer: layer, file_path: file_path, volume: volume ) end |
#scale(start_time:, end_time: start_time, easing: Easing::Linear, start_scale:, end_scale: start_scale) ⇒ void
This method returns an undefined value.
Change the size of the object relative to its original size. Will scale
seperatedly if given +Osb::Vector2+s or +Array
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/osb/dsl/commands.rb', line 125 def scale( start_time:, end_time: start_time, easing: Easing::Linear, start_scale:, end_scale: start_scale ) self.raise_unless_inside_object! self.current_object.scale( start_time: start_time, end_time: end_time, easing: easing, start_scale: start_scale, end_scale: end_scale ) end |
#sprite(layer: Layer::Background, origin: Origin::Center, file_path:, initial_position: nil) ⇒ void
This method returns an undefined value.
Create a still image.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/osb/dsl/object.rb', line 39 def sprite( layer: Layer::Background, origin: Origin::Center, file_path:, initial_position: nil ) self.raise_unless_inside_storyboard! if @sprite || @animation raise RuntimeError, "Cannot create a new sprite inside another sprite/animation." end @sprite = Sprite.new( layer: layer, origin: origin, file_path: file_path, initial_position: initial_position ) @storyboard << @sprite yield @sprite = nil end |
#storyboard ⇒ void
This method returns an undefined value.
Create an osu! storyboard.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/osb/dsl/object.rb', line 21 def storyboard if @storyboard raise RuntimeError, "Cannot create a new storyboard inside another storyboard." end @storyboard = Storyboard.new yield raise RuntimeError, "Output path is not set." unless @out_path @storyboard.generate(@out_path) @storyboard = nil end |
#trigger(on:, start_time:, end_time:, &blk) ⇒ void
This method returns an undefined value.
Add a group of commands on a specific condition.
#trigger can only be called on an empty object declaration (no commands).
Pass a block to this method call to specify which commands to run if
the condition is met.
In addition to the "implicit" player feedback via the separate
Pass/Fail layers, you can use one of several Trigger conditions
to cause a series of events to happen whenever that condition is
fulfilled within a certain time period.
Note that start_time and end_time of any commands called inside
the block become relative to the start_time and end_time of the
#trigger command.
While osu! supports trigger on hitsounds playing, we decided to not include it in because it is unreliable/unpredictable.
243 244 245 246 247 248 249 250 251 |
# File 'lib/osb/dsl/commands.rb', line 243 def trigger(on:, start_time:, end_time:, &blk) self.raise_unless_inside_object! self.current_object.trigger( on: on, start_time: start_time, end_time: end_time, &blk ) end |
#vec2(x = 0, y = 0) ⇒ Vector2
Create a 2d vector.
91 92 93 |
# File 'lib/osb/vector2.rb', line 91 def vec2(x = 0, y = 0) Vector2.new(x, y) end |
#video(file_path:, start_time:) ⇒ void
This method returns an undefined value.
Set the video for the beatmap.
120 121 122 123 124 |
# File 'lib/osb/dsl/object.rb', line 120 def video(file_path:, start_time:) self.raise_unless_inside_storyboard! @storyboard << Video.new(file_path: file_path, start_time: start_time) end |