Class Paint

Colors and gradients used in fills and lines.

Functions

tove.newLinearGradient (x0, y0, x1, y1) Create a linear gradient.
tove.newRadialGradient (cx, cy, fx, fy, r) Create a radial gradient.
tove.newShader (source) Create new custom shader.

Tables

Paint.PaintType types of paint

Fields

tove.newColor Create a new color.

Methods

Paint:addColorStop (offset, r, g, b[, a=1]) Add new color stop.
Paint:clone () Clone.
Paint:get ([opacity=1]) Get RGBA components.
Paint:getColorStop (i[, opacity=1]) Get i-th color stop.
Paint:getNumColors () Get number of colors.
Paint:getType () Query paint type.
Paint:send (k, data) Send data to custom shader.
Paint:set (r, g, b[, a=1]) Set to RGBA.


Functions

Methods
tove.newLinearGradient (x0, y0, x1, y1)
Create a linear gradient. Initially the gradient will not contain any colors. Also see SVG documentation by Mozilla.

Parameters:

  • x0 number x coordinate of start point of gradient
  • y0 number y coordinate of start point of gradient
  • x1 number x coordinate of end point of gradient
  • y1 number y coordinate of end point of gradient

See also:

tove.newRadialGradient (cx, cy, fx, fy, r)
Create a radial gradient. Initially the gradient will not contain any colors. Also see SVG documentation by Mozilla.

Parameters:

  • cx number x coordinate of the end circle
  • cy number y coordinate of the end circle
  • fx number x coordinate of the start circle
  • fy number y coordinate of the start circle
  • r number radius of end circle

See also:

tove.newShader (source)
Create new custom shader. This shader can be used as a paint in fill and line colors. Your code needs to contain a function called COLOR that takes a vec2 position and returns a vec4 color. Currently, custom shaders are only supported for the gpux display mode. Also see LÖVE's newShader.

Parameters:

  • source string shader source code

Returns:

    Paint new shader

See also:

Usage:

    fillShader = tove.newShader([[
      uniform float time;
      vec4 COLOR(vec2 pos) {
           return vec4(1, 0, sin(t), 1);
       }
    ]])

Tables

Paint.PaintType
types of paint

Fields:

  • none empty paint (transparent)
  • solid solid RGBA color
  • linear linear gradient
  • radial radial gradient
  • shader custom shader

Fields

tove.newColor
Create a new color.
  • r number red
  • g number green
  • b number blue
  • a number alpha

Methods

Paint:addColorStop (offset, r, g, b[, a=1])
Add new color stop.

Parameters:

  • offset number where to add this new color (0 <= offset <= 1)
  • r number red
  • g number green
  • b number blue
  • a number alpha (default 1)

See also:

Paint:clone ()
Clone.

Returns:

    Paint cloned Paint
Paint:get ([opacity=1])
Get RGBA components. If called on a gradient, this will not yield useful results.

Parameters:

  • opacity opacity to apply on returned color (default 1)

Returns:

  1. number red
  2. number green
  3. number blue
  4. number alpha
Paint:getColorStop (i[, opacity=1])
Get i-th color stop. Use this to retrieve gradient's colors.

Parameters:

  • i int 1-based index of color
  • opacity number to apply on returned color (default 1)

Returns:

  1. number offset (between 0 and 1)
  2. number red
  3. number green
  4. number blue
  5. number alpha

See also:

Paint:getNumColors ()
Get number of colors. Interesting for gradients only.

Returns:

    int number of colors in this paint.
Paint:getType ()
Query paint type.

Returns:

    string one of the names in Paint.PaintType
Paint:send (k, data)
Send data to custom shader. Also see LÖVE's Shader:send.

Parameters:

  • k string name of uniform
  • data ... data to send

Usage:

    shader:send("t", love.timer.getTime())
Paint:set (r, g, b[, a=1])
Set to RGBA.

Parameters:

  • r number red
  • g number green
  • b number blue
  • a number alpha (default 1)
generated by LDoc 1.4.6 Last updated 2019-04-19 11:25:52