Interface Color

Generator to generate colors.

interface Color {
    color(): string;
    hexColor(): string;
    niceColors(): string[];
    rgbColor(): number[];
    safeColor(): string;
}

Methods

  • Hue seen by the eye, returns the name of the color like red or blue.

    Returns string

    a random color

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.color.color())
    }

    Output (formatted as JSON value)

    "MediumVioletRed"
    
  • Six-digit code representing a color in the color model.

    Returns string

    a random hex color

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.color.hexColor())
    }

    Output (formatted as JSON value)

    "#bd38ac"
    
  • Attractive and appealing combinations of colors, returns an list of color hex codes.

    Returns string[]

    a random nice colors

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.color.niceColors())
    }

    Output (formatted as JSON value)

    "MediumVioletRed"
    
  • Color defined by red, green, and blue light values.

    Returns number[]

    a random rgb color

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.color.rgbColor())
    }

    Output (formatted as JSON value)

    [13,150,143]
    
  • Colors displayed consistently on different web browsers and devices.

    Returns string

    a random safe color

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.color.safeColor())
    }

    Output (formatted as JSON value)

    "black"