src/boxy

Search:
Group by:
Source   Edit  

Types

Boxy = ref object
  ## Index into layer textures for writing.
  ## Layers array for pushing and popping.
  ## Size x size dimensions of the atlas.
  ## Number of quads drawn so far in this batch.
  ## Max quads in a batch before issuing an OpenGL call.
  ## The current matrix.
  ## The matrix stack.
  ## Entires used by not flushed yet.
  ## Flag for if the tile is taken or not.
  ## Dimensions of the window frame.
  
Source   Edit  
BoxyError = object of ValueError
Source   Edit  

Procs

proc addImage(boxy: Boxy; key: string; image: Image; genMipmaps = true) {.
    ...raises: [BoxyError, KeyError, PixieError, GLerror, Exception, ValueError],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc applyTransform(boxy: Boxy; m: Mat3) {....raises: [], tags: [], forbids: [].}
Applies transform to the internal transform. Source   Edit  
proc beginFrame(boxy: Boxy; frameSize: IVec2; clearFrame = true) {.inline,
    ...raises: [BoxyError, GLerror], tags: [], forbids: [].}
Source   Edit  
proc beginFrame(boxy: Boxy; frameSize: IVec2; proj: Mat4; clearFrame = true) {.
    ...raises: [BoxyError, GLerror], tags: [], forbids: [].}
Starts a new frame. Source   Edit  
proc blurEffect(boxy: Boxy; radius: float32) {.
    ...raises: [BoxyError, GLerror, Exception, ValueError], tags: [], forbids: [].}
Blurs the current layer Source   Edit  
proc clearAtlas(boxy: Boxy) {....raises: [PixieError, GLerror], tags: [],
                              forbids: [].}
Source   Edit  
proc clearTransform(boxy: Boxy) {....raises: [], tags: [], forbids: [].}
Clears transform and transform stack. Source   Edit  
proc contains(boxy: Boxy; key: string): bool {.inline, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc drawImage(boxy: Boxy; key: string; center: Vec2; angle: float32;
               tint = color(1, 1, 1, 1); scale: float32 = 1.0) {.
    ...raises: [KeyError, GLerror, Exception, ValueError], tags: [], forbids: [].}
Draws image at center and rotated by angle. The image should have already been added. Source   Edit  
proc drawImage(boxy: Boxy; key: string; pos: Vec2; tint = color(1, 1, 1, 1)) {.
    ...raises: [KeyError, GLerror, Exception, ValueError], tags: [], forbids: [].}
Draws image at pos from top-left. The image should have already been added. Source   Edit  
proc drawImage(boxy: Boxy; key: string; rect: Rect; tint = color(1, 1, 1, 1)) {.
    ...raises: [KeyError, GLerror, Exception, ValueError], tags: [], forbids: [].}
Draws image at filling the ract. The image should have already been added. Source   Edit  
proc drawRect(boxy: Boxy; rect: Rect; color: Color) {.
    ...raises: [GLerror, Exception, ValueError], tags: [], forbids: [].}
Source   Edit  
proc dropShadowEffect(boxy: Boxy; tint: Color; offset: Vec2;
                      radius, spread: float32) {.
    ...raises: [BoxyError, GLerror, Exception, ValueError], tags: [], forbids: [].}
Drop shadows the current layer Source   Edit  
proc endFrame(boxy: Boxy) {....raises: [BoxyError, GLerror, Exception, ValueError],
                            tags: [], forbids: [].}
Ends a frame. Source   Edit  
proc flush(boxy: Boxy) {....raises: [GLerror, Exception, ValueError], tags: [],
                         forbids: [].}
Flips - draws current buffer and starts a new one. Source   Edit  
proc fromScreen(boxy: Boxy; windowFrame: Vec2; v: Vec2): Vec2 {....raises: [],
    tags: [], forbids: [].}
Takes a point from screen and translates it to point inside the current transform. Source   Edit  
proc getImage(boxy: Boxy; bounds: Rect): Image {.
    ...raises: [BoxyError, PixieError, GLerror], tags: [], forbids: [].}
Gets an Image rectangle from the current layer. Note: This is very close because it transfers GPU data to CPU. It's not recommended to use this in a game loop. Source   Edit  
proc getImageSize(boxy: Boxy; key: string): IVec2 {....raises: [KeyError],
    tags: [], forbids: [].}
Return the size of an inserted image. Source   Edit  
proc getTransform(boxy: Boxy): Mat3 {....raises: [], tags: [], forbids: [].}
Gets the internal transform. Source   Edit  
proc newBoxy(atlasSize = 512; tileSize = 32 - 2; quadsPerBatch = 1024): Boxy {.
    ...raises: [BoxyError, GLerror, ValueError, Exception, PixieError], tags: [],
    forbids: [].}
Creates a new Boxy. Source   Edit  
proc popLayer(boxy: Boxy; tint = color(1, 1, 1, 1);
              blendMode: BlendMode = NormalBlend) {.
    ...raises: [BoxyError, GLerror, Exception, ValueError], tags: [], forbids: [].}
Pops the layer and draws with tint and blend. Source   Edit  
proc pushLayer(boxy: Boxy) {....raises: [BoxyError, GLerror, Exception, ValueError],
                             tags: [], forbids: [].}
Starts drawing into a new layer. Source   Edit  
proc readAtlas(boxy: Boxy): Image {....raises: [PixieError, GLerror], tags: [],
                                    forbids: [].}
Read the current atlas content. Source   Edit  
proc removeImage(boxy: Boxy; key: string) {....raises: [BoxyError, KeyError],
    tags: [], forbids: [].}
Removes an image, does nothing if the image has not been added. Source   Edit  
proc restoreTransform(boxy: Boxy) {....raises: [], tags: [], forbids: [].}
Pops a transform off the stack. Source   Edit  
proc rotate(boxy: Boxy; angle: float32) {....raises: [], tags: [], forbids: [].}
Rotates the internal transform. Source   Edit  
proc saveTransform(boxy: Boxy) {....raises: [], tags: [], forbids: [].}
Pushes a transform onto the stack. Source   Edit  
proc scale(boxy: Boxy; scale: float32) {.inline, ...raises: [], tags: [],
    forbids: [].}
Scales the internal transform. Source   Edit  
proc scale(boxy: Boxy; scale: Vec2) {....raises: [], tags: [], forbids: [].}
Scales the internal transform. Source   Edit  
proc setTransform(boxy: Boxy; m: Mat3) {....raises: [], tags: [], forbids: [].}
Sets the internal transform. Source   Edit  
proc toScreen(boxy: Boxy; windowFrame: Vec2; v: Vec2): Vec2 {....raises: [],
    tags: [], forbids: [].}
Takes a point from current transform and translates it to screen. Source   Edit  
proc translate(boxy: Boxy; v: Vec2) {....raises: [], tags: [], forbids: [].}
Translate the internal transform. Source   Edit