germanium

package module
v0.0.0-...-25c2f86 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 16 Imported by: 0

README

Germanium

Germanium is an alternative to Carbon and Silicon implemented in Go.

screenshot

Germanium can work without browser and internet like Silicon.

Usage

germanium

USAGE:
    germanium [FLAGS] [FILE]

FLAGS:
    -o, --output <PATH>       Write output image to specific filepath [default: ./output.png]
    -b, --background <COLOR>  Background color of the image [default: #aaaaff]
    -f, --font <FONT>         Specify font eg. 'Hack-Bold'
    -l, --language <LANG>     The language for syntax highlighting eg. 'go'
    -s, --style <STYLE>       The style for syntax highlighting eg. 'dracula'
    -c, --clip                Copy image to clipboard
    --list-styles             List all available styles for syntax highlighting
    --list-fonts              List all available fonts in your system
    --no-line-number          Hide the line number
    --no-window-access-bar    Hide the window access bar
    -v, --version             Show Version
Example

Generate image From file

germanium -o main.png main.go

Generate image From Stdin (need to add option -l or --language)

cat main.go | germanium -l go -o main.png -

Generate image with another style (you can get a list of them with --list-styles)

germanium -s solarized-dark -o main.png main.go

Generate image without line number

germanium --no-line-number -o main.png main.go

Generate image without window control bar

germanium --no-window-access-bar -o main.png main.go

Generate image and copy to clipboard

germanium --no-window-access-bar -o main.png main.go -c

Install

GitHub releases

You can download from here.

Arch Linux
yay germanium
Build from source
git clone https://github.com/eastym/germanium
cd cmd/germanium && go install
Requirements
  • Go (1.17 or 1.18)

LICENSE

MIT

Author

matsuyoshi30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcHeight

func CalcHeight(lineCount int, fontSize float64, noWindowAccessBar bool) int

CalcHeight calculates the image height from the number of lines of the source code, padding and access bar

func CalcWidth

func CalcWidth(maxLineLen int) int

CalcWidth calculates the image width from the length of the longest line of the source code, padding and line number

func ParseHexColor

func ParseHexColor(s string) (color.RGBA, error)

ParseHexColor parses string into RGBA

Types

type Drawer

type Drawer interface {
	Draw() error
}

Drawer implements Draw()

type Formatter

type Formatter interface {
	Format(w io.Writer, style *chroma.Style, iterator chroma.Iterator) error
}

Formatter implements Format()

type Labeler

type Labeler interface {
	Label(io.Writer, io.Reader, string, string) error
}

Labeler implements Label()

type PNGFormatter

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

PNGFormatter is a formatter for PNG

func NewPNGFormatter

func NewPNGFormatter(fs float64, d *font.Drawer, sp image.Point, l bool) *PNGFormatter

NewPNGFormatter generates a new PNG formatter

func (*PNGFormatter) Format

func (f *PNGFormatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Iterator) error

Format formats the source code on the image

type Panel

type Panel struct {
	Formatter Formatter
	// contains filtered or unexported fields
}

Panel holds an image and formatter

func NewImage

func NewImage(src io.Reader, face font.Face, fontSize float64, style, backgroundColor string, noWindowAccessBar, noLineNum bool) (*Panel, error)

NewImage generates new base panel

func NewPanel

func NewPanel(sx, sy, ex, ey int) *Panel

NewPanel generates new panel

func (*Panel) Draw

func (p *Panel) Draw() error

Draw draws the editor image on the base panel

func (*Panel) Label

func (p *Panel) Label(out io.Writer, src io.Reader, filename, language string) error

Label labels highlighted source code on panel

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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