Thanks to visit codestin.com
Credit goes to pkg.go.dev

xstack

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 5 Imported by: 0

README

xstack

GoDev Build Status Coverage Status Go Report Card

Xstack is library for xstack layouts generation written in Go.

Quick-start

package main

import (
  "bytes"
  "fmt"

  "github.com/video-audio/xstack"
)

// 0_0|w0_0|w0+w1_0|0_h0|w0_h0|w0+w1_h0|0_h0+h1|w0_h0+h1|w0+w1_h0+h1
func main() {
  fmt.Println(xstack.Layout(9))

  // or
  b := bytes.Buffer{}
  xstack.LayoutTo(&b, 9)

  fmt.Println(b.String())
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrZeroN = errors.New("layout for 0 elements couldn't be calculated")

ErrZeroN indicates that passed n to Layout function is 0 and cann't be processed.

Functions

func Layout

func Layout(n uint64) (string, error)

Layout returns xstack layout description as string. Is's just helper function - wrapper around LayoutTo with predefined AlignHorizontal.

func LayoutTo

func LayoutTo(w io.Writer, n uint64) error

LayoutTo writes xstack layout description to w. Where n is total number of elements in grid.

func LayoutToWithAlign added in v0.0.2

func LayoutToWithAlign(w io.Writer, n uint64, align Align) error

LayoutToWithAlign is same as LayoutTo but with custom align.

func LayoutWithAlign added in v0.0.2

func LayoutWithAlign(n uint64, align Align) (string, error)

LayoutWithAlign is same as Layout but with custom align.

Types

type Align added in v0.0.2

type Align uint8

Align sets alignment of grid.

const (
	// AlignVertical is for vertical grid emission.
	// For 6 inputs will produce 2x3 grid. e.g:
	// | | |
	// | | |
	// | | |
	AlignVertical Align = iota

	// AlignHorizontal is for horizontal grid emission.
	// For 6 inputs will produce 3x2 grid. e.g:
	// | | | |
	// | | | |
	AlignHorizontal
)

Jump to

Keyboard shortcuts

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