Skip to main content

Utils

SubtitleCollection

new SubtitleCollection(path: string)

Convert lyrics file into a time-text collection

  • path: full path to lyrics file. File types supported: srt, vtt, json with 3 contains an array of objects containing these 3 keys: startTime, endTime, text

Property:

  • subtitles: ISubtitle[]
interface ISubtitle { 
startTime: number
endTime: number
text: string
}

rgbToHex

function rgbToHex(r: number, g: number, b: number): string

Converts rgb color to its corresponding hex string.

parseOsuTimestamp

function parseOsuTimestamp(timestamp: string): number

Converts osu timestamp to miliseconds. osbjs calls this function under the hood.

OsbColor

new OsbColor(r: number, g: number, b: number)
  • r: red
  • g: green
  • b: blue

Only use with sprite/animation.

Instance methods

toHexString

color.toHexString(): string

Converts rgb color to its corresponding hex string.

Static methods

fromHexString

OsbColor.fromHexString(color: string): OsbColor

Create an OsbColor from a hex string

fromColor

OsbColor.fromColor(color: IColor): OsbColor

Create an OsbColor from any color object that contains r, g, b fields.

interface IColor {
r: number
g: number
b: number
}

OsbVector2

new OsbVector2(x: number, y: number)
  • x: x value of this vector
  • y: y value of this vector

Only use with sprite/animation.

Static methods

fromVector2

OsbVector2.fromVector2(v: Vector2): OsbVector2

Create an OsbVector2 from a Vector2. Helpful when u have a Vector2 returned from a calculation