vcb

package
v0.0.0-...-2099c20 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Virtual Circuit Board package Data structures and methods to alter or create VCB blueprints

Colors are RGBA values for Decor Layers and Ink conversion

Virtual Circuit Board Package Functions for parsing the image inside of blueprints

Layers are a structure containing the

Index

Constants

This section is empty.

Variables

View Source
var Colors = [...]Color{
	{0, 0, 0, 0},
	{42, 53, 65, 255},
	{159, 168, 174, 255},
	{161, 85, 94, 255},
	{161, 108, 86, 255},
	{161, 133, 86, 255},
	{161, 152, 86, 255},
	{153, 161, 86, 255},
	{136, 161, 86, 255},
	{108, 161, 86, 255},
	{86, 161, 141, 255},
	{86, 147, 161, 255},
	{86, 123, 161, 255},
	{86, 98, 161, 255},
	{102, 86, 161, 255},
	{135, 86, 161, 255},
	{161, 85, 151, 255},
	{102, 120, 142, 255},
	{140, 171, 161, 255},
	{58, 69, 81, 255},
	{146, 255, 99, 255},
	{255, 198, 99, 255},
	{99, 242, 255, 255},
	{174, 116, 255, 255},
	{255, 98, 138, 255},
	{255, 162, 0, 255},
	{48, 217, 255, 255},
	{166, 0, 255, 255},
	{77, 56, 62, 255},
	{46, 71, 93, 255},
	{99, 255, 159, 255},
	{56, 77, 71, 255},
	{255, 0, 65, 255},
	{255, 255, 255, 255},
}

RGBA colors for each Ink Ordered exactly like the ink enum

Functions

func NewLayer

func NewLayer[T interface {
	LogicLayer | DecorOnLayer | DecorOffLayer
}](width int, height int) (*T, error)

Create a new layer

Types

type AnyLayer

type AnyLayer interface {
	FromImage(Image) error
	ToImage() (Image, error)
	Set(AnyPixel, int, int)
	Get(int, int) AnyPixel
	GetDimensions() (int, int)
	Clear()
}

type AnyPixel

type AnyPixel interface {
	ToColor() Color
	ToInk() Ink
}

type Blueprint

type Blueprint struct {
	Width, Height int
	Layer         AnyLayer
	Type          LayerType
}

Blueprints contain a single layer Depending on which Type is set

func NewBlueprintFromBase64

func NewBlueprintFromBase64(b64 string) (*Blueprint, error)

Create a new blueprint from a base64 encoded string Allows to import blueprints from the game

func NewBlueprintFromLayer

func NewBlueprintFromLayer(layer AnyLayer) (*Blueprint, error)

Create a new blueprint from layer

func (*Blueprint) SetLayer

func (bp *Blueprint) SetLayer(layer AnyLayer) error

Set the blueprint layer

func (*Blueprint) ToBase64

func (bp *Blueprint) ToBase64() (string, error)

Convert into a base64 representation Allows to export blueprints to the game

type BlueprintFooter

type BlueprintFooter struct {
	HeightPadding int32
	Height        int32
	WidthPadding  int32
	Width         int32
	BytesPadding  int32
	Bytes         int32
	LayerPadding  int32
	Layer         int32
}

Binary representation of the footer

type Color

type Color struct {
	R, G, B, A byte
}

Colors contain RGBA values

func ColorFromData

func ColorFromData(data []byte) (Color, error)

Convert raw bytes to Color

func (Color) ToColor

func (c Color) ToColor() Color

No conversion, made for AnyPixel interface

func (Color) ToInk

func (c Color) ToInk() Ink

Convert Color to Ink Returns INK_NONE and Error on failure

type Context

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

Context contains any layer and has drawing functions

func NewContext

func NewContext(layer AnyLayer) *Context

Create a context attached to a layer

func (*Context) Clear

func (ctx *Context) Clear()

Clear the layer

func (*Context) Get

func (ctx *Context) Get(x int, y int) AnyPixel

func (*Context) Line

func (ctx *Context) Line(pixel AnyPixel, x0 int, y0 int, x1 int, y1 int)

Draw a line inside the layer between two normalized coordinates (-1 to 1)

func (*Context) Rect

func (ctx *Context) Rect(pixel AnyPixel, x0 int, y0 int, x1 int, y1 int)

Draw a rectangle at normalized coordinates (-1 to 1)

func (*Context) Set

func (ctx *Context) Set(pixel AnyPixel, x int, y int)

Set a single pixel inside the layer at a normalized coordinate (-1 to 1)

type DecorOffLayer

type DecorOffLayer struct {
	Width, Height int
	Pixels        []Color
}

Decoration Off Layer Contains the RGBA color data

func (*DecorOffLayer) Clear

func (l *DecorOffLayer) Clear()

Clear the decoration (Off) image

func (*DecorOffLayer) FromImage

func (l *DecorOffLayer) FromImage(colors Image) error

Populate a decoration layer (Off) from colors

func (*DecorOffLayer) Get

func (l *DecorOffLayer) Get(x int, y int) AnyPixel

Get color inside data

func (*DecorOffLayer) GetDimensions

func (l *DecorOffLayer) GetDimensions() (int, int)

Get width and height of layer

func (*DecorOffLayer) Set

func (l *DecorOffLayer) Set(pixel AnyPixel, x int, y int)

Set color inside data

func (*DecorOffLayer) ToImage

func (l *DecorOffLayer) ToImage() (Image, error)

Convert decoration later (Off) to image

type DecorOnLayer

type DecorOnLayer struct {
	Width, Height int
	Pixels        []Color
}

Decoration On Layer Contains the RGBA color data

func (*DecorOnLayer) Clear

func (l *DecorOnLayer) Clear()

Clear the decoration (On) layer

func (*DecorOnLayer) FromImage

func (l *DecorOnLayer) FromImage(colors Image) error

Populate a decoration layer (On) from colors

func (*DecorOnLayer) Get

func (l *DecorOnLayer) Get(x int, y int) AnyPixel

Get color inside data

func (*DecorOnLayer) GetDimensions

func (l *DecorOnLayer) GetDimensions() (int, int)

Get width and height of layer

func (*DecorOnLayer) Set

func (l *DecorOnLayer) Set(pixel AnyPixel, x int, y int)

Set color inside data

func (*DecorOnLayer) ToImage

func (l *DecorOnLayer) ToImage() (Image, error)

Convert decoration layer (On) to image

type Image

type Image []Color

Image type

func (Image) ToData

func (image Image) ToData() []byte

type Ink

type Ink int

Ink is any of the possible usable logical inks

const (
	InkNone Ink = iota
	InkTraceGrey
	InkTraceWhite
	InkTraceRed
	InkTraceOrange
	InkTraceYellowW
	InkTraceYellowC
	InkTraceLemon
	InkTraceGreenW
	InkTraceGreenC
	InkTraceTurqouise
	InkTraceLightBlue
	InkTraceBlue
	InkTraceDarkBlue
	InkTracePurple
	InkTraceViolet
	InkTracePink
	InkCross
	InkFiller
	InkAnnotation
	InkBuffer
	InkAND
	InkOR
	InkXOR
	InkNOT
	InkNAND
	InkNOR
	InkXNOR
	InkWrite
	InkRead
	InkLatchOn
	InkLatchOff
	InkClock
	InkLED
)

Ink enum May change between version depending on game updates

func (Ink) ToColor

func (ink Ink) ToColor() Color

Convert Ink to Color Returns zero-ed Color and error on failure

func (Ink) ToInk

func (ink Ink) ToInk() Ink

No conversion, made for AnyPixel interface

type LayerType

type LayerType int

Layer type

const (
	LayerTypeLogic    LayerType = 65536
	LayerTypeDecorOn  LayerType = 131072
	LayerTypeDecorOff LayerType = 262144
)

Layer types

type LogicLayer

type LogicLayer struct {
	Width, Height int
	Circuit       []Ink
}

Logical layer Contains the 'Inks' that builds up the circuit

func (*LogicLayer) Clear

func (l *LogicLayer) Clear()

Clear the logic layer

func (*LogicLayer) FromImage

func (l *LogicLayer) FromImage(colors Image) error

Populate logic layer from colors

func (*LogicLayer) Get

func (l *LogicLayer) Get(x int, y int) AnyPixel

Get ink inside data

func (*LogicLayer) GetDimensions

func (l *LogicLayer) GetDimensions() (int, int)

Get width and height of layer

func (*LogicLayer) Set

func (l *LogicLayer) Set(pixel AnyPixel, x int, y int)

Set ink inside data

func (*LogicLayer) ToImage

func (l *LogicLayer) ToImage() (Image, error)

Convert logic layer to colors

Jump to

Keyboard shortcuts

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