models

package
v0.0.0-...-a625e7b Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package models describs necessary models

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

type Canvas struct {
	Length   int        // First dimension
	Width    int        // Second dimension
	Elements []*Element // Canvas data
}

Canvas descrbes a patchwork that consists of samples and can be rendered. Here comes coordinates structure

   X  0  1  2  |
Y  +-----------+----
0  |  0  1  2  | ^
1  |  3  4  5  | | LENGTH=4
2  |  6  7  8  | |
3  |  9 10 11  | V
   +-----------+---
   |< WIDTH=3 >|

func (*Canvas) Compose

func (c *Canvas) Compose(cmp Composer, samples []Sample) error

Compose composes canvas elements out of samples based on particular composition logic

func (*Canvas) IndexForXY

func (c *Canvas) IndexForXY(x, y int) (int, error)

IndexForXY returns patch index by its coordinates. Opposite to GetXY

func (*Canvas) Render

func (c *Canvas) Render(r Renderer) ([]byte, error)

Render renders canvas into some output using particular rendering logic

func (*Canvas) XYforIndex

func (c *Canvas) XYforIndex(i int) (int, int, error)

XYforIndex returns element coordinates by its index. Opposite to GetIndex

type Composer

type Composer interface {
	Compose(*Canvas, []Sample) error
	Seed(int64)
}

Composer composes a canvas out of samples by chosing them and placing in some order

type Element

type Element struct {
	Rotation int // 0-3 means multiplication per 90 degree clockwise
	Sample   Sample
}

Element describes a sample placed in a canvas

type Renderer

type Renderer interface {
	Render(*Canvas) ([]byte, error)
}

Renderer renders a canvas into specific format

type Sample

type Sample interface {
	Image() image.Image // Image data
	ID() string         // An identifier that allows to compare samples
}

Sample defines an cloth sample that patchwork is made of

Jump to

Keyboard shortcuts

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