Giter Site home page Giter Site logo

glitch's Introduction

Glitch

This is a simple port of https://github.com/sug0/go-glitch to rust.

What is the deal with the expressions?

You can think of the image as a functor that you map an expression to, for each pixel's component colors, returning a new one. The allowed operators are:

Custom operators

  • t a pixel made up of a random color component from the neighboring 16 pixels
  • g a pixel made up of a random color component from random locations in the image
  • r{Num} a pixel made up of a random color component from the neighboring Num pixels
  • R{Num} the red color component defined by Num (i.e. R255 is the same as R)
  • G{Num} the green color component defined by Num (i.e. G255 is the same as G)
  • B{Num} the blue color component defined by Num (i.e. B255 is the same as B)

Ported from go-glitch

  • + plus
  • - minus
  • * multiplication
  • / division
  • % modulo
  • # power of operator
  • & bit and
  • | bit or
  • : bit and not
  • ^ bit xor
  • < bit left shift
  • > bit right shift
  • ? returns 255 if left side is greater otherwise 0
  • @ attributes a weight in the range [0, 255] to the value on the left

The expressions are made up of operators, numbers, parenthesis, and a set of parameters:

  • c the current value of each pixel component color
  • b the blurred version of c
  • h the horizontally flipped version of c
  • v the vertically flipped version of c
  • d the diagonally flipped version of c
  • Y the luminosity, or grayscale component of each pixel
  • N a noise pixel (i.e. a pixel where each component is a random value)
  • R the red color (i.e. rgb(255, 0, 0))
  • G the green color (i.e. rgb(0, 255, 0))
  • B the blue color (i.e. rgb(0, 0, 255))
  • s the value of each pixel's last saved evaluated expression
  • r a pixel made up of a random color component from the neighboring 8 pixels
  • e the difference of all pixels in a box, creating an edge-like effect
  • x the current x coordinate being evaluated normalized in the range [0, 255]
  • y the current y coordinate being evaluated normalized in the range [0, 255]
  • H the highest valued color component in the neighboring 8 pixels
  • L the lowest valued color component in the neighboring 8 pixels

Examples

  • 128 & (c - ((c - 150 + s) > 5 < s))
  • (c & (c ^ 55)) + 25
  • 128 & (c + 255) : (s ^ (c ^ 255)) + 25

glitch's People

Contributors

toyz avatar pthorpe92 avatar

Stargazers

Helehex avatar ngin avatar duck avatar Kieran Coldron avatar  avatar Tiago Carvalho avatar Jake Langford avatar RGBCube avatar  avatar

Watchers

 avatar

Forkers

sug0 pthorpe92

glitch's Issues

Add examples

README needs a few good examples. I feel like you have some really good ones already done. But maybe show the before:after with the expression/command that produced it?

feat: Display image in the terminal if available

Kitty + wezterm + wayst all support this, I'm working on a rust library to implement kitty's Terminal Graphics Protocol, so ideally we can use that and render images directly in the terminal. We can fall back on opening the image with the default OS application

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.