raster

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

README

raster - a convenience package to render vector graphics as images

Overview

The raster package helps visualize vector graphics in the form of a PNG image. It can be used with the "golang.org/x/image/vector" package. Using primatives in that package, the raster package provides support for rendering solid lines and approximate circles. It also provides a convenience function to render the vector paths to an image. Documentation for the raster package should be available on go.dev.

The package provides a simple examples/trace.go program that uses the package to render something resembling a PCB copper trace.

$ go run examples/trace.go --dest image.png

creates the following image.png file:

trace rendered

License info

The raster program is distributed with the same BSD 3-clause license as that used by golang itself.

Reporting bugs and feature requests

The package raster has been developed purely out of curiosity for and as part of a project to create simple PCBs using a Snapmaker 2 3D printer (with laser and CNC tool heads). If you find a bug or want to suggest a feature addition, please use the bug tracker.

Documentation

Overview

Package raster contains some convenience functions for creating "golang.org/x/image/vector" paths and rendering them into images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawAt

func DrawAt(im draw.Image, r *vector.Rasterizer, x, y float64, col color.Color)

DrawAt places the r into an image aligning (x,y) of r with the (0,0) coordinate of the image.

func LineTo

func LineTo(r *vector.Rasterizer, capped bool, oX, oY, nX, nY, width float64)

LineTo renders a line segment from (oX,oY) to (nX,nY) with the specified perpendicular width. The capped value adds rounded end-caps to the line of radius half of the width (as approximated with Bezier curves).

func PointAt

func PointAt(r *vector.Rasterizer, x, y, width float64)

PointAt renders an approximate "circle" via 4 cubic Bezier curves describing the arc of the 4 quadrants.

func SquareAt

func SquareAt(r *vector.Rasterizer, x, y, width float64)

SquareAt renders a width by width square centered at (x,y).

Types

This section is empty.

Directories

Path Synopsis
Program trace creates a trace-like rendering of something you might see on a PCB.
Program trace creates a trace-like rendering of something you might see on a PCB.

Jump to

Keyboard shortcuts

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