crossfade

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: BSD-3-Clause 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

General info

  • License: BSD-3
  • Version: 1.1.0

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
examples

Jump to

Keyboard shortcuts

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