Difference between revisions of "User:Flying Jester/SpriteBatch API"

From Spherical
Jump to: navigation, search
(Created page with "This page is draft of the SpriteBatch API for TurboSphere. ==Variables== *POINT *LINE *TRIANGLE *RECTANGLE *POLYGON *CIRCLE *FILLED *OUTLINED *GRADIENT *OUTLINED_GRADIENT *B...")
 
 
(3 intermediate revisions by the same user not shown)
Line 22: Line 22:
  
 
* SpriteBatch()
 
* SpriteBatch()
; Creates a new SpriteBatch object.
+
:: Creates a new SpriteBatch object.
 +
 
 +
==Functions==
  
 
* spritebatch.addTexture(tex)
 
* spritebatch.addTexture(tex)
; Clones 'tex' into one of the spritebatch's buffers. 'tex' can be a Surface or Image. Any modifications to 'tex' after being cloned are not reflected by the copy in 'spritebatch'.
+
:: Clones 'tex' into one of the spritebatch's buffers. 'tex' can be a Surface or Image. Any modifications to 'tex' after being cloned are not reflected by the copy in 'spritebatch'.
 +
 
 +
* spritebatch.getImages()
 +
:: Returns an array of added [[API:Image|images]] or surfaces (which are converted to images by adding them to the spritebatch) held in the buffer(s) of 'spritebatch'. These can be blit to the screen.
 +
 
 +
* spritebatch.pushTexture(tex, mode, ..., ['', [[API:Color|mask]]''])
 +
:: Pushes a texture drawing operation for 'spritebatch' to perform when it draws. 'tex' is the index of the texture to draw. 'mode' can be:
 +
 
 +
*# BLIT
 +
*# ROTATE_BLIT
 +
*# ZOOM_BLIT
 +
*# STRETCH_BLIT
 +
*# TRANSFORM_BLIT
 +
 
 +
:: Function signatures are:
 +
 
 +
*#* spritebatch.pushTexture(tex, BLIT, x, y, ['', [[API:Color|mask]]''])
 +
*#* spritebatch.pushTexture(tex, ROTATE_BLIT, x, y, a ['', [[API:Color|mask]]''])
 +
*#* spritebatch.pushTexture(tex, ZOOM_BLIT, x, y, f ['', [[API:Color|mask]]''])
 +
*#* spritebatch.pushTexture(tex, STRETCH_BLIT, x, y, xf, yf ['', [[API:Color|mask]]''])
 +
*#* spritebatch.pushTexture(tex, TRANSFORM_BLIT, x1, y1, x2, y2, x3, y3, x4, y4 ['', [[API:Color|mask]]''])
 +
 
 +
 
 +
* spritebatch.insertTexture(index, tex, mode, ..., ['', [[API:Color|mask]]''])
 +
:: Same as pushTexture, but inserts operation at 'index' in the list of operations to perform.
  
* spritebatch.addOperation(primitive, type, ...)
+
* spritebatch.pushPrimitiveOperation(primitive, type, ...)
; Adds an operation to 'spritebatch'. Primitives can be
+
:: Adds a primitive operation to the list of operations 'spritebatch' will perform when draw() is called. Primitives can be
  
 
*# POINT
 
*# POINT
Line 37: Line 63:
 
*# CIRCLE
 
*# CIRCLE
  
;Types can be
+
:: Types can be
  
 
*# FILLED
 
*# FILLED
Line 44: Line 70:
 
*# OUTLINED_GRADIENT
 
*# OUTLINED_GRADIENT
  
;Function signatures are:
+
:: Function signatures are:
  
*#* spritebatch.addOperation(POINT, type, x, y, [[API:Color|color]] ...)
+
*#* spritebatch.addPrimitiveOperation(POINT, type, x, y, [[API:Color|color]] ...)
*#* spritebatch.addOperation(LINE, type, x1, y1, x2, y2, [[API:Color|color]] ...)
+
*#* spritebatch.addPrimitiveOperation(LINE, type, x1, y1, x2, y2, [[API:Color|color]] ...)
*#* spritebatch.addOperation(TRIANGLE, type, x1, y1, x2, y2,  x3, y3, [[API:Color|color]] ...)
+
*#* spritebatch.addPrimitiveOperation(TRIANGLE, type, x1, y1, x2, y2,  x3, y3, [[API:Color|color]] ...)
*#* spritebatch.addOperation(RECTANGLE, type, x, y, w, h [[API:Color|color]] ...)
+
*#* spritebatch.addPrimitiveOperation(RECTANGLE, type, x, y, w, h [[API:Color|color]] ...)
*#* spritebatch.addOperation(POLYGON, type, xs, ys, [[API:Color|color]] ...)
+
*#* spritebatch.addPrimitiveOperation(POLYGON, type, xs, ys, [[API:Color|color]] ...)
*#* spritebatch.addOperation(CIRCLE, type, x, y, r, [[API:Color|color]] ...)
+
*#* spritebatch.addPrimitiveOperation(CIRCLE, type, x, y, r, [[API:Color|color]] ...)
  
;'color' is defined by 'type'.
+
::'color' is defined by 'type'.
  
 
*#* FILLED or OUTLINED: one color.
 
*#* FILLED or OUTLINED: one color.
 
*#* GRADIENT or OUTLINED_GRADIENT: one color argument for each vertex.
 
*#* GRADIENT or OUTLINED_GRADIENT: one color argument for each vertex.
  
* spritebatch.getImages()
+
* spritebatch.insertPrimitiveOperation(index, primitive, type, ...)
; Returns an array of added [[API:Image|images]] or surfaces (which are converted to images by adding them to the spritebatch) held in the buffer(s) of 'spritebatch'. These can be blit to the screen.
+
:: Same as pushOperation, but inserts the operation at 'index' in the list.
 +
 
 +
* spritebatch.popOperation()
 +
:: Removes the last operation from 'spritebatch'.
 +
 
 +
* spritebatch.spliceOperation(index ['', num''])
 +
:: Removes operation at 'index'. If 'num' is specified, removes 'num' operations starting at 'index'. If 'index' is negative, it is treated as that many items from the end of the operation list. If 'num' is negative, 'num' operations preceding 'index' are removed.
  
* spritebatch.getOperations()
+
===Drawing Control===
; Returns an array of added drawing operations.
 
  
* spritebatch.pushTexture(tex, mode, ..., [', [[API:Color|mask]]'])
+
* spritebatch.draw()
; Pushes a texture drawing operation for 'spritebatch' to perform when it draws. 'tex' is the index of the texture to draw. 'mode' can be:
+
:: Draws 'spritebatch'. All operations in its list will be performed.
  
*# BLIT
+
* spritebatch.setOffset(x, y)
*# ROTATE_BLIT
+
::Specifies an offset for drawing 'spritebatch'.
*# ZOOM_BLIT
 
*# STRETCH_BLIT
 
*# TRANSFORM_BLIT
 
  
;Function signatures are:
+
* spritebatch.setRotation(a)
 +
::Sets a rotation angle for 'spritebatch'
  
*#* spritebatch.pushTexture(tex, BLIT, x, y, [', [[API:Color|mask]]'])
+
* spritebatch.setScale(f)
*#* spritebatch.pushTexture(tex, ROTATE_BLIT, x, y, a [', [[API:Color|mask]]'])
+
::Sets a scaling factor for 'spritebatch'
*#* spritebatch.pushTexture(tex, ZOOM_BLIT, x, y, f [', [[API:Color|mask]]'])
 
*#* spritebatch.pushTexture(tex, STRETCH_BLIT, x, y, xf, yf [', [[API:Color|mask]]'])
 
*#* spritebatch.pushTexture(tex, TRANSFORM_BLIT, x1, y1, x2, y2, x3, y3, x4, y4 [', [[API:Color|mask]]'])
 

Latest revision as of 19:30, 25 November 2013

This page is draft of the SpriteBatch API for TurboSphere.

Variables

  • POINT
  • LINE
  • TRIANGLE
  • RECTANGLE
  • POLYGON
  • CIRCLE
  • FILLED
  • OUTLINED
  • GRADIENT
  • OUTLINED_GRADIENT
  • BLIT
  • ROTATE_BLIT
  • ZOOM_BLIT
  • STRETCH_BLIT
  • TRANSFORM_BLIT

Objects

  • SpriteBatch()
Creates a new SpriteBatch object.

Functions

  • spritebatch.addTexture(tex)
Clones 'tex' into one of the spritebatch's buffers. 'tex' can be a Surface or Image. Any modifications to 'tex' after being cloned are not reflected by the copy in 'spritebatch'.
  • spritebatch.getImages()
Returns an array of added images or surfaces (which are converted to images by adding them to the spritebatch) held in the buffer(s) of 'spritebatch'. These can be blit to the screen.
  • spritebatch.pushTexture(tex, mode, ..., [, mask])
Pushes a texture drawing operation for 'spritebatch' to perform when it draws. 'tex' is the index of the texture to draw. 'mode' can be:
    1. BLIT
    2. ROTATE_BLIT
    3. ZOOM_BLIT
    4. STRETCH_BLIT
    5. TRANSFORM_BLIT
Function signatures are:
      • spritebatch.pushTexture(tex, BLIT, x, y, [, mask])
      • spritebatch.pushTexture(tex, ROTATE_BLIT, x, y, a [, mask])
      • spritebatch.pushTexture(tex, ZOOM_BLIT, x, y, f [, mask])
      • spritebatch.pushTexture(tex, STRETCH_BLIT, x, y, xf, yf [, mask])
      • spritebatch.pushTexture(tex, TRANSFORM_BLIT, x1, y1, x2, y2, x3, y3, x4, y4 [, mask])


  • spritebatch.insertTexture(index, tex, mode, ..., [, mask])
Same as pushTexture, but inserts operation at 'index' in the list of operations to perform.
  • spritebatch.pushPrimitiveOperation(primitive, type, ...)
Adds a primitive operation to the list of operations 'spritebatch' will perform when draw() is called. Primitives can be
    1. POINT
    2. LINE
    3. TRIANGLE
    4. RECTANGLE
    5. POLYGON
    6. CIRCLE
Types can be
    1. FILLED
    2. OUTLINED
    3. GRADIENT
    4. OUTLINED_GRADIENT
Function signatures are:
      • spritebatch.addPrimitiveOperation(POINT, type, x, y, color ...)
      • spritebatch.addPrimitiveOperation(LINE, type, x1, y1, x2, y2, color ...)
      • spritebatch.addPrimitiveOperation(TRIANGLE, type, x1, y1, x2, y2, x3, y3, color ...)
      • spritebatch.addPrimitiveOperation(RECTANGLE, type, x, y, w, h color ...)
      • spritebatch.addPrimitiveOperation(POLYGON, type, xs, ys, color ...)
      • spritebatch.addPrimitiveOperation(CIRCLE, type, x, y, r, color ...)
'color' is defined by 'type'.
      • FILLED or OUTLINED: one color.
      • GRADIENT or OUTLINED_GRADIENT: one color argument for each vertex.
  • spritebatch.insertPrimitiveOperation(index, primitive, type, ...)
Same as pushOperation, but inserts the operation at 'index' in the list.
  • spritebatch.popOperation()
Removes the last operation from 'spritebatch'.
  • spritebatch.spliceOperation(index [, num])
Removes operation at 'index'. If 'num' is specified, removes 'num' operations starting at 'index'. If 'index' is negative, it is treated as that many items from the end of the operation list. If 'num' is negative, 'num' operations preceding 'index' are removed.

Drawing Control

  • spritebatch.draw()
Draws 'spritebatch'. All operations in its list will be performed.
  • spritebatch.setOffset(x, y)
Specifies an offset for drawing 'spritebatch'.
  • spritebatch.setRotation(a)
Sets a rotation angle for 'spritebatch'
  • spritebatch.setScale(f)
Sets a scaling factor for 'spritebatch'