LoadBitmapConvenience

doodle.algebra.LoadBitmapConvenience

Convenience methods for LoadBitmap that provide synchronous, unsafe operations.

These are convenience methods for cases where:

  • You don't want to deal with IO ceremony
  • You're in a context where throwing exceptions is acceptable
  • You need simple fallback behavior for errors

Note: The actual implementation is platform-specific due to differences in how IO is executed synchronously or asynchronously on JVM vs JS.

Attributes

Source
LoadBitmapConvenience.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def loadOrDefault[S, B](specifier: S, default: => B)(using loader: LoadBitmap[S, B]): B

Load a bitmap synchronously, returning a default value on any error.

Load a bitmap synchronously, returning a default value on any error.

This is safer than loadUnsafe as it won't throw exceptions. Useful when you have a reasonable fallback image.

Value parameters

default

the bitmap to return if loading fails (evaluated lazily)

loader

implicit LoadBitmap instance for the types

specifier

the location/identifier of the bitmap

Attributes

Returns

the loaded bitmap or the default

Source
LoadBitmapConvenience.scala
def loadOrRecover[S, B](specifier: S)(recover: PartialFunction[BitmapError, B])(using loader: LoadBitmap[S, B]): B

Load a bitmap synchronously with partial error recovery.

Load a bitmap synchronously with partial error recovery.

Allows handling specific error cases while letting others propagate. Useful when different errors require different fallback strategies.

Value parameters

loader

implicit LoadBitmap instance for the types

recover

partial function to handle specific BitmapError cases

specifier

the location/identifier of the bitmap

Attributes

Returns

the loaded bitmap or recovery result

Throws
Throwable

if the error is not handled by recover

Source
LoadBitmapConvenience.scala
def loadUnsafe[S, B](specifier: S)(using loader: LoadBitmap[S, B]): B

Load a bitmap synchronously, throwing any errors that occur.

Load a bitmap synchronously, throwing any errors that occur.

This is the simplest but most dangerous way to load a bitmap. Use when you're certain the bitmap exists and is valid.

Value parameters

loader

implicit LoadBitmap instance for the types

specifier

the location/identifier of the bitmap

Attributes

Returns

the loaded bitmap

Throws
BitmapError

if loading fails

Source
LoadBitmapConvenience.scala