Color

smile.colors.Color
See theColor companion object
final case class Color(red: Int, green: Int, blue: Int, opacity: Int = ...) extends Paint

Represents a color with RGB and opacity components. The predefined colors in smile.colors.PresetColor are plain values of this class.

Value parameters

blue

The blue component of the color, in the range [0, 255].

green

The green component of the color, in the range [0, 255].

opacity

The opacity of the color, in the range [0, 255]. Defaults to 255.

red

The red component of the color, in the range [0, 255].

Attributes

Companion
object
Source
Color.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Paint
class Object
trait Matchable
class Any
Show all

Members list

Value members

Constructors

def this(argb: Int)

Attributes

Source
Color.scala

Concrete methods

def darker: Color

Darkens the color by a default factor.

Darkens the color by a default factor.

Attributes

See also
Source
Color.scala

Checks if the color is fully opaque, with an opacity of 255.

Checks if the color is fully opaque, with an opacity of 255.

Attributes

Source
Color.scala
def lighter: Color

Lightens the color by a default factor.

Lightens the color by a default factor.

Attributes

See also
Source
Color.scala
def shadeByFactor(shadingFactorFromZeroToOne: Double): Color

Darkens the color by a specified factor.

Darkens the color by a specified factor.

Value parameters

shadingFactorFromZeroToOne

The factor to darken the color by, in the range [0, 1].

Attributes

Source
Color.scala
def shadeByPercentage(shadingFactorInPercents: Double): Color

Darkens the color by a specified percentage.

Darkens the color by a specified percentage.

Value parameters

shadingFactorInPercents

The percentage to darken the color by, in the range [0, 100].

Attributes

Source
Color.scala
def tintByFactor(tintingFactorFromZeroToOne: Double): Color

Lightens the color by a specified factor.

Lightens the color by a specified factor.

Value parameters

tintingFactorFromZeroToOne

The factor to lighten the color by, in the range [0, 1].

Attributes

Source
Color.scala
def tintByPercentage(tintingFactorInPercents: Double): Color

Lightens the color by a specified percentage.

Lightens the color by a specified percentage.

import smile.colors.PresetColor.*
import smile.pictures.*

val tints   = (0 to 80 by 20).map(percent => Blue.tintByPercentage(percent))
val squares = tints.map(tint => Rectangle(30, fillWith(tint), None))
val ramp    = squares.reduce[Element]((row, next) => row.addToRight(next))

Blue squares, each lighter than the one before

Value parameters

tintingFactorInPercents

The percentage to lighten the color by, in the range [0, 100].

Attributes

Source
Color.scala
def toARGBInt: Int

Converts the color to an ARGB integer.

Converts the color to an ARGB integer.

Attributes

Source
Color.scala

Converts the color to HSI (Hue, Saturation, Intensity) format.

Converts the color to HSI (Hue, Saturation, Intensity) format.

Attributes

Source
Color.scala
def toRGBAInt: Int

Converts the color to an RGBA integer.

Converts the color to an RGBA integer.

Attributes

Source
Color.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
Color.scala

Inherited methods

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala

Concrete fields

lazy override val averageColor: Color

The color this paint amounts to over its whole pattern. A renderer that cannot paint the pattern paints this color.

The color this paint amounts to over its whole pattern. A renderer that cannot paint the pattern paints this color.

Attributes

Source
Color.scala