SurfaceView

eu.joaocosta.minart.graphics.SurfaceView
See theSurfaceView companion object
final case class SurfaceView(plane: Plane, width: Int, height: Int) extends Surface

A view over a surface, stored as a plane limited by a width and height. Allows lazy operations to be applied over a surface.

This can have a performance impact. However, a new RAM surface with the operations already applied can be constructed using toRamSurface

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Surface
class Object
trait Matchable
class Any
Show all
Self type

Members list

Value members

Concrete methods

def clamped: Plane

Returns a plane that clamps this surface when out of bounds

Returns a plane that clamps this surface when out of bounds

Attributes

def clip(cx: Int, cy: Int, cw: Int, ch: Int): SurfaceView

Clips this view to a chosen rectangle

Clips this view to a chosen rectangle

Value parameters

ch

clip height

cw

clip width

cx

leftmost pixel on the surface

cy

topmost pixel on the surface

Attributes

Coflatmaps this plane with a SurfaceView => Color function. Effectively, each pixel of the new view is computed from a translated view, which can be used to implement convolutions.

Coflatmaps this plane with a SurfaceView => Color function. Effectively, each pixel of the new view is computed from a translated view, which can be used to implement convolutions.

Attributes

def contramap(f: (Int, Int) => (Int, Int)): Plane

Contramaps the positions from this surface view.

Contramaps the positions from this surface view.

Attributes

Flatmaps the inner plane of this surface view

Flatmaps the inner plane of this surface view

Attributes

Flips a surface horizontally.

Flips a surface horizontally.

Attributes

Flips a surface vertically.

Flips a surface vertically.

Attributes

Inverts a surface color.

Inverts a surface color.

Attributes

def map(f: Color => Color): SurfaceView

Maps the colors from this surface view.

Maps the colors from this surface view.

Attributes

final def overlay(that: Surface, blendMode: BlendMode)(x: Int, y: Int): SurfaceView

Overlays a surface on top of this view.

Overlays a surface on top of this view.

Similar to MutableSurface#blit, but for surface views.

Value parameters

blendMode

blend strategy to use

that

surface to overlay

x

leftmost pixel on the destination plane

y

topmost pixel on the destination plane

Attributes

Forces the surface to be computed and returns a new view. Equivalent to toRamSurface().view.

Forces the surface to be computed and returns a new view. Equivalent to toRamSurface().view.

This can be particularly useful to force the computation before a heavy coflatMap (e.g. a convolution with a large kernel) to avoid recomputing the same pixel multiple times.

Attributes

Premultiplies the color channels with the alpha channel.

Premultiplies the color channels with the alpha channel.

If this surface is going to be used multiple times, it is usually recommended to store this as a temporary surface instead of using a surface view.

Attributes

Returns a plane that repeats this surface forever

Returns a plane that repeats this surface forever

Attributes

def repeating(xTimes: Int, yTimes: Int): SurfaceView

Repeats this surface xTimes on the x axis and yTimes on the yAxis

Repeats this surface xTimes on the x axis and yTimes on the yAxis

Attributes

def scale(sx: Double, sy: Double): SurfaceView

Scales a surface.

Scales a surface.

Attributes

def scale(s: Double): SurfaceView

Scales a surface.

Scales a surface.

Attributes

Transposes a surface.

Transposes a surface.

Attributes

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

override def view: SurfaceView

Returns a view over this surface.

Returns a view over this surface.

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

Attributes

Definition Classes
def zipWith(that: Surface, f: (Color, Color) => Color): SurfaceView

Combines this view with a surface by combining their colors with the given function.

Combines this view with a surface by combining their colors with the given function.

Attributes

def zipWith(that: Plane, f: (Color, Color) => Color): SurfaceView

Combines this view with a plane by combining their colors with the given function.

Combines this view with a plane by combining their colors with the given function.

Attributes

Inherited methods

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
def getPixels(): Vector[Array[Color]]

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
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
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