diceimg

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

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 4 Imported by: 0

README

About diceimg

This is golang library designed to produce dice face images. At the first stage it will generate D6 dice faces. Maybe I will other dices.

Why?

It is used in tobytables project. I wanted to be able to have some textual representation of a dice in source and graphical dice with this value in the output.

How to use

width := 10
height := 10
strokeWidth := 0.2
radius := 0.5

d := NewBlank(width+strokeWidth, height+strokeWidth, strokeWidth, radius, canvas.Gray, canvas.Salmon, canvas.Lightgray)
d.D6(3, width, height, false)
d.WriteOutput("myfile.svg")

You can generate jpg, png, pdf giving propriate extension to WriteOutput filename.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func D6Rec

func D6Rec(ctx *canvas.Context, x, y, w, h, r float64)

func Dots

func Dots(ctx *canvas.Context, x, y, w, h, r float64, i int)

3 7 2 4 6 1 5

Types

type Dice

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

func New

func New(ctx *canvas.Context, x, y, r, strokeWidth float64, strokeCol, valueCol, diceCol color.RGBA) *Dice

New allows you to reuse existing ctx (canvas). x, y are coordinates of the dice to be rendered at.

func NewBlank

func NewBlank(w, h, r, strokeWidth float64, strokeCol, valueCol, diceCol color.RGBA) *Dice

NewBlank creates blank canvas. At the end, image is rendered. w, h are canvas WxH (size of image)

func (*Dice) D6

func (d *Dice) D6(face int, w, h float64, numeric bool)

D6 will generate D6 dice face. Numeric determines if pips are used or just numeric value (like 1, 2, ...)

func (*Dice) WriteOutput

func (d *Dice) WriteOutput(filename string)

WriteOutput renders dice into actual file.

Jump to

Keyboard shortcuts

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