callisto

package module
v0.0.0-...-59c2813 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 4 Imported by: 0

README

callisto

simple render image with golang code

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadImageDimension

func ReadImageDimension(imagePath string) (*image.Config, error)

func ReadImageFromFile

func ReadImageFromFile(imageFilePath string) (*image.Image, error)

Types

type Anchor

type Anchor int
const (
	TopLeft Anchor = iota
	TopCenter
	TopRight
	CenterLeft
	Center
	CenterRight
	BottomLeft
	BottomCenter
	BottomRight
)

type Border

type Border struct {
	Color string
	Width int
}

type Box

type Box struct {
	ElementPosition
	ElementDimension
	Children      []Element
	ChildrenAlign ChildAlign
	Color         string
	LayoutManager LayoutManager
	DrawArea      DrawArea
	Padding       ElementPadding
	BoxSizing     BoxSizing
	Border        ElementBorder
}

func (*Box) AddToChildren

func (b *Box) AddToChildren(element Element)

func (*Box) AlignWithAnchor

func (b *Box) AlignWithAnchor(anchor Anchor, X float64, Y float64)

func (*Box) ApplyAlign

func (b *Box) ApplyAlign()

func (*Box) ApplyChildPosition

func (b *Box) ApplyChildPosition()

func (*Box) CalculationDimension

func (b *Box) CalculationDimension(parent Element)

func (*Box) GetAnchor

func (b *Box) GetAnchor(anchor Anchor) (X, Y float64)

func (*Box) GetChildren

func (b *Box) GetChildren() []Element

func (*Box) GetDimension

func (b *Box) GetDimension() (float64, float64)

func (*Box) GetWeight

func (b *Box) GetWeight() float64

func (*Box) Render

func (b *Box) Render(renderContext *RenderContext)

func (*Box) TransformChildPosition

func (b *Box) TransformChildPosition()

type BoxSizing

type BoxSizing int
const (
	BorderBox BoxSizing = iota + 1
	ContentBox
)

type ChildAlign

type ChildAlign int
const (
	MainAxisTop ChildAlign = iota + 1
	MainAxisCenter
	MainAxisBottom
	CrossAxisLeft
	CrossAxisCenter
	CrossAxisRight
	MainCrossAxisCenter
)

type Dimension

type Dimension interface {
	GetDimension() (width float64, height float64)
	GetWidth() float64
	GetHeight() float64
	SetHeight(height float64)
	SetWidth(width float64)
	SetDimension(width float64, height float64)
	SetDimensionDelta(width float64, height float64)
	GetWeight() float64
	SetWeight(weight float64)
	CalculationDimension(parent Element)
}

type DrawArea

type DrawArea struct {
	Width  float64
	Height float64
	X      float64
	Y      float64
}

type Edge

type Edge struct {
	Top    float64
	Right  float64
	Bottom float64
	Left   float64
}

type Element

type Element interface {
	Position
	Dimension
	Render(context *RenderContext)
	GetChildren() []Element
	GetAnchor(anchor Anchor) (X, Y float64)
	AlignWithAnchor(anchor Anchor, X float64, Y float64)
	ApplyChildPosition()
	AddToChildren(element Element)
}

type ElementBorder

type ElementBorder struct {
	Top    Border
	Right  Border
	Bottom Border
	Left   Border
}

type ElementDimension

type ElementDimension struct {
	Width                     float64
	Height                    float64
	Weight                    float64
	ParentRelativeScaleWidth  float64
	ParentRelativeScaleHeight float64
	ParentRelativeDeltaWidth  float64
	ParentRelativeDeltaHeight float64
	UserParentRelative        bool
}

func (*ElementDimension) GetDimension

func (e *ElementDimension) GetDimension() (float64, float64)

func (*ElementDimension) GetHeight

func (e *ElementDimension) GetHeight() float64

func (*ElementDimension) GetWeight

func (e *ElementDimension) GetWeight() float64

func (*ElementDimension) GetWidth

func (e *ElementDimension) GetWidth() float64

func (*ElementDimension) SetDimension

func (e *ElementDimension) SetDimension(width float64, height float64)

func (*ElementDimension) SetDimensionDelta

func (e *ElementDimension) SetDimensionDelta(width float64, height float64)

func (*ElementDimension) SetHeight

func (e *ElementDimension) SetHeight(height float64)

func (*ElementDimension) SetWeight

func (e *ElementDimension) SetWeight(weight float64)

func (*ElementDimension) SetWidth

func (e *ElementDimension) SetWidth(width float64)

type ElementPadding

type ElementPadding struct {
	Left   float64
	Right  float64
	Top    float64
	Bottom float64
}

type ElementPosition

type ElementPosition struct {
	X               float64
	Y               float64
	ParentDeltaX    float64
	ParentDeltaY    float64
	SiblingDeltaX   float64
	SiblingDeltaY   float64
	UseParentDelta  bool
	UseSiblingDelta bool
	// contains filtered or unexported fields
}

func (*ElementPosition) GetPosition

func (b *ElementPosition) GetPosition() (float64, float64)

func (*ElementPosition) GetX

func (b *ElementPosition) GetX() float64

func (*ElementPosition) GetY

func (b *ElementPosition) GetY() float64

func (*ElementPosition) MoveDelta

func (b *ElementPosition) MoveDelta(x float64, y float64)

func (*ElementPosition) SetPosition

func (b *ElementPosition) SetPosition(x float64, y float64)

func (*ElementPosition) SetX

func (b *ElementPosition) SetX(x float64)

func (*ElementPosition) SetY

func (b *ElementPosition) SetY(y float64)

func (*ElementPosition) UpdatePosition

func (b *ElementPosition) UpdatePosition(x float64, y float64) (float64, float64)

type HorizonListLayoutManager

type HorizonListLayoutManager struct {
}

func (*HorizonListLayoutManager) Place

func (v *HorizonListLayoutManager) Place(element *Box)

type ImageBox

type ImageBox struct {
	Box
	Src             string
	Image           *ImageElement
	OriginDimension bool
	Fit             ImageFit
}

func (*ImageBox) CalculationDimension

func (b *ImageBox) CalculationDimension(parent Element)

func (*ImageBox) Preload

func (b *ImageBox) Preload(ctx *RenderContext)

func (*ImageBox) Render

func (b *ImageBox) Render(renderContext *RenderContext)

type ImageElement

type ImageElement struct {
	ImagePath string
	Content   *image.Image
	Config    *image.Config
}

func NewImageElement

func NewImageElement(imagePath string) (*ImageElement, error)

type ImageFit

type ImageFit uint
const (
	NoFit ImageFit = iota
	FitWidth
	FitHeight
	Both
)

type ImageResourceLibrary

type ImageResourceLibrary struct {
	Images []*ImageElement
}

func (*ImageResourceLibrary) GetImageWithPath

func (l *ImageResourceLibrary) GetImageWithPath(imagePath string) (target *ImageElement)

func (*ImageResourceLibrary) LoadFromResource

func (l *ImageResourceLibrary) LoadFromResource(imageFilePath string) error

type LayoutManager

type LayoutManager interface {
	Place(box *Box)
}

type ParagraphBox

type ParagraphBox struct {
	Box
	Text     string
	FontPath string
	Size     float64
	Color    string
	Wrap     bool
}

func (*ParagraphBox) Preload

func (t *ParagraphBox) Preload(ctx *RenderContext)

func (*ParagraphBox) Render

func (t *ParagraphBox) Render(renderContext *RenderContext)

type Position

type Position interface {
	GetPosition() (float64, float64)
	SetPosition(float64, float64)
	UpdatePosition(float64, float64) (float64, float64)
	MoveDelta(float64, float64)
	GetX() float64
	GetY() float64
	SetY(float64)
	SetX(float64)
	TransformChildPosition()
}

type PreloadElement

type PreloadElement interface {
	Preload(ctx *RenderContext)
}

type RenderContext

type RenderContext struct {
	Context              *gg.Context
	ImageResourceLibrary *ImageResourceLibrary
	Parent               Element
	Sibling              Element
}

type RenderEngine

type RenderEngine struct {
	Context *gg.Context
	Root    Element
}

func (*RenderEngine) CalculationElementsDimension

func (e *RenderEngine) CalculationElementsDimension(imageResources *ImageResourceLibrary)

func (*RenderEngine) LoadCanvasImageFromFile

func (e *RenderEngine) LoadCanvasImageFromFile(imageFilePath string) error

func (*RenderEngine) NewCanvas

func (e *RenderEngine) NewCanvas(width int, height int) error

func (*RenderEngine) PlaceElements

func (e *RenderEngine) PlaceElements(imageResources *ImageResourceLibrary)

func (*RenderEngine) RenderElements

func (e *RenderEngine) RenderElements(imageResources *ImageResourceLibrary)

func (*RenderEngine) RenderImage

func (e *RenderEngine) RenderImage()

func (*RenderEngine) SaveAsPNG

func (e *RenderEngine) SaveAsPNG(outputImageFilePath string) error

func (*RenderEngine) SetDoc

func (e *RenderEngine) SetDoc(doc Element)

type RenderQueueElement

type RenderQueueElement struct {
	Root    Element
	Context *RenderContext
}

type RenderTask

type RenderTask struct {
	Element     Element
	GetChildren []Element
}

type TextBox

type TextBox struct {
	Box
	Text     string
	FontPath string
	Size     float64
	Color    string
}

func (*TextBox) Preload

func (t *TextBox) Preload(ctx *RenderContext)

func (TextBox) Render

func (t TextBox) Render(renderContext *RenderContext)

type VerticalListLayoutManager

type VerticalListLayoutManager struct {
}

func (*VerticalListLayoutManager) Place

func (v *VerticalListLayoutManager) Place(element *Box)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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