Documentation
¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2024-12-09 12:15:51 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-05-28 17:15:25 * @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 ¶
- Variables
- 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 MatchesAnyPattern(input string, patterns []string) bool
- 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 ¶
var DefaultImgPatterns = []string{"*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp", "*.webp", "*.tiff"}
Functions ¶
func AddOverlay ¶
AddOverlay 接受一个 img.Image 和一个颜色,返回添加了蒙层的 img.Image
func AdjustValues ¶
AdjustValues 根据目标值调整起始和结束值
func CalculateControlPoint ¶
CalculateControlPoint 计算控制点以实现弯曲效果 @param startPoint 起始点 @param endPoint 结束点 @param offsetX 坐标X偏移量 @param offsetY 坐标Y偏移量 @return *gg.Point 返回计算得到的控制点
func CalculateFractionPoint ¶
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 ¶
func CalculateMultiplePoints(points []*gg.Point, calculateMode CalculateMode, axisMode ...AxisPointMode) *gg.Point
CalculateMultiplePoints 计算多个点中的最大或最小点 @param points 要比较的点的切片 @param calculateMode 指定是取最大点还是最小点(PointMaxMin 枚举类型) @param axisMode 指定比较的轴(AxisPointMode 枚举类型、默认X) @return 返回在指定维度上较大的或较小的点
func CalculatePoint ¶
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 ¶
CanFormTriangle 判断三个点是否能构成三角形 @param points 三个点的切片,必须包含三个点 @return area 三角形的面积,如果能构成三角形则返回面积,
bool 表示是否能构成三角形,error 表示是否有错误
func CropImage ¶
func CropImage(img image.Image, cropImgOptions *CropImgOptions) image.Image
CropImage 裁剪图片 @param img: 要裁剪的原始图像(image.Image类型) @param cropImgOptions: 裁剪选项(*CropImgOptions类型),包含裁剪的最小和最大宽高 return
返回裁剪后的图像(image.Image类型)
func EncodeImageToBase64 ¶
EncodeImageToBase64 将图像编码为 Base64 字符串
func ExtendLine ¶
ExtendLine 从起始点 p1 延长到 p2,返回延长线的终点坐标 p1 是起始点,p2 是终止点,length 是延长的长度
func LoadImageFromFile ¶
LoadImageFromFile 从给定的文件路径加载图片并返回 image.Image 对象
func LoadImageFromFileAndEncodeToBase64 ¶
func LoadImageFromFileAndEncodeToBase64(filePath string, format ImageFormat, quality int) (string, error)
LoadImageFromFileAndEncodeToBase64 从文件加载图片并返回 Base64 编码字符串
func LoadImageFromURL ¶
LoadImageFromURL 从给定的 URL 加载图片并返回 image.Image 对象
func MatchesAnyPattern ¶
MatchesAnyPattern 判断 input 字符串是否匹配 patterns 中任意一个通配符模式(不区分大小写)
func ModifyPoint ¶
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 ¶
func OffsetPointX(point *gg.Point, offset float64, operation ...CalculateFractionPointMode) *gg.Point
OffsetPointX 根据指定的操作返回原始 y 坐标与偏移后的 x 坐标的结果 @param point 要缩放的点 @param offset 偏移量 @param operation 计算模式 @return 返回经过操作后的新点
func OffsetPointY ¶
func OffsetPointY(point *gg.Point, offset float64, operation ...CalculateFractionPointMode) *gg.Point
OffsetPointY 根据指定的操作返回原始 x 坐标与偏移后的 y 坐标的结果 @param point 要缩放的点 @param offset 偏移量 @param operation 计算模式 @return 返回经过操作后的新点
func ResizeDownTriangle ¶
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 ¶
func ResizeImage(img image.Image, resizeImgOptions *ResizeImgOptions) image.Image
ResizeImage 缩放图片 @param img: 要缩放的原始图像(image.Image类型) @param resizeImgOptions: 缩放选项(*CropImgOptions类型),包含缩放的宽高 return
返回缩放后的图像(image.Image类型)
func ResizePoint ¶
ResizePoint 单个坐标轴的等比例缩放 @param point 要缩放的点 @param resizeX x 坐标的缩放因子 @param resizeY y 坐标的缩放因子 @return 返回同时经过 x 和 y 坐标缩放后的新点
func ResizePointOneselfX ¶
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 ¶
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 ¶
ResizePoints 批量缩放多个点,支持不同的 x 和 y 缩放因子 @param points: 需要缩放的点的切片 @param scaleX: x 轴的缩放因子 @param scaleY: y 轴的缩放因子 @return []*gg.Point: 返回缩放后的点的切片
func ResizeUpTriangle ¶
ResizeUpTriangle 根据固定点放大三角形的两个顶点 @params vertexA: 固定点的坐标 @params vertexB: 需要放大的第一个点的坐标 @params vertexC: 需要放大的第二个点的坐标 @params resizeXy: 放大因子,值大于1表示放大 @return: 新的 vertexB 和 vertexC 的坐标
func ResizeX ¶
ResizeX 只缩放 x 坐标 @param point 要缩放的点 @param scaleFactor 缩放因子,>1 表示放大,<1 表示缩小 @return 返回经过 x 坐标缩放后的新点
func ResizeY ¶
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 ¶
UpdateBounds 更新边界值 @param x 当前坐标的X值 @param y 当前坐标的Y值 @param left 左边界的指针 @param top 上边界的指针 @param right 右边界的指针 @param bottom 下边界的指针
func WriterImage ¶
WriterImage 将图像写入输出
func WriterImageFromBytes ¶
WriterImageFromBytes 将字节切片转换为图像并写入输出
Types ¶
type AxisPointMode ¶
type AxisPointMode int
定义轴的枚举类型
const ( AxisX AxisPointMode = iota // X轴 AxisY // Y轴 )
type CalculateFractionPointMode ¶
type CalculateFractionPointMode int
CalculateFractionPointMode 类型定义,用于表示计算模式
const ( Add CalculateFractionPointMode = iota Subtract Multiply Divide )
func GetPointOperation ¶
func GetPointOperation(operation ...CalculateFractionPointMode) CalculateFractionPointMode
GetPointOperation 从可变参数中获取操作类型,默认为 Subtract @param operation 计算模式 @return 返回操作类型
type CalculateMode ¶
type CalculateMode int
定义计算模式
const ( CalculateMax CalculateMode = iota // 最大值模式 CalculateMin // 最小值模式 CalculateAvg // 平均值模式 )
type Coordinates ¶
type Coordinates struct {
Top HorizontalEdge // 上边,包含最左边和最右边的点
Bottom HorizontalEdge // 下边,包含最左边和最右边的点
Left VerticalEdge // 左边,包含顶点和底点
Right VerticalEdge // 右边,包含顶点和底点
}
Coordinates 结构体表示边界框的坐标,包含四条边
func CleanCoordinates ¶
func CleanCoordinates(pointsMap map[string]gg.Point) Coordinates
CleanCoordinates 函数接受一个 map[string]Point,返回清洗后的边界框坐标
type CropImgOptions ¶
type CropImgOptions struct {
MinWidth int // 最小裁剪宽度
MinHeight int // 最小裁剪高度
MaxWidth int // 最大裁剪宽度
MaxHeight int // 最大裁剪高度
}
CropImgOptions 定义裁剪图像的选项
type DashOptions ¶
type DashOptions struct {
// contains filtered or unexported fields
}
func NewDashOptions ¶
func NewDashOptions(dashLength, gapLength, lineWidth DashStyle) DashOptions
NewDashOptions 创建一个新的 DashOptions 实例 如果提供了自定义的段长度和间隔长度,则使用它们;否则使用默认值
func (*DashOptions) DashLength ¶
func (d *DashOptions) DashLength() DashStyle
DashLength 返回虚线段长度的 float64 表示
func (*DashOptions) GapLength ¶
func (d *DashOptions) GapLength() DashStyle
GapLength 返回虚线间隔长度的 float64 表示
type DelayLine ¶
type DelayLine struct {
Enabled bool // 是否绘制该延长线
Dash bool // 是否使用虚线
// contains filtered or unexported fields
}
DelayLine 表示每条延长线的绘制状态和是否使用虚线
type GraphicsRenderer ¶
type GraphicsRenderer struct {
GgCtx *gg.Context // Gg 上下文
DashOptions DashOptions // 虚实线扩展
// contains filtered or unexported fields
}
GraphicsRenderer 结构体用于绘制面部特征
func NewGraphicsRenderer ¶
func NewGraphicsRenderer(ctx *gg.Context, dashOptions ...DashOptions) *GraphicsRenderer
NewGraphicsRenderer 创建一个新的 GraphicsRenderer 实例 @param ctx gg.Context 的指针,用于绘制操作 @param dashOptions @return *GraphicsRenderer 返回一个新的 GraphicsRenderer 实例
func (*GraphicsRenderer) DrawArc ¶
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 ¶
func (g *GraphicsRenderer) DrawCenteredMultiLine(lines []LineSegment)
DrawCenteredMultiLine 在多个指定的线段内绘制多组文本 @param lines 线段的参数数组
func (*GraphicsRenderer) DrawCircle ¶
func (g *GraphicsRenderer) DrawCircle(point *gg.Point, radius float64)
DrawCircle 绘制一个圆形 @param point 圆心的X、Y坐标 @param radius 圆的半径
func (*GraphicsRenderer) DrawCurvedLine ¶
func (g *GraphicsRenderer) DrawCurvedLine(start, end, control *gg.Point)
DrawCurvedLine 绘制带有弯曲度的线条 @param start 起始点 @param end 结束点 @param control 控制点
func (*GraphicsRenderer) DrawEllipse ¶
func (g *GraphicsRenderer) DrawEllipse(point *gg.Point, width, height float64)
DrawEllipse 绘制一个椭圆 @param point 椭圆中心的X、Y坐标 @param width 椭圆的宽度 @param height 椭圆的高度
func (*GraphicsRenderer) DrawHorizontalLine ¶
func (g *GraphicsRenderer) DrawHorizontalLine(line HorizontalLine)
DrawHorizontalLine 从面部左侧到右侧绘制横线 @param line 横线的参数
func (*GraphicsRenderer) DrawLine ¶
func (g *GraphicsRenderer) DrawLine(startPoint, endPoint *gg.Point)
DrawLine 绘制从 startPoint 到 endPoint 的线条。 @param startPoint 线条的起始 @param endPoint: 线条的结束点
func (*GraphicsRenderer) DrawLineXYLineWidth ¶
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 ¶
func (g *GraphicsRenderer) DrawPoint(point *gg.Point, radius float64)
DrawPoint 绘制一个圆点 @param point 圆心的X、Y坐标 @param radius 圆的半径
func (*GraphicsRenderer) DrawPolygon ¶
func (g *GraphicsRenderer) DrawPolygon(points []gg.Point)
DrawPolygon 绘制一个多边形 @param points 多边形顶点的切片
func (*GraphicsRenderer) DrawRectangle ¶
func (g *GraphicsRenderer) DrawRectangle(rect Rectangle, extendLength float64)
DrawRectangle 绘制矩形框,并可选地绘制延长线 @param rect 矩形的左上角和右下角 @param extendLength 延长线的长度,单位与坐标相同
func (*GraphicsRenderer) DrawTriangle ¶
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 ¶
func (g *GraphicsRenderer) DrawVerticalLine(line VerticalLine)
DrawVerticalLine 从面部顶部到底部绘制竖线 @param line 竖线的参数
func (*GraphicsRenderer) DrawWithStroke ¶
func (g *GraphicsRenderer) DrawWithStroke(drawFunc func(), isStroke bool)
DrawWithStroke 是一个通用的绘图函数,接受一个绘图操作的函数作为参数
func (*GraphicsRenderer) GetDashOptions ¶
func (g *GraphicsRenderer) GetDashOptions() DashOptions
获取 DashOptions 的方法
func (*GraphicsRenderer) SaveImage ¶
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 ¶
func (g *GraphicsRenderer) SetDashed(dashes ...float64)
SetDashed 设置线条 @param dashes
func (*GraphicsRenderer) UseDefaultDashed ¶
func (g *GraphicsRenderer) UseDefaultDashed()
UseDefaultDashed 使用默认虚线
type HorizontalEdge ¶
type HorizontalEdge struct {
LeftMost *gg.Point // 最左边的点,表示边的左端点
RightMost *gg.Point // 最右边的点,表示边的右端点
}
HorizontalEdge 结构体表示一个水平边,包括最左边和最右边的点
type HorizontalLine ¶
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 ¶
type ImageLTRB struct {
Left float64 // 左边界
Top float64 // 上边界
Right float64 // 右边界
Bottom float64 // 下边界
}
ImageLTRB 表示图像的边界框
type LineSegment ¶
type LineSegment struct {
StartCoord *gg.Point // 起始坐标
EndCoord *gg.Point // 结束坐标
TextOffsetX float64 // 文本X偏移量
TextOffsetY float64 // 文本Y偏移量
Texts []string // 文本内容
DrawLine bool // 是否绘制线条
SkipDrawTexts bool // 跳过绘制文字
}
LineSegment 表示线段的参数
type PointAddStrategy ¶
type PointAddStrategy struct{}
PointAddStrategy 实现加法操作
func (*PointAddStrategy) Apply ¶
func (s *PointAddStrategy) Apply(value, current float64) float64
type PointDivideStrategy ¶
type PointDivideStrategy struct{}
PointDivideStrategy 实现除法操作
func (*PointDivideStrategy) Apply ¶
func (s *PointDivideStrategy) Apply(value, current float64) float64
type PointMultiplyStrategy ¶
type PointMultiplyStrategy struct{}
PointMultiplyStrategy 实现乘法操作
func (*PointMultiplyStrategy) Apply ¶
func (s *PointMultiplyStrategy) Apply(value, current float64) float64
type PointOperationStrategy ¶
PointOperationStrategy 定义操作策略接口
type PointSubtractStrategy ¶
type PointSubtractStrategy struct{}
PointSubtractStrategy 实现减法操作
func (*PointSubtractStrategy) Apply ¶
func (s *PointSubtractStrategy) Apply(value, current float64) float64
type Rectangle ¶
type Rectangle struct {
TopLeft *gg.Point // 矩形的左上角坐标
BottomRight *gg.Point // 矩形的右下角坐标
Extensions *RectangleExtensions // 控制延长线的绘制状态,默认为不绘制
}
Rectangle 表示一个矩形,包含左上角和右下角的坐标,以及控制延长线绘制的选项
func NewRectangle ¶
func NewRectangle(topLeft, bottomRight *gg.Point, rectangleExtensions ...*RectangleExtensions) Rectangle
NewRectangle 创建一个新的矩形,默认延长线不绘制
type RectangleExtensions ¶
type RectangleExtensions struct {
RightTop DelayLine // 右上角的上方延长线
RightBottom DelayLine // 右下角的下方延长线
LeftTop DelayLine // 左上角的上方延长线
LeftBottom DelayLine // 左下角的下方延长线
TopLeft DelayLine // 上方的左侧延长线
TopRight DelayLine // 上方的右侧延长线
BottomLeft DelayLine // 下方的左侧延长线
BottomRight DelayLine // 下方的右侧延长线
}
RectangleExtensionFlags 用于控制矩形每个角的延长线绘制状态
func NewRectangleExtensions ¶
func NewRectangleExtensions() *RectangleExtensions
NewRectangleExtensions 创建一个新的 RectangleExtensions 实例,所有字段默认为不绘制且不使用虚线
type ResizeImgOptions ¶
type ResizeImgOptions struct {
Width int
Height int
Filter imaging.ResampleFilter
}
缩放图扩展
type VerticalEdge ¶
VerticalEdge 结构体表示一个垂直边,包括顶点和底点
type VerticalLine ¶
type VerticalLine struct {
X float64 // 竖线的X坐标
TopY float64 // 竖线的顶部Y坐标
BottomY float64 // 竖线的底部Y坐标
}
VerticalLine 表示竖线的参数