Class: Renderer

Grape2D. Renderer

new Renderer()

Renderers are used to render graphics to the screen.
Source:

Methods

appendToDOMElement(elm)

Appends the renderer to a DOM element.
Parameters:
Name Type Description
elm Element The element to append to.
Source:

end()

Commits everything to render. This method should be called once, at the end of the rendering cycle.
Source:

getDOMElement() → {Element}

Gets the renderer DOM element.
Source:
Returns:
Element
Type
Element

getHalfHeight() → {number}

Gets the half height of the renderer
Source:
Returns:
the half width
Type
number

getHalfWidth() → {number}

Gets the half width of the renderer.
Source:
Returns:
the half width
Type
number

getHeight() → {number}

Gets the renderer height
Source:
Returns:
the height
Type
number

getWidth() → {number}

Gets the renderer width.
Source:
Returns:
the width
Type
number

renderAABB(aabb, camera)

Renders the wireframe of an AABB.
Parameters:
Name Type Description
aabb Grape2D.AABB The AABB to render.
camera Grape2D.Camera The camera to transfrom the coordinates.
Source:

renderCircle(circle, camera)

Renders the wireframe of a circle.
Parameters:
Name Type Description
circle Grape2D.Circle Circle to render.
camera Grape2D.Camera The camera to transfrom the coordinates.
Source:

renderImage(image, sx, sy, sw, sh, dx, dy, dw, dh)

Renders an image to the screen
Parameters:
Name Type Description
image Image DOM image.
sx number Start x coordinate of the image to render.
sy number Start y coordinate of the image to render.
sw number Width of the image to render.
sh number Height of the image to render.
dx number Start x coordinate in the renderer, for the image.
dy number Start y coordinate in the renderer, for the image.
dw number Width of the image in the renderer.
dh number Height of the image in the renderer.
Source:

renderLineSegment(start, end, camera)

Renders a line segment to the renderer.
Parameters:
Name Type Description
start Grape2D.Vector Start position of the line.
end Grape2D.Vector End position of the line.
camera Grape2D.Camera Camera to transform the coordinates.
Source:

renderNetworkObject2D(obj, pos, camera)

Renders an network object to the renderer.
Parameters:
Name Type Description
obj Grape2D.NetworkObject2D Network object.
pos Grape2D.Vector Lerped position of the object.
camera Grape2D.Camera Camera to transform the coordinates.
Source:

renderObject2D(obj, camera)

Renders an object to the renderer.
Parameters:
Name Type Description
obj Grape2D.Object2D Object to render.
camera Grape2D.Camera Camera to transform the coordinates.
Source:

renderParticle(particle, camera)

Renders a particle to the renderer.
Parameters:
Name Type Description
particle Grape2D.Particle Particle to render.
camera Grape2D.Camera Camera to transform the coordinates.
Source:

renderPoint(point, camera)

Renders a point to the renderer.
Parameters:
Name Type Description
point Grape2D.Vector Point position.
camera Grape2D.Camera Camera to transform the coordinates.
Source:

renderPolygon(polygon, camera)

Renders the wireframe of a polygon.
Parameters:
Name Type Description
polygon Grape2D.Polygon Polygon to render.
camera Grape2D.Camera The camera to transfrom the coordinates.
Source:

renderText(text, position)

Renders text to the renderer.
Parameters:
Name Type Description
text string Text to render.
position Grape2D.Vector Top left corner of the text.
Source:

renderTexture(texture, position)

Renders a texture to a position on the renderer.
Parameters:
Name Type Description
texture Grape2D.ITexture The texture to render
position Grape2D.Vector The position to render
Source:

setFillColor(color)

Sets a new fill color.
Parameters:
Name Type Description
color string New color to use when filling.
Source:

setHeight(height)

Sets the height of the renderer and computes the half height.
Parameters:
Name Type Description
height number the new height
Source:

setStrokeColor(color)

Sets a new stroke color.
Parameters:
Name Type Description
color string New color to use when stroking.
Source:

setTextFont(font)

Sets the text font.
Parameters:
Name Type Description
font string Text font.
Source:

setWidth(width)

Sets the width of the renderer and computes the half width.
Parameters:
Name Type Description
width number the width
Source:

start()

Prepares a render cycle. This method should be called once, at the begining of the rendering cycle.
Source: