clrplot

package module
v0.0.0-...-bc0c034 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 8 Imported by: 0

README

clrplt module

I'd wanted to write module which would help me to plot matrix (like matplotlib for python do). So, I created this module.

How to use

Add this line in your file to import module:

import "github.com/Aleksandr-qefy/clrplot"

To draw your matrix like structure it must implement methods of Plotable interface:

type Plotable interface {
	CoordsToNum(Coords) int
	GetMaxNum() int
	GetMinNum() int
	Height() int
	Width() int
}

type Coords struct {
	I int
	J int
}

Supposed, that every element in matrix at position (I, J) can be represented as int type value (I name them Num), so module could plot it.

To speed up matrix drawing I use multiple algorithms like binary search and memorization.

Use examples

Examples how to create new ColorMap you can see in file.

I use this module to plot fractals in this project.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(mtrx Plotable, imgName string, cm ColorMap) error

Types

type Color

type Color struct {
	R, G, B uint8
}

type ColorMap

type ColorMap struct {
	// contains filtered or unexported fields
}

func GenBlack

func GenBlack() ColorMap

func GenInferno

func GenInferno() ColorMap

func GenPlasma

func GenPlasma() ColorMap

func GenViridis

func GenViridis() ColorMap

func NewColorMap

func NewColorMap(
	val0 ColorMapVal,
	val1 ColorMapVal,
	vals ...ColorMapVal,
) (ColorMap, error)

func (ColorMap) Bake

func (cm ColorMap) Bake(minNum, maxNum int) (ColorMapBaked, error)

type ColorMapBaked

type ColorMapBaked struct {
	// contains filtered or unexported fields
}

func (ColorMapBaked) NumToColor

func (cmb ColorMapBaked) NumToColor(num int) Color

type ColorMapBakedVal

type ColorMapBakedVal struct {
	// contains filtered or unexported fields
}

type ColorMapBakedValSlc

type ColorMapBakedValSlc []ColorMapBakedVal

type ColorMapVal

type ColorMapVal struct {
	C     Color
	Ratio float64
}

type ColorMapValSlc

type ColorMapValSlc []ColorMapVal

func (ColorMapValSlc) Len

func (c ColorMapValSlc) Len() int

func (ColorMapValSlc) Less

func (c ColorMapValSlc) Less(i, j int) bool

func (ColorMapValSlc) Swap

func (c ColorMapValSlc) Swap(i, j int)

type Coords

type Coords struct {
	I int
	J int
}

type NumToColorInterface

type NumToColorInterface interface {
	NumToColor(int) Color
}

type Plotable

type Plotable interface {
	CoordsToNum(Coords) int
	GetMaxNum() int
	GetMinNum() int
	Height() int
	Width() int
}

Jump to

Keyboard shortcuts

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