← back to roto on ba3a.dev

RampSwap

class RampSwap(ramps: RampSet, swaps: List<RampSwapPair>, outline: Int? = null)

The colour map of a variant's ramp swaps, applied to the base's art.

Every swap reads the original colours, so swaps never chain: swapping a to b and b to a exchanges them. A colour at step i of a swapped from ramp of length n becomes step j of the to ramp of length m: j = i when n == m, else j = (i * (m - 1) + (n - 1) / 2) / (n - 1) with integer division, and j = 0 when n = 1. Colours are compared exactly.

Parameters

ramps

the project's ramps

swaps

the ramp swaps, each source ramp once

outline

the colour the project's outline colour becomes, or null to keep it; it has no effect when ramps has no outline colour, since each ramp's darkest step is then the outline and swaps with it

Constructors

Link copied to clipboard
constructor(ramps: RampSet, swaps: List<RampSwapPair>, outline: Int? = null)

Functions

Link copied to clipboard
fun apply(raster: Raster): Raster

A new raster with every pixel passed through map; raster is not changed.

Link copied to clipboard
fun map(argb: Int): Int

The colour argb becomes: its mapped colour, or itself when it is transparent or in no swap.