MouseDance MouseDance
MouseDance MouseDance
MouseDance User Docs powered by DocFx, DiscordFx

Search Results for

    Class GraphicsUtil

    Utility code for geometrical functions needed by Sliders, and graphical code needed by other parts of the game.

    Inheritance
    Object
    GraphicsUtil
    Namespace: MouseDance.Runtime
    Assembly: MouseDance.Runtime.dll
    Syntax
    public static class GraphicsUtil

    Fields

    AntiAliasingSmoothness

    Id of shader property AntiAliasingSmoothness. Used in SDF shaders.

    Declaration
    public static readonly int AntiAliasingSmoothness
    Field Value
    Type Description
    Int32

    AspectRatioX

    Id of shader property AspectRatioX. Used in SDF shaders.

    Declaration
    public static readonly int AspectRatioX
    Field Value
    Type Description
    Int32

    AspectRatioY

    Id of shader property AspectRatioY. Used in SDF shaders.

    Declaration
    public static readonly int AspectRatioY
    Field Value
    Type Description
    Int32

    BaseColour

    Id of shader property Base Colour. Used in SDF shaders.

    Declaration
    public static readonly int BaseColour
    Field Value
    Type Description
    Int32

    BorderColour

    Id of shader property Border Colour (when shader displays a border). Used in SDF shaders.

    Declaration
    public static readonly int BorderColour
    Field Value
    Type Description
    Int32

    CenterLineColour

    Id of shader property Center Line Colour (when shader displays a center line). Used in SDF shaders.

    Declaration
    public static readonly int CenterLineColour
    Field Value
    Type Description
    Int32

    CurvePositionCount

    Id of shader property CurvePositionCount (when shader displays a list of points as a curve). Used in SDF Curve to know how many points there are.

    Declaration
    public static readonly int CurvePositionCount
    Field Value
    Type Description
    Int32

    CurvePositions

    Id of shader property CurvePositions (when shader displays a list of points as a curve). Used in SDF Curve when structured buffers are supported. This is for passing a list of Vector2 to the shader.

    Declaration
    public static readonly int CurvePositions
    Field Value
    Type Description
    Int32

    CurvePositionsX

    Id of shader property CurvePositionsX (when shader displays a list of points as a curve). Used in SDF Curve when structured buffers are not available. This is for passing a float array of a Vector2's x-coordinate to the shader.

    Declaration
    public static readonly int CurvePositionsX
    Field Value
    Type Description
    Int32

    CurvePositionsY

    Id of shader property CurvePositionsY (when shader displays a list of points as a curve). Used in SDF Curve when structured buffers are not available. This is for passing a float array of a Vector2's y-coordinate to the shader.

    Declaration
    public static readonly int CurvePositionsY
    Field Value
    Type Description
    Int32

    CurveShowPercent

    Id of shader property Curve Show Percent (when shader displays a list of points as a curve). Used in SDF Curve.

    Declaration
    public static readonly int CurveShowPercent
    Field Value
    Type Description
    Int32

    LineEndPositionX

    Id of shader property LineEndPositionX. Used in SDF shaders.

    Declaration
    public static readonly int LineEndPositionX
    Field Value
    Type Description
    Int32

    LineEndPositionY

    Id of shader property LineEndPositionY. Used in SDF shaders.

    Declaration
    public static readonly int LineEndPositionY
    Field Value
    Type Description
    Int32

    LineMid1PositionX

    Id of shader property LineMid1PositionX. Used in SDF Lines.

    Declaration
    public static readonly int LineMid1PositionX
    Field Value
    Type Description
    Int32

    LineMid1PositionY

    Id of shader property LineMid1PositionY. Used in SDF Lines.

    Declaration
    public static readonly int LineMid1PositionY
    Field Value
    Type Description
    Int32

    LineMid2PositionX

    Id of shader property LineMid2PositionX. Used in SDF Lines.

    Declaration
    public static readonly int LineMid2PositionX
    Field Value
    Type Description
    Int32

    LineMid2PositionY

    Id of shader property LineMid2PositionY. Used in SDF Lines.

    Declaration
    public static readonly int LineMid2PositionY
    Field Value
    Type Description
    Int32

    LineStartPositionX

    Id of shader property LineStartPositionX. Used in SDF shaders.

    Declaration
    public static readonly int LineStartPositionX
    Field Value
    Type Description
    Int32

    LineStartPositionY

    Id of shader property LineStartPositionY. Used in SDF shaders.

    Declaration
    public static readonly int LineStartPositionY
    Field Value
    Type Description
    Int32

    LineThickness

    Id of shader property Line Thickness. Used in SDF shaders.

    Declaration
    public static readonly int LineThickness
    Field Value
    Type Description
    Int32

    Opacity

    Id of shader property Opacity. Used in SDF shaders.

    Declaration
    public static readonly int Opacity
    Field Value
    Type Description
    Int32

    OriginX

    Id of shader property OriginX. Used in SDF shaders.

    Declaration
    public static readonly int OriginX
    Field Value
    Type Description
    Int32

    OriginY

    Id of shader property OriginY. Used in SDF shaders.

    Declaration
    public static readonly int OriginY
    Field Value
    Type Description
    Int32

    OSU_PIXELS_CENTER_X

    X-axis center of a 640x480 screen.

    Declaration
    public const float OSU_PIXELS_CENTER_X = 256F
    Field Value
    Type Description
    Single

    OSU_PIXELS_CENTER_Y

    Y-axis center of a 640x480 screen.

    Declaration
    public const float OSU_PIXELS_CENTER_Y = 192F
    Field Value
    Type Description
    Single

    OSU_PIXELS_HEIGHT

    Height of the 640x480 screen.

    Declaration
    public const float OSU_PIXELS_HEIGHT = 480F
    Field Value
    Type Description
    Single

    OSU_PIXELS_WIDTH

    Width of the 640x480 screen.

    Declaration
    public const float OSU_PIXELS_WIDTH = 640F
    Field Value
    Type Description
    Single

    OuterBaseColour

    Id of shader property Outer Base Colour (when shader can do gradient between Base Colour and Outer Base Colour). Used in SDF shaders.

    Declaration
    public static readonly int OuterBaseColour
    Field Value
    Type Description
    Int32

    ScreenScale

    Id of shader property ScreenScale. Used in SDF shaders.

    Declaration
    public static readonly int ScreenScale
    Field Value
    Type Description
    Int32

    Methods

    Add(Gradient, Color32)

    Combine a Gradient's start and end values additively with a Color32. This brings the result closer to white.

    Declaration
    public static Gradient Add(this Gradient g, Color32 c)
    Parameters
    Type Name Description
    Gradient g
    Color32 c
    Returns
    Type Description
    Gradient

    A new Gradient of the combined value.

    Add(Color32, Color32)

    Combine two Color32s additively. This brings the result closer to white.

    Declaration
    public static Color32 Add(this Color32 c1, Color32 c2)
    Parameters
    Type Name Description
    Color32 c1
    Color32 c2
    Returns
    Type Description
    Color32

    A new Color32 of the combined value.

    CreateBezier(List<Vector2>, Int32, List<Vector2>)

    Create an N-order bezier curve and store it in a list of Vector2.

    Declaration
    public static void CreateBezier(List<Vector2> resultingPoints, int positionCount, List<Vector2> points)
    Parameters
    Type Name Description
    List<Vector2> resultingPoints

    Where the points of the resulting bezier curve is stored in.

    Int32 positionCount

    How many points you want the resulting curve to have. More points means smoother curve.

    List<Vector2> points

    Control points for the curve, in world-space.

    Remarks

    Based on https://stackoverflow.com/a/31169371

    CreateBezier(List<Vector3>, Int32, List<Vector2>)

    Create an N-order bezier curve and store it in a list of Vector3.

    Declaration
    public static void CreateBezier(List<Vector3> resultingPoints, int positionCount, List<Vector2> points)
    Parameters
    Type Name Description
    List<Vector3> resultingPoints

    Where the points of the resulting bezier curve is stored in. Values will be in the X and Y. Z will be set to 0.

    Int32 positionCount

    How many points you want the resulting curve to have. More points means smoother curve.

    List<Vector2> points

    Control points for the curve, in world-space.

    Remarks

    Based on https://stackoverflow.com/a/31169371

    Equal(Color32, Byte, Byte, Byte)

    Check if the specified Color32 is equal to the specific r, g, b values. Alpha value is ignored.

    Declaration
    public static bool Equal(this Color32 a, byte br, byte bg, byte bb)
    Parameters
    Type Name Description
    Color32 a

    Color32 to check.

    Byte br

    0 - 255 red value to compare against.

    Byte bg

    0 - 255 green value to compare against.

    Byte bb

    0 - 255 blue value to compare against.

    Returns
    Type Description
    Boolean

    Returns true if color's values match the 0-255 values specified.

    EqualBlack(Color32)

    Check if the specified Color32 is black (0, 0, 0). Alpha value is ignored.

    Declaration
    public static bool EqualBlack(this Color32 a)
    Parameters
    Type Name Description
    Color32 a
    Returns
    Type Description
    Boolean

    Returns true if color is black.

    GetCircleCenterFromPoints(Vector2, Vector2, Vector2)

    Find a circle's center and radius, given 3 points found on its circumference. It doesn't matter if the 3 points are not sorted in any way, as long as they are all points on the circle's circumference.

    Declaration
    public static (Vector2 center, float radius) GetCircleCenterFromPoints(Vector2 p1, Vector2 p2, Vector2 p3)
    Parameters
    Type Name Description
    Vector2 p1

    First point on the circle's circumference.

    Vector2 p2

    Second point on the circle's circumference.

    Vector2 p3

    Third point on the circle's circumference.

    Returns
    Type Description
    (T1, T2)<Vector2, Single>
    Remarks

    Based on https://stackoverflow.com/a/22792054 Note: Explanation of answer in StackOverflow does square of a binomial, and Cramer's Rule (2x2 linear system).

    MakeArc(List<Vector2>, Int32, Single, Vector3, Vector3, Vector3, Boolean)

    Create a circular arc based on a center point, and a start and end point on the circumference. This stores the result in a list of Vector2.

    Declaration
    public static void MakeArc(List<Vector2> resultingPoints, int positionCount, float radius, Vector3 centerPos, Vector3 startPt, Vector3 endPt, bool append = false)
    Parameters
    Type Name Description
    List<Vector2> resultingPoints

    Where the resulting points of the arc will be stored.

    Int32 positionCount

    How many points you want the resulting arc to have. More points means smoother arc.

    Single radius

    Radius of the arc.

    Vector3 centerPos

    Center point of the arc.

    Vector3 startPt

    A point that lies on the circumference of the arc where you want it to start.

    Vector3 endPt

    A point that lies on the circumference of the arc where you want it to end.

    Boolean append

    Whether you want the result appended to the resultingPoints list, or if you want to clear that list first.

    MakeArc(List<Vector2>, Int32, Vector2, Vector2, Vector2)

    Create a circular arc, given 3 points found on its circumference. This stores the result in a list of Vector2.

    Declaration
    public static void MakeArc(List<Vector2> resultingPoints, int positionCount, Vector2 startPt, Vector2 midPt, Vector2 endPt)
    Parameters
    Type Name Description
    List<Vector2> resultingPoints

    Where the resulting points of the arc will be stored.

    Int32 positionCount

    How many points you want the resulting arc to have. More points means smoother arc.

    Vector2 startPt

    A point that lies on the circumference of the arc where you want it to start.

    Vector2 midPt

    A point that lies on the circumference of the arc that is between the startPt and endPt.

    Vector2 endPt

    A point that lies on the circumference of the arc where you want it to end.

    MakeArc(List<Vector3>, Int32, Single, Vector3, Vector3, Vector3, Boolean)

    Create a circular arc based on a center point, and a start and end point on the circumference. This stores the result in a list of Vector3.

    Declaration
    public static void MakeArc(List<Vector3> resultingPoints, int positionCount, float radius, Vector3 centerPos, Vector3 startPt, Vector3 endPt, bool append = false)
    Parameters
    Type Name Description
    List<Vector3> resultingPoints

    Where the resulting points of the arc will be stored. Values will be in the X and Y. Z will be set to 0.

    Int32 positionCount

    How many points you want the resulting arc to have. More points means smoother arc.

    Single radius

    Radius of the arc.

    Vector3 centerPos

    Center point of the arc.

    Vector3 startPt

    A point that lies on the circumference of the arc where you want it to start.

    Vector3 endPt

    A point that lies on the circumference of the arc where you want it to end.

    Boolean append

    Whether you want the result appended to the resultingPoints list, or if you want to clear that list first.

    MakeArc(List<Vector3>, Int32, Vector2, Vector2, Vector2)

    Create a circular arc, given 3 points found on its circumference. This stores the result in a list of Vector3.

    Declaration
    public static void MakeArc(List<Vector3> resultingPoints, int positionCount, Vector2 startPt, Vector2 midPt, Vector2 endPt)
    Parameters
    Type Name Description
    List<Vector3> resultingPoints

    Where the resulting points of the arc will be stored. Values will be in the X and Y. Z will be set to 0.

    Int32 positionCount

    How many points you want the resulting arc to have. More points means smoother arc.

    Vector2 startPt

    A point that lies on the circumference of the arc where you want it to start.

    Vector2 midPt

    A point that lies on the circumference of the arc that is between the startPt and endPt.

    Vector2 endPt

    A point that lies on the circumference of the arc where you want it to end.

    NormalizedPingPong(Single)

    Returns value that linearly goes from 0.0 to 1.0, then back to 0.0. Input t is expected to go from 0.0 to 1.0.

    Declaration
    public static float NormalizedPingPong(float t)
    Parameters
    Type Name Description
    Single t
    Returns
    Type Description
    Single

    ScalePointFromCenter(Vector2, Single)

    Move point nearer or farther from center of screen, assuming the screen has a size of 640x480.

    Declaration
    public static Vector2 ScalePointFromCenter(this Vector2 point, float scale)
    Parameters
    Type Name Description
    Vector2 point

    The point to be scaled.

    Single scale

    Multiplier on the point. 1.0 leaves the value unchanged. 2.0 places the point twice as far from the center. 0.5 places the point nearer the center, about halfway from its original position. etc.

    Returns
    Type Description
    Vector2

    A new Vector2 of the scaled value.

    SetAlpha(Graphic, Single)

    Simple quick way to set a Unity UI Graphic's alpha, while keeping the rest of the colour the same.

    Declaration
    public static void SetAlpha(this Graphic i, float newAlpha)
    Parameters
    Type Name Description
    UnityEngine.UI.Graphic i

    Graphic component to edit.

    Single newAlpha

    New alpha value to be given.