Documentation ¶
Index ¶
- Constants
- func Erase(n int)
- func ReadPNG(filename string, verbose bool) (image.Image, error)
- type Box
- type Pixel
- type PixelImage
- func (pi *PixelImage) At(x, y int) (r, g, b int)
- func (pi *PixelImage) At2(x, y int) (r, g, b, a int)
- func (pi *PixelImage) Bytes() []byte
- func (pi *PixelImage) CoverAllPixels()
- func (pi *PixelImage) CoverBox(bo *Box, pink bool, optimizeColors bool)
- func (pi *PixelImage) CoverEmptyBox(bo *Box)
- func (pi *PixelImage) Covered(x, y int) bool
- func (pi *PixelImage) CreateBox(x, y int) *Box
- func (pi *PixelImage) CreateRandomBox(checkIfPossible bool) *Box
- func (pi *PixelImage) Done(startx, starty int) bool
- func (pi *PixelImage) Expand(bo *Box) (expanded bool)
- func (pi *PixelImage) ExpandDown(bo *Box) bool
- func (pi *PixelImage) ExpandLeft(bo *Box) bool
- func (pi *PixelImage) ExpandOnce(bo *Box) bool
- func (pi *PixelImage) ExpandRight(bo *Box) bool
- func (pi *PixelImage) ExpandUp(bo *Box) bool
- func (pi *PixelImage) FirstUncovered(startx, starty int) (int, int)
- func (pi *PixelImage) SetColorOptimize(enabled bool)
- func (pi *PixelImage) WriteSVG(filename string) error
- type Pixels
Constants ¶
const VersionString = "png2svg 1.5.2"
VersionString contains the package name and the current version
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box represents a box with the following properties: * position (x, y) * size (w, h) * color (r, g, b, a)
type Pixel ¶
type Pixel struct {
// contains filtered or unexported fields
}
Pixel represents a pixel at position (x,y) with color (r,g,b,a) and a bool for if this pixel has been covered by an SVG shape yet
type PixelImage ¶
type PixelImage struct {
// contains filtered or unexported fields
}
PixelImage contains the data needed to convert a PNG to an SVG: pixels (with an overview of which pixels are covered) and an SVG document, starting with the document and root tag + colorOptimize, for if only 4096 colors should be used (short hex color strings, like #fff).
func NewPixelImage ¶
func NewPixelImage(img image.Image, verbose bool) *PixelImage
NewPixelImage initializes a new PixelImage struct, given an image.Image.
func (*PixelImage) At ¶
func (pi *PixelImage) At(x, y int) (r, g, b int)
At returns the RGB color at the given coordinate
func (*PixelImage) At2 ¶
func (pi *PixelImage) At2(x, y int) (r, g, b, a int)
At2 returns the RGBA color at the given coordinate
func (*PixelImage) Bytes ¶
func (pi *PixelImage) Bytes() []byte
Bytes returns the rendered SVG document as bytes
func (*PixelImage) CoverAllPixels ¶
func (pi *PixelImage) CoverAllPixels()
CoverAllPixels will cover all pixels that are not yet covered by an SVG element , by creating a rectangle per pixel.
func (*PixelImage) CoverBox ¶
func (pi *PixelImage) CoverBox(bo *Box, pink bool, optimizeColors bool)
CoverBox creates rectangles in the SVG image, and also marks the pixels as covered if pink is true, the rectangles will be pink if optimizeColors is true, the color strings will be shortened (and quantized)
func (*PixelImage) CoverEmptyBox ¶
func (pi *PixelImage) CoverEmptyBox(bo *Box)
func (*PixelImage) Covered ¶
func (pi *PixelImage) Covered(x, y int) bool
Covered returns true if the pixel at the given coordinate is already covered by SVG elements
func (*PixelImage) CreateBox ¶
func (pi *PixelImage) CreateBox(x, y int) *Box
CreateBox creates a 1x1 box at the given location, if it's not already covered
func (*PixelImage) CreateRandomBox ¶
func (pi *PixelImage) CreateRandomBox(checkIfPossible bool) *Box
CreateRandomBox randomly searches for a place for a 1x1 size box. Note: If checkIfPossible is true, the function continue running until it either finds a free spot or no spots are available.
func (*PixelImage) Done ¶
func (pi *PixelImage) Done(startx, starty int) bool
Done checks if all pixels are covered, in terms of being represented by an SVG element searches from the given x and y coordinate
func (*PixelImage) Expand ¶
func (pi *PixelImage) Expand(bo *Box) (expanded bool)
Expand tries to expand the box to the right and downwards, until it can't expand any more. Returns true if the box was expanded at least once.
func (*PixelImage) ExpandDown ¶
func (pi *PixelImage) ExpandDown(bo *Box) bool
ExpandDown will expand a box 1 pixel downwards, if all new pixels have the same color
func (*PixelImage) ExpandLeft ¶
func (pi *PixelImage) ExpandLeft(bo *Box) bool
ExpandLeft will expand a box 1 pixel to the left, if all new pixels have the same color
func (*PixelImage) ExpandOnce ¶
func (pi *PixelImage) ExpandOnce(bo *Box) bool
ExpandOnce tries to expand the box to the right and downwards, once
func (*PixelImage) ExpandRight ¶
func (pi *PixelImage) ExpandRight(bo *Box) bool
ExpandRight will expand a box 1 pixel to the right, if all new pixels have the same color
func (*PixelImage) ExpandUp ¶
func (pi *PixelImage) ExpandUp(bo *Box) bool
ExpandUp will expand a box 1 pixel upwards, if all new pixels have the same color
func (*PixelImage) FirstUncovered ¶
func (pi *PixelImage) FirstUncovered(startx, starty int) (int, int)
FirstUncovered will find the first pixel that is not covered by an SVG element, starting from (startx,starty), searching row-wise, downwards.
func (*PixelImage) SetColorOptimize ¶
func (pi *PixelImage) SetColorOptimize(enabled bool)
SetColorOptimize can be used to set the colorOptimize flag, for using only 4096 colors.
func (*PixelImage) WriteSVG ¶
func (pi *PixelImage) WriteSVG(filename string) error
WriteSVG will save the current SVG document to a file