Canvas

eu.joaocosta.minart.graphics.Canvas
See theCanvas companion object
trait Canvas extends MutableSurface

Window with a canvas that can be painted.

The Canvas provides access to both rendering and input functionallity, as the input must be tied to a window

A canvas represents a window with a width * height pixels. There's also a scale variable that controls the integer scaling and a clearColor that is applied to the whole canvas when it's cleared.

Attributes

Companion
object
Graph
Supertypes
trait Surface
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

The settings applied to this canvas.

The settings applied to this canvas.

Attributes

def changeSettings(newSettings: Settings): Unit

Changes the settings applied to this canvas.

Changes the settings applied to this canvas.

Value parameters

newSettings

new canvas settings

Attributes

def clear(buffers: Set[Buffer]): Unit

Clears buffers, such as the backbuffer and keyboard inputs.

Clears buffers, such as the backbuffer and keyboard inputs.

Value parameters

buffers

set of Canvas.Buffers to be cleared

Attributes

Gets the current keyboard input.

Gets the current keyboard input.

Attributes

Returns

current keyboard input

Gets the current pointer input.

Gets the current pointer input.

Attributes

Returns

current pointer input

def redraw(): Unit

Flips buffers and redraws the screen.

Flips buffers and redraws the screen.

Attributes

Concrete methods

final def height: Int

The surface height.

The surface height.

Attributes

final def width: Int

The surface width.

The surface width.

Attributes

Inherited methods

def blit(that: Surface, blendMode: BlendMode)(x: Int, y: Int, cx: Int, cy: Int, cw: Int, ch: Int): Unit

Draws a surface on top of this surface.

Draws a surface on top of this surface.

Value parameters

blendMode

blend strategy to use

ch

clip height of the source surface

cw

clip width of the source surface

cx

leftmost pixel on the source surface

cy

topmost pixel on the source surface

that

surface to draw

x

leftmost pixel on the destination surface

y

topmost pixel on the destination surface

Attributes

Inherited from:
MutableSurface
def fill(color: Color): Unit

Fill the whole surface with a certain color.

Fill the whole surface with a certain color.

Value parameters

color

Color to fill the surface with

Attributes

Inherited from:
MutableSurface
def fillRegion(x: Int, y: Int, w: Int, h: Int, color: Color): Unit

Fill part of the surface with a certain color.

Fill part of the surface with a certain color.

Value parameters

color

Color to fill the surface with

h

region height

w

region width

x

leftmost pixel on the destination surface

y

topmost pixel on the destination surface

Attributes

Inherited from:
MutableSurface
final def getPixel(x: Int, y: Int): Option[Color]

Gets the color from the this surface. This operation can be perfomance intensive, so it might be worthwile to either use getPixels to fetch multiple pixels at the same time or to implement this operation on the application code.

Gets the color from the this surface. This operation can be perfomance intensive, so it might be worthwile to either use getPixels to fetch multiple pixels at the same time or to implement this operation on the application code.

Value parameters

x

pixel x position

y

pixel y position

Attributes

Returns

pixel color

Inherited from:
Surface
final def getPixelOrElse(x: Int, y: Int, fallback: Color): Color

Gets the color from the this surface, falling back to a default color when out of bounds. Similar to getPixel(x, y).getOrElse(fallback), but avoids an allocation.

Gets the color from the this surface, falling back to a default color when out of bounds. Similar to getPixel(x, y).getOrElse(fallback), but avoids an allocation.

Value parameters

fallback

fallback color

x

pixel x position

y

pixel y position

Attributes

Returns

pixel color

Inherited from:
Surface

Returns the pixels from this surface. This operation can be perfomance intensive, so it might be worthwile to implement this operation on the application code.

Returns the pixels from this surface. This operation can be perfomance intensive, so it might be worthwile to implement this operation on the application code.

Attributes

Returns

color matrix

Inherited from:
Surface

Modifies this surface using surface view transformations

Modifies this surface using surface view transformations

Value parameters

f

operations to apply

Attributes

Inherited from:
MutableSurface
final def putPixel(x: Int, y: Int, color: Color): Unit

Put a pixel in the surface with a certain color.

Put a pixel in the surface with a certain color.

Value parameters

color

Color to apply to the pixel

x

pixel x position

y

pixel y position

Attributes

Inherited from:
MutableSurface
final def toRamSurface(): RamSurface

Copies this surface into a new surface stored in RAM.

Copies this surface into a new surface stored in RAM.

Attributes

Inherited from:
Surface
def unsafeGetPixel(x: Int, y: Int): Color

Gets the color from the this surface in an unsafe way.

Gets the color from the this surface in an unsafe way.

This operation is unsafe: reading a out of bounds pixel has undefined behavior. You should only use this if the performance of getPixel and getPixels are not acceptable.

Value parameters

x

pixel x position

y

pixel y position

Attributes

Returns

pixel color

Inherited from:
Surface
def unsafePutPixel(x: Int, y: Int, color: Color): Unit

Puts a pixel in the surface in an unsafe way.

Puts a pixel in the surface in an unsafe way.

This operation is unsafe: writing a out of bounds pixel has undefined behavior. You should only use this if the performance of putPixel is not acceptable.

Value parameters

x

pixel x position

y

pixel y position

Attributes

Returns

pixel color

Inherited from:
MutableSurface

Returns a view over this surface.

Returns a view over this surface.

Operations performed on a view are executed in a defered fashion.

Attributes

Inherited from:
Surface

Deprecated and Inherited methods

def blit(that: Surface, mask: Option[Color])(x: Int, y: Int, cx: Int, cy: Int, cw: Int, ch: Int): Unit

Draws a surface on top of this surface.

Draws a surface on top of this surface.

Value parameters

ch

clip height of the source surface

cw

clip width of the source surface

cx

leftmost pixel on the source surface

cy

topmost pixel on the source surface

mask

color to use as a mask (pixels with this color won't be merged)

that

surface to draw

x

leftmost pixel on the destination surface

y

topmost pixel on the destination surface

Attributes

Deprecated
true
Inherited from:
MutableSurface