material

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

Material

GitHub go.mod Go version GitHub Repo stars GitHub License GitHub Tag

[!IMPORTANT] 🔥 Found this useful? A quick star goes a long way.

A pure go implementation of Material Color Utilities

Example

package main

import (
	"fmt"
	"image/jpeg"
	"log"
	"os"

	"github.com/Nadim147c/material"
	"github.com/Nadim147c/material/dynamic"
)

func main() {
	file, err := os.Open("gophar.jpg")
	if err != nil {
		panic(err)
	}

	img, err := jpeg.Decode(file)
	if err != nil {
		log.Fatalf("failed to decode image: %v", err)
	}

	colors, err := material.GenerateFromImage(
		img,
		dynamic.VariantExpressive,
		true,
		0,
		dynamic.PlatformPhone,
		dynamic.Version2021,
	)
	if err != nil {
		log.Fatalf("failed to generate colors: %v", err)
	}

	for key, value := range colors {
		fmt.Println(key, value)
	}
}

License

This project is licensed under the Apache License, Version 2.0. It includes code derived from Material Color Utilities by Google LLC, originally licensed under the Apache License 2.0.

See the NOTICE file for details and third-party attributions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoColorFound = errors.New("no color found")

ErrNoColorFound indecates no color found in array

Functions

This section is empty.

Types

type Colors

type Colors = map[string]color.ARGB

Colors is key and color

func GenerateFromColors

func GenerateFromColors(
	colors []color.Color,
	variant dynamic.Variant,
	dark bool,
	constrast float64,
	platform dynamic.Platform,
	version dynamic.Version,
) (Colors, error)

GenerateFromColors generate theme from a slice of Color interface

func GenerateFromImage

func GenerateFromImage(
	img image.Image,
	variant dynamic.Variant,
	dark bool,
	constrast float64,
	platform dynamic.Platform,
	version dynamic.Version,
) (Colors, error)

GenerateFromImage colors from an image.Image

func GenerateFromPixels

func GenerateFromPixels(
	pixels []color.ARGB,
	variant dynamic.Variant,
	dark bool,
	constrast float64,
	platform dynamic.Platform,
	version dynamic.Version,
) (Colors, error)

GenerateFromPixels generate theme from a slice of ARGB colors

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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