crossfade

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2023 License: MIT Imports: 5 Imported by: 2

README

crossfade

  • Go module for crossfading between two image files.
  • Started out as a fork of phrozen/blend.
  • Includes a blend command line utility, for mixing two images 50%/50%.

github.com/anthonysimon/bild is a more popular choice than this package.

Example use of the Go package

crossfade.Files("a.png", "b.png", "out.png", 0.5)

The last argument is a float that regulates the transition from one image to the other, where 0.0 is only "a.png", while 1.0 is only "b.png".

Screenshots

0% lemur 100% mountain

20% lemur 80% mountain

50% lemur 50% mountain

80% lemur 20% mountain

100% lemur 0% mountain

lemur

The images are from wikipedia: lemur | mountain

Blendmode examples

A B
source destination

blend add

Add

blend color

Color

blend color_burn

Color Burn

blend color_dodge

Color Dodge

blend darken

Darken

blend darker_color

Darker Color

blend difference

Difference

blend divide

Divide

blend exclusion

Exclusion

blend hard_light

Hard Light

blend hard_mix

Hard Mix

blend hue

Hue

blend lighten

Lighten

blend lighter_color

Lighter Color

blend linear_burn

Linear Burn

blend linear_dodge

Linear Dodge

blend linear_light

Linear Light

blend luminosity

Luminosity

blend multiply

Multiply

blend overlay

Overlay

blend phoenix

Phoenix

blend pin_light

Pin Light

blend reflex

Reflex

blend saturation

Saturation

blend screen

Screen

blend soft_light

Soft Light

blend substract

Substract

blend vivid_light

Vivid Light

Note that these images and blend modes are from the phrozen/blend repo that this repo was forked from.

General info

  • License: MIT
  • Version: 1.1.2

Documentation

Overview

Package crossfade implements blending mode functions between images, and some utility functions for image processing.

The fundamental part of the library is the type BlendFunc, the function is applied to each pixel where the top layer (src) overlaps the bottom layer (dst) of both given 'image' interfaces.

This library provides many of the widely used blending functions to be used either as 'mode' parameter to the Blend() primary function, or to be used individually providing two 'color' interfaces. You can implement your own blending modes and pass them into the Blend() function.

This is the list of the currently implemented blending modes:

Add, Color, Color Burn, Color Dodge, Darken, Darker Color, Difference, Divide, Exclusion, Hard Light, Hard Mix, Hue, Lighten, Lighter Color, Linear Burn, Linear Dodge, Linear Light, Luminosity, Multiply, Overlay, Phoenix, Pin Light, Reflex, Saturation, Screen, Soft Light, Substract, Vivid Light.

Index

Constants

This section is empty.

Variables

View Source
var (
	SMul = 1.0
	DMul = 1.0
)

Used by MIX and OVERLAY MIX to multiply with the source and destination color values

Functions

func BlendImage

func BlendImage(dst draw.Image, src image.Image, mode BlendFunc)

Blends src image (top layer) into dst image (bottom layer) using the BlendFunc provided by mode. BlendFunc is applied to each pixel where the src image overlaps the dst image and the result is stored in the original dst image, src image is unmutable.

func BlendNewImage

func BlendNewImage(dst, src image.Image, mode BlendFunc) image.Image

Blends src image (top layer) into dst image (bottom layer) using the BlendFunc provided by mode. BlendFunc is applied to each pixel where the src image overlaps the dst image and returns the resulting image without modifying src, or dst as they are both unmutable.

func DemosceneMix

func DemosceneMix(img1, img2 image.Image, ratio, contrast float64) image.Image

Experimental mix of two images, with a given ratio and contrast. Try ratio: 0.5 and contrast: 4.0.

func Files

func Files(inFilename1, inFilename2, outFilename string, ratio float64) error

Mixes two images with the given ratio. 0.5 is 50% of the first image and 50% of the second image. 0.1 is 10% of the first image and 90% of the second image.

Types

type BlendFunc

type BlendFunc func(dst, src color.Color) color.Color

A blend function or blend mode receives a destination color and a source color, then returns a transformation of them. Blend() function receives a BlendFunc and applies it to every pixel in the overlaping areas of two given images.

var (
	Add          BlendFunc
	Color        BlendFunc
	ColorBurn    BlendFunc
	ColorDodge   BlendFunc
	Darken       BlendFunc
	DarkerColor  BlendFunc
	Difference   BlendFunc
	Divide       BlendFunc
	Exclusion    BlendFunc
	HardLight    BlendFunc
	HardMix      BlendFunc
	Hue          BlendFunc
	Lighten      BlendFunc
	LighterColor BlendFunc
	LinearBurn   BlendFunc
	LinearDodge  BlendFunc
	LinearLight  BlendFunc
	Luminosity   BlendFunc
	Multiply     BlendFunc
	Overlay      BlendFunc
	Mix          BlendFunc
	OverlayMix   BlendFunc
	Phoenix      BlendFunc
	PinLight     BlendFunc
	Reflex       BlendFunc
	Saturation   BlendFunc
	Screen       BlendFunc
	SoftLight    BlendFunc
	Substract    BlendFunc
	VividLight   BlendFunc
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL