GithubHelp home page GithubHelp logo

context-blender's People

Contributors

gingerbeardman avatar mixophrygian avatar phrogz avatar violy avatar webmechanic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

context-blender's Issues

Blend Mode Equations

Hi,

I just stumbled upon this demo, which is related to what you're doing.

They have equations for all the blend modes; see this page (pasted below). You may find this useful, since this is what you want help with.

/**
 * JavaScript implementation of common blending modes, based on
 * http://stackoverflow.com/questions/5919663/how-does-photoshop-blend-two-images-together
 *
 * Note that I'm not using <code>this</code> to reference current object
 * for faster execution
 */
var blendingModes = {
    normal: function(a, b) {
        return a;
    },

    lighten: function(a, b) {
        return (b > a) ? b : a;
    },

    darken: function(a, b) {
        return (b > a) ? a : b;
    },

    multiply: function(a, b) {
        return (a * b) / 255;
    },

    average: function(a, b) {
        return (a + b) / 2;
    },

    add: function(a, b) {
        return Math.min(255, a + b);
    },

    substract: function(a, b) {
        return (a + b < 255) ? 0 : a + b - 255;
    },

    difference: function(a, b) {
        return Math.abs(a - b);
    },

    negation: function(a, b) {
        return 255 - Math.abs(255 - a - b);
    },

    screen: function(a, b) {
        return 255 - (((255 - a) * (255 - b)) >> 8);
    },

    exclusion: function(a, b) {
        return a + b - 2 * a * b / 255;
    },

    overlay: function(a, b) {
        return b < 128
            ? (2 * a * b / 255)
            : (255 - 2 * (255 - a) * (255 - b) / 255);
    },

    softLight: function(a, b) {
        return b < 128
            ? (2 * ((a >> 1) + 64)) * (b / 255)
            : 255 - (2 * (255 - (( a >> 1) + 64)) * (255 - b) / 255);
    },

    hardLight: function(a, b) {
        return blendingModes.overlay(b, a);
    },

    colorDodge: function(a, b) {
        return b == 255 ? b : Math.min(255, ((a << 8 ) / (255 - b)));
    },

    colorBurn: function(a, b) {
        return b == 0 ? b : Math.max(0, (255 - ((255 - a) << 8 ) / b));
    },

    linearDodge: function(a, b) {
        return blendingModes.add(a, b);
    },

    linearBurn: function(a, b) {
        return blendingModes.substract(a, b);
    },

    linearLight: function(a, b) {
        return b < 128
            ? blendingModes.linearBurn(a, 2 * b)
            : blendingModes.linearDodge(a, (2 * (b - 128)));
    },

    vividLight: function(a, b) {
        return b < 128
            ? blendingModes.colorBurn(a, 2 * b)
            : blendingModes.colorDodge(a, (2 * (b - 128)));
    },

    pinLight: function(a, b) {
        return b < 128
            ? blendingModes.darken(a, 2 * b)
            : blendingModes.lighten(a, (2 * (b - 128)));
    },

    hardMix: function(a, b) {
        return blendingModes.vividLight(a, b) < 128 ? 0 : 255;
    },

    reflect: function(a, b) {
        return b == 255 ? b : Math.min(255, (a * a / (255 - b)));
    },

    glow: function(a, b) {
        return blendingModes.reflect(b, a);
    },

    phoenix: function(a, b) {
        return Math.min(a, b) - Math.max(a, b) + 255;
    }
};

blend value/percentage

This library seriously lack ability to define "how much" do I want to blend the layer.

Let's say addition: now it's doing like:

result = destination + source

What it should do:

result = destination + source * factor

where factor is a float between 0.0 and 1.0

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.