Skip to content

Scripted Docs

arduano edited this page Jan 16, 2020 · 10 revisions

Please learn C# first before using this.

The IO Class

IO.LoadTexture()

Load a texture from a relative path

By default, the UV coordinates are set to loop (instead of clip), and filtering is nearest neighbor Can only be called from inside the Load() function

  • Texture LoadTexture(string path)
  • Texture LoadTexture(string path, bool linear) Linear texture filtering
  • Texture LoadTexture(string path, bool uvLoop, bool linear) Clipped UV coordinates

IO.RenderQuad()

Render a rectangle (textured or untextured)

  • RenderQuad(double left, double top, double right, double bottom, Color4 col)
  • RenderQuad(double left, double top, double right, double bottom, Color4 col, Texture tex)
  • RenderQuad(double left, double top, double right, double bottom, Color4 col, Texture tex, double uvLeft, double uvTop, double uvRight, double uvBottom)
  • RenderQuad(double left, double top, double right, double bottom, Color4 topLeft, Color4 topRight, Color4 bottomRight, Color4 bottomLeft)
  • RenderQuad(double left, double top, double right, double bottom, Color4 topLeft, Color4 topRight, Color4 bottomRight, Color4 bottomLeft, Texture tex)
  • RenderQuad(double left, double top, double right, double bottom, Color4 topLeft, Color4 topRight, Color4 bottomRight, Color4 bottomLeft, Texture tex, double uvLeft, double uvTop, double uvRight, double uvBottom)

IO.RenderShape()

Render a 4-angle shape (textured or untextured)

  • RenderShape(Vector2d v1, Vector2d v2, Vector2d v3, Vector2d v4, Color4 col)
  • RenderShape(Vector2d v1, Vector2d v2, Vector2d v3, Vector2d v4, Color4 col, Texture tex)
  • RenderShape(Vector2d v1, Vector2d v2, Vector2d v3, Vector2d v4, Color4 col, Texture tex, Vector2d uv1, Vector2d uv2, Vector2d uv3, Vector2d uv4)
  • RenderShape(Vector2d v1, Vector2d v2, Vector2d v3, Vector2d v4, Color4 topLeft, Color4 topRight, Color4 bottomRight, Color4 bottomLeft)
  • RenderShape(Vector2d v1, Vector2d v2, Vector2d v3, Vector2d v4, Color4 topLeft, Color4 topRight, Color4 bottomRight, Color4 bottomLeft, Texture tex)
  • RenderShape(Vector2d v1, Vector2d v2, Vector2d v3, Vector2d v4, Color4 topLeft, Color4 topRight, Color4 bottomRight, Color4 bottomLeft, Texture tex, Vector2d uv1, Vector2d uv2, Vector2d uv3, Vector2d uv4)

IO.SelectTextureShader()

Select a texture shader (same as the ones in the textured module)

  • SelectTextureShader(TextureShaders shader)

IO.ForceFlushBuffer()

Flush the current vertex buffers.

This should mainly be used if you are directly interacting with OpenGL (e.g. calling GL.BlendFunc())

  • ForceFlushBuffer()

The Util Class

Util.GetKeyboardLayout()

Calculate a keyboard layout (key and note positions, other metadata)

Due to how common this task is, it was placed in its own utility function

  • KeyLayout GetKeyboardLayout(int firstNote, int lastNote, KeyboardOptions options)

Util.IsBlackKey()

Checks if a key is black

  • bool IsBlackKey(int key)

Util.BlackNotesAbove()

Places black notes after white ones in the list

Loops over the list twice, first time returning only white notes, second time only black notes

  • IEnumerable<Note> BlackNotesAbove(IEnumerable<Note> notes)

Util.BlendColors()

Blends the second color above the first based on alpha

  • Color4 BlendColors(Color4 col1, Color4 col2)

Object definitions

Texture class

Describes a texture

{
    int width; // width in pixels
    int height; // height in pixels
    double aspectRatio; // (width / height)
    string path; // Relative file path
    bool linear; // linear shading (instead of nearest neighbor)
    bool looped; // looped UV coordinates
}

TextureShaders enum

Selects one of the 3 shaders

{
    Normal, // default, multiplies colors
    Inverted, // inversely multiplies (lightens) colors
    Hybrid // chooses between normal and inverted, depending on if the color is < or > 0.5
}

RenderOptions class

Describes settings of the renderer

{
    int firstKey; // first key, from the misc page
    int lastKey; // last key, from the misc page
    int renderWidth; // render width in pixels (before SSAA)
    int renderHeight; // render width in pixels (before SSAA)
    double renderAspectRatio; // (width / height)
    int renderFPS; // fps
    int renderSSAA; // ssaa
    double midiTime; // the current "time" position of the keyboard. 
    double noteScreenTime; // the note speed from the misc tab
}

KeyLayout class

The generated keyboard layout from the Util.GetKeyboardLayout function

// pos
{
    double left; // x coordinate of the left side
    double right; // x coordinate of the right side
}

// KeyLayout
{
    pos[257] keys; // positions of keys
    pos[257] notes; // positions of notes
    bool[257] blackKey; // boolean array with cache'd values from `Util.IsBlackKey()`
    int[257] keyNumber; // cache'd numbers of each key (e.g. n'th black key, n'th white key)
}

KeyboardOptions class

Describes options for keyboard layout, very similar to how layout in textured module works

{
    bool sameWidthNotes = false;

    double blackKey2setOffset = 0.3;
    double blackKey3setOffset = 0.5;
    double blackKeyScale = 0.6;

    double blackNote2setOffset = 0;
    double blackNote3setOffset = 0;
    double blackNoteScale = 1;

    double[5] advancedBlackKeyOffsets = new double[] { 0, 0, 0, 0, 0 };
}