since: 1.0.0
Oneko objects are constructed using this syntax:
new Oneko(options: OnekoOptions);since: 3.0.0
A list of animations that the Oneko can use when idle.
Default value:
[
"scratchSelf",
"scratchWallE",
"scratchWallN",
"scratchWallS",
"scratchWallW",
"sleeping"
]since: 3.0.0
The maximum distance, in pixels, that the Oneko is allowed to be from the target point before it becomes idle.
Default value: 48
since: 1.0.0
An HTMLDivElement used to represent the Oneko in the document.
Default value: HTMLDivElement
since: 1.0.0
How long the Oneko has been alive for. Measured by how many times the Oneko's element has been updated.
Default value: 0
since: 1.0.0
The idle animation that's currently playing. null means the regular idle animation of being played.
Default value: null
since: 1.0.0
The current frame of the playing idle animation.
Default value: 0
since: 1.0.0
How long the Oneko has been idle for. Measured by how many times the Oneko's element has been updated.
Default value: 0
readonly since: 2.3.0
The timestamp of the last time the Oneko's element was updated.
since: 2.2.0
Controls if onAnimationFrame() loops called after each completion of itself.
Default value: true
since: 3.0.0
The maximum number of frames the Oneko will spend in the alert state before moving towards the target point.
Default value: 7
since: 3.0.0
The number of frames the Oneko will spend in any scratching animation before the idle animation is reset.
Default value: 9
since: 3.0.0
How big the Oneko is, in pixels.
Default value: 32
since: 2.2.0
Controls if the alert animation is skipped before running begins.
Default value: false
since: 3.0.0
The number of frames the Oneko will spend in the main sleep animation before the idle animation is reset.
Default value: 192
since: 1.0.0
The path to an image file used to represent the Oneko, as a string.
Default value: "https://raw.githubusercontent.com/raynecloudy/oneko_db/refs/heads/master/default.png"
since: 1.0.0
How far the Oneko runs per update, in pixels.
Default value: 10
since: 1.0.0
A keyed list of arrays of points ([number, number]), defined as animations.
Default value:
{
idle: [[-3, -3]],
alert: [[-7, -3]],
scratchSelf: [
[-5, 0],
[-6, 0],
[-7, 0],
],
scratchWallN: [
[0, 0],
[0, -1],
],
scratchWallS: [
[-7, -1],
[-6, -2],
],
scratchWallE: [
[-2, -2],
[-2, -3],
],
scratchWallW: [
[-4, 0],
[-4, -1],
],
tired: [[-3, -2]],
sleeping: [
[-2, 0],
[-2, -1],
],
N: [
[-1, -2],
[-1, -3],
],
NE: [
[0, -2],
[0, -3],
],
E: [
[-3, 0],
[-3, -1],
],
SE: [
[-5, -1],
[-5, -2],
],
S: [
[-6, -3],
[-7, -2],
],
SW: [
[-5, -3],
[-6, -1],
],
W: [
[-4, -2],
[-4, -3],
],
NW: [
[-1, 0],
[-1, -1],
],
}since: 1.0.0
The X position the Oneko is running towards, in pixels.
Default value: 16
since: 1.0.0
The Y position the Oneko is running towards, in pixels.
Default value: 16
since: 1.0.0
How fast the Oneko updates its animations, in milliseconds.
Default value: 100
since: 1.0.0
The Oneko's element's position on the X axis, in pixels.
Default value: 16
since: 1.0.0
The Oneko's element's position on the Y axis, in pixels.
Default value: 16
since: 3.0.0
The number of frames the Oneko will spend in the tired state before entering the main sleep animation.
Default value: 8
static since: 3.0.0
Returns true if an Oneko can be initialized under current conditions. An example in which this would return false is if the prefers-reduced-motion media query is set to reduce.
since: 2.3.0
Updates the Oneko element's position and image. Fires the draw event after completion.
since: 3.0.0 throws Error if Oneko cannot be initialized.
Forces an initialized Oneko object.
since: 2.3.0
Controls all animation logic.
since: 2.3.0
Controls idle animation logic (scratching, sleeping, etc.)
since: 3.0.0
Only true if the Oneko has been properly initialized. For example, if the prefers-reduced-motion media query is set to reduce, the Oneko will not initialize.
since: 2.3.0
Sets the Oneko's target coordinates and element position.
since: 2.3.0
Runs every frame. Enables Oneko animations. timestamp is the duration since the last update.
since: 2.3.0
Resets the idle animation.
static since: 3.0.0
Constructs a complete URL path to a file of a given name on the online source database.
since: 2.3.0
Sets the coordinates for the Oneko element to be positioned at.
since: 2.1.0
Sets the source image of the Oneko element to a URL accessing the source database of Oneko PNGs (https://github.com/raynecloudy/oneko_db/).
since: 2.3.0
Sets the sprite image to a given frame of a given animation.
since: 1.0.0
Set the coordinates for the Oneko to run to. x and y are pixel values.
since: 1.1.0
Fires when the draw method is finished.
since: 2.0.0
Fires when the target coordinate becomes outside range, after alert animation plays.
since: 2.0.0
Fires when target coordinate becomes inside range.
private since: 2.3.0
Used as Oneko.prototype.setSourceDB's sourceName argument's type.
type OnekoDatabaseSource = "ace" | "black" | "bunny" | "calico" | "default" | "eevee" | "esmeralda" | "fox" | "ghost" | "gray" | "jess" | "kina" | "lucy" | "maia" | "maria" | "mike" | "silver" | "silversky" | "snuupy" | "spirit" | "tora" | "valentine";private since 2.3.0
Used as Oneko.prototype.idleAnimation's type.
type OnekoIdleAnimation = "sleeping" | "scratchSelf" | "scratchWallW" | "scratchWallN" | "scratchWallE" | "scratchWallS";private since: 2.3.0
Used as the Oneko class constructor's options argument's type.
type OnekoOptions = {
allowedIdleAnimations?: OnekoIdleAnimation[],
allowedTargetDistance?: number,
element?: HTMLDivElement | null,
frameCount?: number,
idleAnimation?: OnekoIdleAnimation,
idleAnimationFrame?: number,
idleTime?: number,
loopAnimating?: boolean,
size?: number,
skipAlertAnimation?: boolean,
skipElementInit?: boolean, // Determines if the Oneko's element has automatic styling applied to it.
source?: number,
speed?: number,
targetX?: number,
targetY?: number,
updateSpeed?: number,
x?: number,
y?: number,
};private since: 2.4.0
Used as Oneko.prototype.setSprite's setName argument's type.
type OnekoSpriteSetOptions = keyof typeof Oneko.prototype.spriteSets;