• Welcome to Touhou Wiki!
  • Registering is temporarily disabled. Check in our Discord server to request an account and for assistance of any kind.

Touhou Danmakufu/Functions/Drawing

From Touhou Wiki
Jump to navigation Jump to search

Drawing Functions

Functions to draw graphics.

DrawGraphic

Draw the prepared graphic. If no graphic has been loaded and/or set via the LoadGraphic and SetTexture functions respectively, nothing will be drawn. The arguments are the screen coordinates where the center of the drawn graphic will be placed.

2 Parameters
    1) x-coordinate
    2) y-coordinate

LoadGraphic

Load the graphic from the file on the memory. BMP and PNG files can be loaded. The black region (R, G, B = 0, 0, 0) is transparent, or blending can be performed when PNG's alpha values are indicated, too.

1 Parameter
    1) path of the graphic (string)

DeleteGraphic

Remove the graphic loaded on the memory.

1 Parameter
    1) path of the loaded graphic (string)

SetTexture

Set the graphic drawn by DrawGraphic.

1 Parameter
    1) path of the loaded graphic (string)

SetGraphicRect

Set the rectangular drawing region of the graphic drawn by DrawGraphic.

4 Parameters
    1) left
    2) top
    3) right
    4) bottom

SetGraphicScale

Set the scaling parameters for DrawGraphic.

2 Parameters
    1) x-scale (1 is the same size)
    2) y-scale (1 is the same size)

SetGraphicExpansion

Appears to have the same function as SetGraphicScale. May have been an old, deprecated function replaced by SetGraphicScale.

SetGraphicAngle

Set the rotation angle of the graphic drawn by DrawGraphic.

3 Parameters
    1) x-angle (0 ~ 360, not radian)
    2) y-angle (0 ~ 360)
    3) z-angle (0 ~ 360)

SetAlpha

Set the alpha value (opacity) for DrawGraphic.

1 Parameter
    1) alpha value (0 ~ 255)

SetColor

Set the blending color for DrawGraphic. SetColor(255, 255, 255); is the default color.

3 Parameters
    1) red (0 ~ 255)
    2) green (0 ~ 255)
    3) blue (0 ~ 255)

SetRenderState

Set the render type for DrawGraphic.

1 Parameter
    1) render type
        ALPHA   : alpha blend
        ADD     : additive blend
        MULTIPLY: multiplicative blend
        SUBTRACT: subtractive blend

DrawText

Draw the text. This function is very heavy.

5 Parameters
    1) drawn string
    2) x-coordinate
    3) y-coordinate
    4) character size
    5) alpha value (0 ~ 255)

SetFontColor

Set the font color for DrawText. The color can be gradated.

6 Parameters
    1) red of top (0 ~ 255)
    2) green of top (0 ~ 255)
    3) blue of top (0 ~ 255)
    4) red of bottom (0 ~ 255)
    5) green of bottom (0 ~ 255)
    6) blue of bottom (0 ~ 255)

CreateRenderTarget

Creates a render-target texture of the given size. Returns true on success.

When done with the render target, use DeleteGraphic

3 Parameters
    1) The name of the render-target texture you want to create
    2) The width of the render target to be created, must be a power of 2 (2, 4, 8, 16, 32, 64, 128, 256, ...)
    3) The height of the render target to be created, must be a power of 2

SetRenderTarget

Sets the currently active render target. Set this before drawing to draw to the specified render target.

Returns the previous render target's name.

1 Parameter
    1) The name of the render target to set active

ClearRenderTarget

Clears the given render target to ARGB (0, 0, 0, 0)

1 Parameter
    1) The name of the render target to clear (created with CreateRenderTarget)