juroku

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

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 20 Imported by: 0

README

Juroku

Juroku converts an image (PNG or JPG) into a Lua script that can be loaded as a ComputerCraft API to be used to draw on terminals and monitors.

Building and Running

  1. A cgo security exception is required to allow the libimagequant to build:
export CGO_CFLAGS_ALLOW=.*
export CGO_LDFLAGS_ALLOW=.*
  1. go get -u github.com/tmpim/juroku/cmd/juroku
  2. Find juroku in your $GOPATH/bin and run it.

TODO: Release pre-built binaries.

Usage:

Usage: juroku [options] input_image

Juroku converts an image (PNG or JPG) into a Lua script that can be
loaded as a ComputerCraft API to be used to draw on terminals and monitors.
Images are not automatically downscaled or cropped.

input_image must have a height that is a multiple of 3 in pixels,
and a width that is a multiple of 2 in pixels.

Options:
  -d float
    	set the amount of allowed dithering (0 = none, 1 = most) (default 0.2)
  -license
    	show GPLv3 licensing disclaimer
  -o string
    	set location of output script (default "image.lua")
  -p string
    	set location of output preview (will be PNG) (default "preview.png")
  -q int
    	set the processing speed/quality (1 = slowest, 10 = fastest) (default 1)

Disclaimer

Juroku when built contains libimagequant which is licensed under GPLv3. For more information and the source code of the relevant portions, see: https://github.com/1lann/imagequant.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChunkImage

func ChunkImage(img image.Image) (image.Image, error)

ChunkImage chunks an image following the ComputerCraft requirements of maximum of 2 colors per 2x3 chunk of pixels and returns it. It is assumed that the palette has already been reduced to 16 colors.

func EncodeVideo

func EncodeVideo(rd io.Reader, output chan<- VideoChunk,
	opts EncoderOptions) error

EncodeVideo encodes the video from the given reader which can be of any format that FFMPEG supports, into the output.

func GetPalette

func GetPalette(img image.Image) color.Palette

GetPalette returns the palette of the image.

func Quantize

func Quantize(ref, img image.Image, speed int, dither float64) (image.Image, error)

Quantize quantizes an image into a maximum of 16 colors with the given parameters.

Types

type AudioChunk

type AudioChunk []byte

AudioChunk represents a chunk of audio data.

func (AudioChunk) WriteTo

func (a AudioChunk) WriteTo(w io.Writer) error

type EncoderOptions

type EncoderOptions struct {
	Context     context.Context
	Width       int
	Height      int
	Workers     int
	Speed       int
	Dither      float64
	AudioBuffer time.Duration
	Debug       bool
	Splitter    FrameSplitter
}

type FrameChunk

type FrameChunk struct {
	Width  int
	Height int

	Rows []FrameRow

	Palette [16]color.RGBA
}

FrameChunk represents a frame chunk.

func GenerateFrameChunk

func GenerateFrameChunk(img image.Image) (*FrameChunk, error)

GenerateFrameChunk generates a frame chunk for the given image.

func (*FrameChunk) WriteTo

func (f *FrameChunk) WriteTo(w io.Writer) error

WriteTo writes the frame chunk to a writer.

type FrameRow

type FrameRow struct {
	TextColor       *bytes.Buffer
	BackgroundColor *bytes.Buffer
	Text            *bytes.Buffer
}

FrameRow represents a row in a frame chunk.

func (*FrameRow) WriteTo

func (f *FrameRow) WriteTo(wr io.Writer) (int, error)

WriteTo writes the frame row to a writer.

type FrameSplitter

type FrameSplitter func(img image.Image) []image.Image

FrameSplitter splits an image into multiple frames for multiple monitors.

type VideoChunk

type VideoChunk struct {
	Frames []*FrameChunk
	Audio  AudioChunk
}

VideoChunk is composed of a Frame and Audio chunk.

Directories

Path Synopsis
cmd
exp

Jump to

Keyboard shortcuts

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