Skip to content

Implement filter WIP, using logos#50

Draft
Aloso wants to merge 1 commit into
mainfrom
dev
Draft

Implement filter WIP, using logos#50
Aloso wants to merge 1 commit into
mainfrom
dev

Conversation

@Aloso
Copy link
Copy Markdown
Owner

@Aloso Aloso commented Dec 12, 2020

Closes #12

Adds a filter subcommand (f for short) with advanced color editing capabilities. filter expects a list of instructions. Each instruction is either a CSS filter or a color component instruction.

Available CSS filters are:

  • brightness
  • contrast
  • grayscale
  • hue-rotate
  • invert
  • saturate
  • sepia

These filters work exactly the same as in the CSS filter property. For example, brightness 120% will increase the brightness by 20%. Note that most CSS filters use simple algorithms in the RGB color space, and may produce inadequate results. For better results, modify the color components directly in a suitable color space.

Color components are specified with the syntax <color_space>:<component>. For example, hsl:s specifies the saturation component in the HSL color space. For RGB and HSL, the color space is optional, i.e. r is equivalent to rgb:r, l is equivalent to hsl:l, and so on.

Each CSS filter name or color component is followed by a number. This number can be negative, and it can be written in percent. For color components, the value can be preceded my an operator, which is one of

  • * for multiplication (this must be escaped in some shells)
  • / for division
  • = to replace the value

Examples

# set the red component to 50, increase brightness by 20% and increase the HSV saturation component by 0.3
colo filter r=50, brightness 120%, hsv:s 0.3  -- orange blue 15A

# the above is equivalent to this:
colo filter "r = 50 brightness(120%) hsv:s+0.3"  -- orange blue 15A

As you can see, the format is whitespace insensitive and ignores commas. Values can optionally be wrapped in parentheses, to be fully compatible with the CSS syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[proposal] DSL for advanced computations

1 participant