svgs

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 5 Imported by: 0

README

svgs

svg 工具类库

QrSVG

生成SVG格式的QR码

参考: goqrsvg

优化了svg生成方式,压缩了svg尺寸

Rect

矩形

Rects

一组矩形,可横纵排序,压缩尺寸

依赖

Documentation

Overview

Package svgs svg 相关工具

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QrSVG

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

QrSVG holds the data related to the size, location, and block size of the QR Code. Holds unexported fields.

func NewQrSVG

func NewQrSVG(qr barcode.Barcode, blockSize int) QrSVG

NewQrSVG contructs a QrSVG struct. It takes a QR Code in the form of barcode.Barcode and sets the "pixel" or block size of QR Code in the SVG file.

func (*QrSVG) SetStartPoint

func (qs *QrSVG) SetStartPoint(x, y int)

SetStartPoint sets the top left start point of QR Code. This takes an X and Y value and then adds four white "blocks" to create the "quiet zone" around the QR Code.

func (*QrSVG) StartQrSVG

func (qs *QrSVG) StartQrSVG(s *svg.SVG)

StartQrSVG creates a start for writing an SVG file that only contains a barcode. This is similar to the svg.Start() method. StartQrSVG should only be used if you only want to write a QR code to the SVG. Otherwise use the regular svg.Start() method to start your SVG file.

func (*QrSVG) WriteQrSVG

func (qs *QrSVG) WriteQrSVG(elem *svg.SVG) error

WriteQrSVG writes the QR Code to SVG.

type Rect

type Rect struct {
	X int
	Y int
	W int
	H int
}

Rect 矩形.

type Rects

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

Rects 一组矩形.

func NewRects

func NewRects() *Rects

NewRects 新建矩形数组.

func (*Rects) Add

func (r *Rects) Add(rects ...*Rect)

Add 增加矩形.

func (*Rects) Compress

func (r *Rects) Compress() []*Rect

Compress 压缩.

func (*Rects) Len

func (r *Rects) Len() int

Len is the number of elements in the collection.

func (*Rects) Less

func (r *Rects) Less(indexI, indexJ int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*Rects) Swap

func (r *Rects) Swap(i, j int)

Swap swaps the elements with indexes i and j.

Jump to

Keyboard shortcuts

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