canvas

package module
v0.0.0-...-125ebeb Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 4 Imported by: 0

README

Canvas MIT License

Canvas is a simple go package that provides functions to help you create and display canvases in the terminal.

Contents

Example

package main

import (
	"fmt"
	"image/color"

	"github.com/NotWithering/canvas"
)

func main() {
	myCanvas := canvas.New(7, 3)
	myCanvas = canvas.Fill(myCanvas, color.Transparent)

	myCanvas[0][0] = color.RGBA{255, 85, 85, 255}
	myCanvas[0][1] = color.RGBA{255, 85, 85, 255}
	myCanvas[0][2] = color.RGBA{255, 85, 85, 255}
	myCanvas[1][1] = color.RGBA{255, 85, 85, 255}
	myCanvas[2][0] = color.RGBA{255, 85, 85, 255}
	myCanvas[2][1] = color.RGBA{255, 85, 85, 255}
	myCanvas[2][2] = color.RGBA{255, 85, 85, 255}

	myCanvas[4][0] = color.RGBA{255, 85, 85, 255}
	myCanvas[5][0] = color.RGBA{255, 85, 85, 255}
	myCanvas[6][0] = color.RGBA{255, 85, 85, 255}
	myCanvas[5][1] = color.RGBA{255, 85, 85, 255}
	myCanvas[4][2] = color.RGBA{255, 85, 85, 255}
	myCanvas[5][2] = color.RGBA{255, 85, 85, 255}
	myCanvas[6][2] = color.RGBA{255, 85, 85, 255}

	me := canvas.Text(myCanvas)
	fmt.Println(me)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageText deprecated

func ImageText(img image.Image, width, height uint) string

Deprecated: ImageText renders the image using half block subcharacter-layering into a string. Please use ImageCanvas and TextHalfBlock instead.

func Text deprecated

func Text(canvas Canvas) string

Deprecated: Text renders the canvas using half block subcharacter-layering into a string. Please use TextHalfBlock instead.

func TextHalfBlock

func TextHalfBlock(canvas Canvas) string

TextHalfBlock renders the canvas using half block subcharacter-layering into a string.

Types

type Canvas

type Canvas [][]color.Color

Canvas is a two-dimensional array of colors.

func Clone

func Clone(original Canvas) Canvas

Clone takes the original canvas and returns the copy of it.

func Fill

func Fill(canvas Canvas, color color.Color) Canvas

Fill fills the entire Canvas with the specified color.

func ImageCanvas

func ImageCanvas(img image.Image) Canvas

ImageCanvas takes an image and converst it to a canvas

func New

func New(width, height int) Canvas

New creates a new Canvas with the specified width and height.

Jump to

Keyboard shortcuts

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