RenderSpriteStateFreeShape

From OxeyeWiki

Jump to: navigation, search

video.renderSpriteStateFreeShape(spriteId, x1, y1, x2, y2, x3, y3, x4, y4[, scale[, angle[, a, r, g, b]]])

This method renders the sprite state's texture on a irregular quad that is specified by the four corner coordinates. The sprite state's hotspot will be ignored. This method can be used to flip/mirror sprites, or to perform asymetric scaling.

Parameter Expected Type Description
spriteId An integer The sprite ID.
x1 A number The x coordinate for the "upper left" corner.
y1 A number The y coordinate for the "upper left" corner.
x2 A number The x coordinate for the "upper right" corner.
y2 A number The y coordinate for the "upper right" corner.
x3 A number The x coordinate for the "lower left" corner.
y3 A number The y coordinate for the "lower left" corner.
x4 A number The x coordinate for the "lower right" corner.
y4 A number The y coordinate for the "lower right" corner.
a Optional integer The alpha component of the diffuse color. Use this to blend the sprite with the background.
r Optional integer The red pigment of the diffuse color, defaults to 255.
g Optional integer The green pigment of the diffuse color, defaults to 255.
b Optional integer The blue pigment of the diffuse color, defaults to 255.
Returns

Returns nothing.

Daisymoon Video Lib

Example


do
   -- render an *unmodified* sprite using the free shape method
   local w,h = video.getSpriteStateSize(spriteId)
   local ox,oy = video.getSpriteStateHotspot(spriteId)

   video.renderSpriteStateFreeShape(spriteId,
      x - ox,     y - oy,
      x - ox + w, y - oy,
      x - ox,     y - oy + h,
      x - ox + w, y - oy + h,
      255, 255, 255, 255)
end

do
   -- render a *mirrored* sprite using the free shape method
   local w,h = video.getSpriteStateSize(spriteId)
   local ox,oy = video.getSpriteStateHotspot(spriteId)

   -- the hotspot will need to be flipped, too
   ox = 1 - w + ox

   video.renderSpriteStateFreeShape(spriteId,
      x - ox + w, y - oy,
      x - ox,     y - oy,
      x - ox + w, y - oy + h,
      x - ox,     y - oy + h,
      255, 255, 255, 255)
end

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox