Documentation
¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2024-12-09 12:15:51 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-01-03 15:18:55 * @FilePath: \go-toolbox\pkg\imgix\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-12-13 09:55:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-01-07 17:16:55 * @FilePath: \go-toolbox\pkg\imgix\drawer.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- func AddOverlay(originalImg image.Image, overlayColor color.RGBA) image.Image
- func AdjustValues(start, end, target float64) (float64, float64)
- func CalculateControlPoint(startPoint, endPoint *gg.Point, offsetX, offsetY float64) *gg.Point
- func CalculateFractionPoint(startPoint, endPoint *gg.Point, fraction float64, ...) *gg.Point
- func CalculateMultiplePoints(points []*gg.Point, calculateMode CalculateMode, axisMode ...AxisPointMode) *gg.Point
- func CalculatePoint(a, b *gg.Point, calculateMode CalculateMode, axisMode AxisPointMode) *gg.Point
- func CanFormTriangle(points []*gg.Point) (float64, bool, error)
- func CropImage(img image.Image, cropImgOptions *CropImgOptions) image.Image
- func EncodeImageToBase64(img image.Image, format ImageFormat, quality int) (string, error)
- func ExtendLine(p1, p2 *gg.Point, length float64) *gg.Point
- func LoadImageFromFile(filePath string) (image.Image, error)
- func LoadImageFromFileAndEncodeToBase64(filePath string, format ImageFormat, quality int) (string, error)
- func LoadImageFromURL(url string) (image.Image, error)
- func ModifyPoint(point *gg.Point, value float64, operation CalculateFractionPointMode, isX bool) *gg.Point
- func OffsetPointX(point *gg.Point, offset float64, operation ...CalculateFractionPointMode) *gg.Point
- func OffsetPointY(point *gg.Point, offset float64, operation ...CalculateFractionPointMode) *gg.Point
- func ResizeDownTriangle(vertexA, vertexB, vertexC *gg.Point, resizeXy float64) (*gg.Point, *gg.Point)
- func ResizeImage(img image.Image, resizeImgOptions *ResizeImgOptions) image.Image
- func ResizePoint(point *gg.Point, resizeX, resizeY float64) *gg.Point
- func ResizePointOneselfX(point *gg.Point, scaleFactor float64, operation ...CalculateFractionPointMode) *gg.Point
- func ResizePointOneselfY(point *gg.Point, scaleFactor float64, operation ...CalculateFractionPointMode) *gg.Point
- func ResizePoints(points []*gg.Point, scaleX, scaleY float64) []*gg.Point
- func ResizeUpTriangle(vertexA, vertexB, vertexC *gg.Point, resizeXy float64) (*gg.Point, *gg.Point)
- func ResizeX(point *gg.Point, scaleFactor float64) *gg.Point
- func ResizeY(point *gg.Point, scaleFactor float64) *gg.Point
- func SaveBufToImageFile(buf *bytes.Buffer, filePath string, format ImageFormat) error
- func UpdateBounds(x, y float64, left, top, right, bottom *float64)
- func WriterImage(img image.Image, quality int, format ImageFormat, output io.Writer) error
- func WriterImageFromBytes(data []byte, quality int, format ImageFormat, output io.Writer) error
- type AxisPointMode
- type CalculateFractionPointMode
- type CalculateMode
- type Coordinates
- type CropImgOptions
- type DashOptions
- type DashStyle
- type DelayLine
- type GraphicsRenderer
- func (g *GraphicsRenderer) DrawArc(startPoint, endPoint *gg.Point, offset float64, clockwise bool)
- func (g *GraphicsRenderer) DrawCenteredMultiLine(lines []LineSegment)
- func (g *GraphicsRenderer) DrawCircle(point *gg.Point, radius float64)
- func (g *GraphicsRenderer) DrawCurvedLine(start, end, control *gg.Point)
- func (g *GraphicsRenderer) DrawEllipse(point *gg.Point, width, height float64)
- func (g *GraphicsRenderer) DrawHorizontalLine(line HorizontalLine)
- func (g *GraphicsRenderer) DrawLine(startPoint, endPoint *gg.Point)
- func (g *GraphicsRenderer) DrawLineXYLineWidth(startX, startY, endX, endY float64)
- func (g *GraphicsRenderer) DrawPoint(point *gg.Point, radius float64)
- func (g *GraphicsRenderer) DrawPolygon(points []gg.Point)
- func (g *GraphicsRenderer) DrawRectangle(rect Rectangle, extendLength float64)
- func (g *GraphicsRenderer) DrawTriangle(x1, y1, x2, y2, x3, y3 float64)
- func (g *GraphicsRenderer) DrawVerticalLine(line VerticalLine)
- func (g *GraphicsRenderer) DrawWithStroke(drawFunc func(), isStroke bool)
- func (g *GraphicsRenderer) GetDashOptions() DashOptions
- func (g *GraphicsRenderer) SaveImage(img image.Image, name string, quality int, imageFormat ImageFormat) error
- func (g *GraphicsRenderer) SetDashed(dashes ...float64)
- func (g *GraphicsRenderer) UseDefaultDashed()
- func (g *GraphicsRenderer) UseSolidLine()
- type HorizontalEdge
- type HorizontalLine
- type ImageFormat
- type ImageLTRB
- type LineSegment
- type PointAddStrategy
- type PointDivideStrategy
- type PointMultiplyStrategy
- type PointOperationStrategy
- type PointSubtractStrategy
- type Rectangle
- type RectangleExtensions
- type ResizeImgOptions
- type VerticalEdge
- type VerticalLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddOverlay ¶ added in v0.11.26
AddOverlay 接受一个 img.Image 和一个颜色,返回添加了蒙层的 img.Image
func AdjustValues ¶ added in v0.11.27
AdjustValues 根据目标值调整起始和结束值
func CalculateControlPoint ¶ added in v0.11.21
CalculateControlPoint 计算控制点以实现弯曲效果 @param startPoint 起始点 @param endPoint 结束点 @param offsetX 坐标X偏移量 @param offsetY 坐标Y偏移量 @return *gg.Point 返回计算得到的控制点
func CalculateFractionPoint ¶ added in v0.11.21
func CalculateFractionPoint(startPoint, endPoint *gg.Point, fraction float64, mode CalculateFractionPointMode) *gg.Point
CalculateFractionPoint 计算任意分数的坐标 @param startPoint 起始点 @param endPoint 结束点 @param fraction 计算的分数 @param mode 计算模式(加、减、乘、除) @return *gg.Point 返回计算得到的坐标
func CalculateMultiplePoints ¶ added in v0.11.21
func CalculateMultiplePoints(points []*gg.Point, calculateMode CalculateMode, axisMode ...AxisPointMode) *gg.Point
CalculateMultiplePoints 计算多个点中的最大或最小点 @param points 要比较的点的切片 @param calculateMode 指定是取最大点还是最小点(PointMaxMin 枚举类型) @param axisMode 指定比较的轴(AxisPointMode 枚举类型、默认X) @return 返回在指定维度上较大的或较小的点
func CalculatePoint ¶ added in v0.11.21
func CalculatePoint(a, b *gg.Point, calculateMode CalculateMode, axisMode AxisPointMode) *gg.Point
CalculatePoint 返回两个点中在指定维度上较大的或较小的点 @param a 第一个点 @param b 第二个点 @param calculateMode 指定是取最大点还是最小点(CalculateMode 枚举类型) @param axisMode 指定比较的轴(AxisPointMode 枚举类型) @return 返回在指定维度上较大的或较小的点
func CanFormTriangle ¶ added in v0.11.21
CanFormTriangle 判断三个点是否能构成三角形 @param points 三个点的切片,必须包含三个点 @return area 三角形的面积,如果能构成三角形则返回面积,
bool 表示是否能构成三角形,error 表示是否有错误
func CropImage ¶ added in v0.11.25
func CropImage(img image.Image, cropImgOptions *CropImgOptions) image.Image
CropImage 裁剪图片 @param img: 要裁剪的原始图像(image.Image类型) @param cropImgOptions: 裁剪选项(*CropImgOptions类型),包含裁剪的最小和最大宽高 return
返回裁剪后的图像(image.Image类型)
func EncodeImageToBase64 ¶ added in v0.11.18
EncodeImageToBase64 将图像编码为 Base64 字符串
func ExtendLine ¶ added in v0.11.24
ExtendLine 从起始点 p1 延长到 p2,返回延长线的终点坐标 p1 是起始点,p2 是终止点,length 是延长的长度
func LoadImageFromFile ¶ added in v0.11.18
LoadImageFromFile 从给定的文件路径加载图片并返回 image.Image 对象
func LoadImageFromFileAndEncodeToBase64 ¶ added in v0.11.18
func LoadImageFromFileAndEncodeToBase64(filePath string, format ImageFormat, quality int) (string, error)
LoadImageFromFileAndEncodeToBase64 从文件加载图片并返回 Base64 编码字符串
func LoadImageFromURL ¶
LoadImageFromURL 从给定的 URL 加载图片并返回 image.Image 对象
func ModifyPoint ¶ added in v0.11.25
func ModifyPoint(point *gg.Point, value float64, operation CalculateFractionPointMode, isX bool) *gg.Point
ModifyPoint 根据指定的操作对点的某个坐标进行修改 @param point 要修改的点 @param value 要应用的值(缩放因子或偏移量) @param operation 计算模式 @param isX true 表示修改 x 坐标,false 表示修改 y 坐标 @return 返回经过操作后的新点
func OffsetPointX ¶ added in v0.11.25
func OffsetPointX(point *gg.Point, offset float64, operation ...CalculateFractionPointMode) *gg.Point
OffsetPointX 根据指定的操作返回原始 y 坐标与偏移后的 x 坐标的结果 @param point 要缩放的点 @param offset 偏移量 @param operation 计算模式 @return 返回经过操作后的新点
func OffsetPointY ¶ added in v0.11.25
func OffsetPointY(point *gg.Point, offset float64, operation ...CalculateFractionPointMode) *gg.Point
OffsetPointY 根据指定的操作返回原始 x 坐标与偏移后的 y 坐标的结果 @param point 要缩放的点 @param offset 偏移量 @param operation 计算模式 @return 返回经过操作后的新点
func ResizeDownTriangle ¶ added in v0.11.21
func ResizeDownTriangle(vertexA, vertexB, vertexC *gg.Point, resizeXy float64) (*gg.Point, *gg.Point)
ResizeDownTriangle 根据固定点缩小三角形的两个顶点 @params vertexA: 固定点的坐标 @params vertexB: 需要缩小的第一个点的坐标 @params vertexC: 需要缩小的第二个点的坐标 @params resizeXy: 缩小因子,值小于1表示缩小 @return: 新的 vertexB 和 vertexC 的坐标
func ResizeImage ¶ added in v0.11.24
func ResizeImage(img image.Image, resizeImgOptions *ResizeImgOptions) image.Image
ResizeImage 缩放图片 @param img: 要缩放的原始图像(image.Image类型) @param resizeImgOptions: 缩放选项(*CropImgOptions类型),包含缩放的宽高 return
返回缩放后的图像(image.Image类型)
func ResizePoint ¶ added in v0.11.21
ResizePoint 单个坐标轴的等比例缩放 @param point 要缩放的点 @param resizeX x 坐标的缩放因子 @param resizeY y 坐标的缩放因子 @return 返回同时经过 x 和 y 坐标缩放后的新点
func ResizePointOneselfX ¶ added in v0.11.25
func ResizePointOneselfX(point *gg.Point, scaleFactor float64, operation ...CalculateFractionPointMode) *gg.Point
ResizePointOneselfX 根据指定的操作返回原始 y 坐标与缩放后的 x 坐标的结果 @param point 要缩放的点 @param scaleFactor 缩放因子,>1 表示放大,<1 表示缩小 @param operation 计算模式 @return 返回经过操作后的新点
func ResizePointOneselfY ¶ added in v0.11.25
func ResizePointOneselfY(point *gg.Point, scaleFactor float64, operation ...CalculateFractionPointMode) *gg.Point
ResizePointOneselfY 根据指定的操作返回原始 x 坐标与缩放后的 y 坐标的结果 @param point 要缩放的点 @param scaleFactor 缩放因子,>1 表示放大,<1 表示缩小 @param operation 计算模式 @return 返回经过操作后的新点
func ResizePoints ¶ added in v0.11.21
ResizePoints 批量缩放多个点,支持不同的 x 和 y 缩放因子 @param points: 需要缩放的点的切片 @param scaleX: x 轴的缩放因子 @param scaleY: y 轴的缩放因子 @return []*gg.Point: 返回缩放后的点的切片
func ResizeUpTriangle ¶ added in v0.11.21
ResizeUpTriangle 根据固定点放大三角形的两个顶点 @params vertexA: 固定点的坐标 @params vertexB: 需要放大的第一个点的坐标 @params vertexC: 需要放大的第二个点的坐标 @params resizeXy: 放大因子,值大于1表示放大 @return: 新的 vertexB 和 vertexC 的坐标
func ResizeX ¶ added in v0.11.21
ResizeX 只缩放 x 坐标 @param point 要缩放的点 @param scaleFactor 缩放因子,>1 表示放大,<1 表示缩小 @return 返回经过 x 坐标缩放后的新点
func ResizeY ¶ added in v0.11.21
ResizeY 只缩放 y 坐标 @param point 要缩放的点 @param scaleFactor 缩放因子,>1 表示放大,<1 表示缩小 @return 返回经过 y 坐标缩放后的新点
func SaveBufToImageFile ¶
func SaveBufToImageFile(buf *bytes.Buffer, filePath string, format ImageFormat) error
SaveBufToImageFile 将Buf数据保存到本地文件
func UpdateBounds ¶ added in v0.11.21
UpdateBounds 更新边界值 @param x 当前坐标的X值 @param y 当前坐标的Y值 @param left 左边界的指针 @param top 上边界的指针 @param right 右边界的指针 @param bottom 下边界的指针
func WriterImage ¶
WriterImage 将图像写入输出
func WriterImageFromBytes ¶
WriterImageFromBytes 将字节切片转换为图像并写入输出
Types ¶
type AxisPointMode ¶ added in v0.11.21
type AxisPointMode int
定义轴的枚举类型
const ( AxisX AxisPointMode = iota // X轴 AxisY // Y轴 )
type CalculateFractionPointMode ¶ added in v0.11.21
type CalculateFractionPointMode int
CalculateFractionPointMode 类型定义,用于表示计算模式
const ( Add CalculateFractionPointMode = iota Subtract Multiply Divide )
func GetPointOperation ¶ added in v0.11.25
func GetPointOperation(operation ...CalculateFractionPointMode) CalculateFractionPointMode
GetPointOperation 从可变参数中获取操作类型,默认为 Subtract @param operation 计算模式 @return 返回操作类型
type CalculateMode ¶ added in v0.11.24
type CalculateMode int
定义计算模式
const ( CalculateMax CalculateMode = iota // 最大值模式 CalculateMin // 最小值模式 CalculateAvg // 平均值模式 )
type Coordinates ¶ added in v0.11.21
type Coordinates struct { Top HorizontalEdge // 上边,包含最左边和最右边的点 Bottom HorizontalEdge // 下边,包含最左边和最右边的点 Left VerticalEdge // 左边,包含顶点和底点 Right VerticalEdge // 右边,包含顶点和底点 }
Coordinates 结构体表示边界框的坐标,包含四条边
func CleanCoordinates ¶ added in v0.11.21
func CleanCoordinates(pointsMap map[string]gg.Point) Coordinates
CleanCoordinates 函数接受一个 map[string]Point,返回清洗后的边界框坐标
type CropImgOptions ¶ added in v0.11.25
type CropImgOptions struct { MinWidth int // 最小裁剪宽度 MinHeight int // 最小裁剪高度 MaxWidth int // 最大裁剪宽度 MaxHeight int // 最大裁剪高度 }
CropImgOptions 定义裁剪图像的选项
type DashOptions ¶ added in v0.11.20
type DashOptions struct {
// contains filtered or unexported fields
}
func NewDashOptions ¶ added in v0.11.20
func NewDashOptions(dashLength, gapLength, lineWidth DashStyle) DashOptions
NewDashOptions 创建一个新的 DashOptions 实例 如果提供了自定义的段长度和间隔长度,则使用它们;否则使用默认值
func (*DashOptions) DashLength ¶ added in v0.11.20
func (d *DashOptions) DashLength() DashStyle
DashLength 返回虚线段长度的 float64 表示
func (*DashOptions) GapLength ¶ added in v0.11.20
func (d *DashOptions) GapLength() DashStyle
GapLength 返回虚线间隔长度的 float64 表示
func (*DashOptions) LineWidth ¶ added in v0.11.21
func (g *DashOptions) LineWidth() DashStyle
获取 LineWidth 的方法
type DelayLine ¶ added in v0.11.25
type DelayLine struct { Enabled bool // 是否绘制该延长线 Dash bool // 是否使用虚线 // contains filtered or unexported fields }
DelayLine 表示每条延长线的绘制状态和是否使用虚线
type GraphicsRenderer ¶ added in v0.11.20
type GraphicsRenderer struct { GgCtx *gg.Context // Gg 上下文 DashOptions DashOptions // 虚实线扩展 // contains filtered or unexported fields }
GraphicsRenderer 结构体用于绘制面部特征
func NewGraphicsRenderer ¶ added in v0.11.20
func NewGraphicsRenderer(ctx *gg.Context, dashOptions ...DashOptions) *GraphicsRenderer
NewGraphicsRenderer 创建一个新的 GraphicsRenderer 实例 @param ctx gg.Context 的指针,用于绘制操作 @param dashOptions @return *GraphicsRenderer 返回一个新的 GraphicsRenderer 实例
func (*GraphicsRenderer) DrawArc ¶ added in v0.11.21
func (g *GraphicsRenderer) DrawArc(startPoint, endPoint *gg.Point, offset float64, clockwise bool)
DrawArc 绘制从 startPoint 到 endPoint 的弧形。 控制点自动计算为起始点和结束点的中点向上偏移一定的高度。 @param startPoint 线条的起始 @param endPoint: 线条的结束点 @param offset 控制点的偏移量 @param clockwise 为 true 表示顺时针,false 表示逆时针。
func (*GraphicsRenderer) DrawCenteredMultiLine ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawCenteredMultiLine(lines []LineSegment)
DrawCenteredMultiLine 在多个指定的线段内绘制多组文本 @param lines 线段的参数数组
func (*GraphicsRenderer) DrawCircle ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawCircle(point *gg.Point, radius float64)
DrawCircle 绘制一个圆形 @param point 圆心的X、Y坐标 @param radius 圆的半径
func (*GraphicsRenderer) DrawCurvedLine ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawCurvedLine(start, end, control *gg.Point)
DrawCurvedLine 绘制带有弯曲度的线条 @param start 起始点 @param end 结束点 @param control 控制点
func (*GraphicsRenderer) DrawEllipse ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawEllipse(point *gg.Point, width, height float64)
DrawEllipse 绘制一个椭圆 @param point 椭圆中心的X、Y坐标 @param width 椭圆的宽度 @param height 椭圆的高度
func (*GraphicsRenderer) DrawHorizontalLine ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawHorizontalLine(line HorizontalLine)
DrawHorizontalLine 从面部左侧到右侧绘制横线 @param line 横线的参数
func (*GraphicsRenderer) DrawLine ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawLine(startPoint, endPoint *gg.Point)
DrawLine 绘制从 startPoint 到 endPoint 的线条。 @param startPoint 线条的起始 @param endPoint: 线条的结束点
func (*GraphicsRenderer) DrawLineXYLineWidth ¶ added in v0.11.21
func (g *GraphicsRenderer) DrawLineXYLineWidth(startX, startY, endX, endY float64)
DrawLineXYLineWidth 绘制线条 @param startX 起始X坐标 @param startY 起始Y坐标 @param endX 结束X坐标 @param endY 结束Y坐标 @param lineWidth 线条宽度
func (*GraphicsRenderer) DrawPoint ¶ added in v0.11.24
func (g *GraphicsRenderer) DrawPoint(point *gg.Point, radius float64)
DrawPoint 绘制一个圆点 @param point 圆心的X、Y坐标 @param radius 圆的半径
func (*GraphicsRenderer) DrawPolygon ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawPolygon(points []gg.Point)
DrawPolygon 绘制一个多边形 @param points 多边形顶点的切片
func (*GraphicsRenderer) DrawRectangle ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawRectangle(rect Rectangle, extendLength float64)
DrawRectangle 绘制矩形框,并可选地绘制延长线 @param rect 矩形的左上角和右下角 @param extendLength 延长线的长度,单位与坐标相同
func (*GraphicsRenderer) DrawTriangle ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawTriangle(x1, y1, x2, y2, x3, y3 float64)
DrawTriangle 绘制一个三角形 @param x1 第一个顶点的X坐标 @param y1 第一个顶点的Y坐标 @param x2 第二个顶点的X坐标 @param y2 第二个顶点的Y坐标 @param x3 第三个顶点的X坐标 @param y3 第三个顶点的Y坐标
func (*GraphicsRenderer) DrawVerticalLine ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawVerticalLine(line VerticalLine)
DrawVerticalLine 从面部顶部到底部绘制竖线 @param line 竖线的参数
func (*GraphicsRenderer) DrawWithStroke ¶ added in v0.11.20
func (g *GraphicsRenderer) DrawWithStroke(drawFunc func(), isStroke bool)
DrawWithStroke 是一个通用的绘图函数,接受一个绘图操作的函数作为参数
func (*GraphicsRenderer) GetDashOptions ¶ added in v0.11.20
func (g *GraphicsRenderer) GetDashOptions() DashOptions
获取 DashOptions 的方法
func (*GraphicsRenderer) SaveImage ¶ added in v0.11.20
func (g *GraphicsRenderer) SaveImage(img image.Image, name string, quality int, imageFormat ImageFormat) error
SaveImage 存储图片 @param img 图像 @param name 文件名名称 @param quality 图片质量 @param imageFormat 图片类型 (目前仅支持PNG/JPG/JPEG)
func (*GraphicsRenderer) SetDashed ¶ added in v0.11.20
func (g *GraphicsRenderer) SetDashed(dashes ...float64)
SetDashed 设置线条 @param dashes
func (*GraphicsRenderer) UseDefaultDashed ¶ added in v0.11.20
func (g *GraphicsRenderer) UseDefaultDashed()
UseDefaultDashed 使用默认虚线
func (*GraphicsRenderer) UseSolidLine ¶ added in v0.11.20
func (g *GraphicsRenderer) UseSolidLine()
UseSolidLine 使用实线
type HorizontalEdge ¶ added in v0.11.21
type HorizontalEdge struct { LeftMost *gg.Point // 最左边的点,表示边的左端点 RightMost *gg.Point // 最右边的点,表示边的右端点 }
HorizontalEdge 结构体表示一个水平边,包括最左边和最右边的点
type HorizontalLine ¶ added in v0.11.24
type HorizontalLine struct { Y float64 // 横线的Y坐标 LeftX float64 // 横线的左侧X坐标 RightX float64 // 横线的右侧X坐标 }
HorizontalLine 表示横线的参数
type ImageFormat ¶
type ImageFormat int
ImageFormat 定义图像格式类型
const ( JPEG ImageFormat = iota JPG PNG GIF )
定义支持的图像格式常量
type ImageLTRB ¶ added in v0.11.20
type ImageLTRB struct { Left float64 // 左边界 Top float64 // 上边界 Right float64 // 右边界 Bottom float64 // 下边界 }
ImageLTRB 表示图像的边界框
func GetLTRB ¶ added in v0.11.21
GetLTRB 获取关键点各部分的点横纵坐标最大小值,即:left,top,right,bottom @param features 面部特征点的映射 @return ImageLTRB 返回包含边界信息的结构体
type LineSegment ¶ added in v0.11.24
type LineSegment struct { StartCoord *gg.Point // 起始坐标 EndCoord *gg.Point // 结束坐标 TextOffsetX float64 // 文本X偏移量 TextOffsetY float64 // 文本Y偏移量 Texts []string // 文本内容 DrawLine bool // 是否绘制线条 SkipDrawTexts bool // 跳过绘制文字 }
LineSegment 表示线段的参数
type PointAddStrategy ¶ added in v0.11.25
type PointAddStrategy struct{}
PointAddStrategy 实现加法操作
func (*PointAddStrategy) Apply ¶ added in v0.11.25
func (s *PointAddStrategy) Apply(value, current float64) float64
type PointDivideStrategy ¶ added in v0.11.25
type PointDivideStrategy struct{}
PointDivideStrategy 实现除法操作
func (*PointDivideStrategy) Apply ¶ added in v0.11.25
func (s *PointDivideStrategy) Apply(value, current float64) float64
type PointMultiplyStrategy ¶ added in v0.11.25
type PointMultiplyStrategy struct{}
PointMultiplyStrategy 实现乘法操作
func (*PointMultiplyStrategy) Apply ¶ added in v0.11.25
func (s *PointMultiplyStrategy) Apply(value, current float64) float64
type PointOperationStrategy ¶ added in v0.11.25
PointOperationStrategy 定义操作策略接口
type PointSubtractStrategy ¶ added in v0.11.25
type PointSubtractStrategy struct{}
PointSubtractStrategy 实现减法操作
func (*PointSubtractStrategy) Apply ¶ added in v0.11.25
func (s *PointSubtractStrategy) Apply(value, current float64) float64
type Rectangle ¶ added in v0.11.24
type Rectangle struct { TopLeft *gg.Point // 矩形的左上角坐标 BottomRight *gg.Point // 矩形的右下角坐标 Extensions *RectangleExtensions // 控制延长线的绘制状态,默认为不绘制 }
Rectangle 表示一个矩形,包含左上角和右下角的坐标,以及控制延长线绘制的选项
func NewRectangle ¶ added in v0.11.25
func NewRectangle(topLeft, bottomRight *gg.Point, rectangleExtensions ...*RectangleExtensions) Rectangle
NewRectangle 创建一个新的矩形,默认延长线不绘制
type RectangleExtensions ¶ added in v0.11.25
type RectangleExtensions struct { RightTop DelayLine // 右上角的上方延长线 RightBottom DelayLine // 右下角的下方延长线 LeftTop DelayLine // 左上角的上方延长线 LeftBottom DelayLine // 左下角的下方延长线 TopLeft DelayLine // 上方的左侧延长线 TopRight DelayLine // 上方的右侧延长线 BottomLeft DelayLine // 下方的左侧延长线 BottomRight DelayLine // 下方的右侧延长线 }
RectangleExtensionFlags 用于控制矩形每个角的延长线绘制状态
func NewRectangleExtensions ¶ added in v0.11.25
func NewRectangleExtensions() *RectangleExtensions
NewRectangleExtensions 创建一个新的 RectangleExtensions 实例,所有字段默认为不绘制且不使用虚线
type ResizeImgOptions ¶ added in v0.11.24
type ResizeImgOptions struct { Width int Height int Filter imaging.ResampleFilter }
缩放图扩展
type VerticalEdge ¶ added in v0.11.21
VerticalEdge 结构体表示一个垂直边,包括顶点和底点
type VerticalLine ¶ added in v0.11.24
type VerticalLine struct { X float64 // 竖线的X坐标 TopY float64 // 竖线的顶部Y坐标 BottomY float64 // 竖线的底部Y坐标 }
VerticalLine 表示竖线的参数