colortools

package module
v0.0.0-...-533984f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 4 Imported by: 1

README

Color Tools

Useful color tools.

Install

go get github.com/CuteReimu/colortools

Usage

package main

import (
	"github.com/CuteReimu/colortools"
	"image/color"
	"image/png"
	"os"
)

func main() {
	f, _ := os.Open("1.png")
	defer f.Close()
	img, _ := png.Decode(f)

	c := make([]color.Color, 361)
	p := make([]float64, 361)
	for i := 0; i <= 360; i++ {
		c[i] = &colortools.HSV{H: float64(i), S: 1.0, V: 0.5}
		p[i] = float64(i) / 360.0
	}
	img1 := colortools.NewLineGradChgColorImage(img.Bounds(), c, p, img.Bounds())
	img2 := colortools.Screen(img1, img)
	
	f2, _ := os.Create("2.png")
	defer f2.Close()
	_ = png.Encode(f2, img2)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equals

func Equals(img1, img2 image.Image) bool

Equals 判断两个图像是否完全相同

func EqualsSub

func EqualsSub(img1 image.Image, x int, y int, img2 image.Image) bool

EqualsSub 判断img1在(x, y)位置的子图像与img2是否完全相同

func Mosaic

func Mosaic(img image.Image, rect image.Rectangle, px int) image.Image

Mosaic 马赛克,img-原图,rect-马赛克的区域,px-马赛克的像素

func NewCervicalGradChgColorImage

func NewCervicalGradChgColorImage(bounds image.Rectangle, c []color.Color, percent []float64, line image.Rectangle) image.Image

func NewLineGradChgColorImage

func NewLineGradChgColorImage(bounds image.Rectangle, c []color.Color, percent []float64, line image.Rectangle) image.Image

func NewTaperedGradChgColorImage

func NewTaperedGradChgColorImage(bounds image.Rectangle, c []color.Color, percent []float64, line image.Rectangle) image.Image

func Rotate

func Rotate(img image.Image, clockwise int8) image.Image

Rotate 旋转图片,clockwise参数为1表示顺时针,2表示180°,-1表示逆时针

func Screen

func Screen(imgs ...image.Image) image.Image

Screen 滤色

func Search(img1 image.Image, x int, y int, img2 image.Image) (point image.Point, ok bool)

Search 在img1中,从(x, y)位置开始搜索img2图像,返回值是相对于img1.Bounds().Min的相对位置

func ZoomGraphics

func ZoomGraphics(img image.Image, rect image.Rectangle, background color.Color) image.Image

ZoomGraphics 放大或缩小画布,img-原图,rect-新画布的位置,background-空余部分的背景色

Types

type HSV

type HSV struct {
	H float64 // 0-360
	S float64 // 0-1
	V float64 // 0-1
	// contains filtered or unexported fields
}

func (*HSV) RGBA

func (H *HSV) RGBA() (uint32, uint32, uint32, uint32)

Jump to

Keyboard shortcuts

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