Skip to content
Proyectos

larsenwork/postcss-easing-gradients

Ver en GitHub

Acerca de

Plugin de PostCSS para crear degradados lineales suaves que aproximan funciones de easing.

Otros proyectos

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
-1

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

PostCSS Easing Gradients

NPM Version NPM Monthly Downloads Build Status Dependency status
MIT License Code Style: Prettier Follow Larsenwork on Twitter

PostCSS plugin to create smooth linear-gradients that approximate easing functions. Visual examples and online editor on larsenwork.com/easing-gradients

Code Examples

.cubic-bezier {
  background: linear-gradient(to bottom, black, cubic-bezier(0.48, 0.3, 0.64, 1), transparent);
  /* => */
  background: linear-gradient(
    to bottom,
    hsl(0, 0%, 0%),
    hsla(0, 0%, 0%, 0.94505) 7.9%,
    hsla(0, 0%, 0%, 0.88294) 15.3%,
    hsla(0, 0%, 0%, 0.81522) 22.2%,
    hsla(0, 0%, 0%, 0.7426) 28.7%,
    hsla(0, 0%, 0%, 0.66692) 34.8%,
    hsla(0, 0%, 0%, 0.58891) 40.6%,
    hsla(0, 0%, 0%, 0.50925) 46.2%,
    hsla(0, 0%, 0%, 0.42866) 51.7%,
    hsla(0, 0%, 0%, 0.34817) 57.2%,
    hsla(0, 0%, 0%, 0.2693) 62.8%,
    hsla(0, 0%, 0%, 0.19309) 68.7%,
    hsla(0, 0%, 0%, 0.12126) 75.2%,
    hsla(0, 0%, 0%, 0.05882) 82.6%,
    hsla(0, 0%, 0%, 0.01457) 91.2%,
    hsla(0, 0%, 0%, 0)
  );
}

.ease {
  background: linear-gradient(green, ease, red);
  /* => */
  background: linear-gradient(
    hsl(120, 100%, 25.1%),
    hsl(88.79, 100%, 24.28%) 7.8%,
    hsl(69.81, 100%, 23.14%) 13.2%,
    hsl(53.43, 100%, 24.55%) 17.6%,
    hsl(42.52, 100%, 28.9%) 21.7%,
    hsl(34.96, 100%, 32.64%) 25.8%,
    hsl(29.1, 100%, 35.96%) 30.2%,
    hsl(24.26, 100%, 38.94%) 35.1%,
    hsl(20.14, 100%, 41.56%) 40.6%,
    hsl(16.47, 100%, 43.87%) 46.9%,
    hsl(13.13, 100%, 45.83%) 54.1%,
    hsl(10.07, 100%, 47.42%) 62.2%,
    hsl(7.23, 100%, 48.62%) 71.1%,
    hsl(4.6, 100%, 49.43%) 80.6%,
    hsl(2.16, 100%, 49.87%) 90.5%,
    hsl(0, 100%, 50%)
  );
}

.steps {
  background: linear-gradient(to right, green, steps(4, skip-none), red);
  /* => */
  background: linear-gradient(
    to right,
    hsl(120, 100%, 25.1%),
    hsl(120, 100%, 25.1%) 25%,
    hsl(42.59, 100%, 28.87%) 25%,
    hsl(42.59, 100%, 28.87%) 50%,
    hsl(21.3, 100%, 40.82%) 50%,
    hsl(21.3, 100%, 40.82%) 75%,
    hsl(0, 100%, 50%) 75%,
    hsl(0, 100%, 50%)
  );
}

.radial {
  background: radial-gradient(circle at top right, red, ease-in-out, blue);
  /* => */
  background: radial-gradient(
    circle at top right,
    hsl(0, 100%, 50%),
    hsl(353.5, 100%, 49.71%) 7.7%,
    hsl(347.13, 100%, 48.89%) 14.8%,
    hsl(341.1, 100%, 47.69%) 21%,
    hsl(335.24, 100%, 46.22%) 26.5%,
    hsl(329.48, 100%, 44.57%) 31.4%,
    hsl(323.63, 100%, 42.76%) 35.9%,
    hsl(317.56, 100%, 40.82%) 40.1%,
    hsl(310.92, 100%, 38.7%) 44.2%,
    hsl(303.81, 100%, 36.49%) 48.1%,
    hsl(296, 100%, 36.55%) 52%,
    hsl(288.73, 100%, 38.81%) 56%,
    hsl(282.14, 100%, 40.92%) 60.1%,
    hsl(276.09, 100%, 42.84%) 64.3%,
    hsl(270.27, 100%, 44.64%) 68.8%,
    hsl(264.54, 100%, 46.28%) 73.7%,
    hsl(258.7, 100%, 47.74%) 79.2%,
    hsl(252.68, 100%, 48.92%) 85.4%,
    hsl(246.32, 100%, 49.72%) 92.5%,
    hsl(240, 100%, 50%)
  );
}

Syntax

Currently a subset of the full syntax is supported:

linear-gradient(
  [ <direction>,]?
  <color>,
  <animation-timing-function>,
  <color>
)

The steps syntax is also being figured out and currently this is supported.


Usage

postcss([require('postcss-easing-gradients')])

See PostCSS Usage docs for examples for your environment.


Options

colorStops: 15

is the default. A lower number creates a more "low poly" gradient with less code but a higher risk of banding.

alphaDecimals: 5

is the default. A lower number can result in banding.

colorMode: 'lrgb'

is the default color space used for interpolation and is closest to what most browsers use. Other options are 'rgb', 'hsl', 'lab' and 'lch' as per chromajs documentation

Explorar proyectos relacionados

Cargando…