2025-12-21 17:18:33 +00:00
|
|
|
|
package data
|
|
|
|
|
|
|
2026-02-28 22:31:33 +08:00
|
|
|
|
import "github.com/gogf/gf/v2/util/grand"
|
|
|
|
|
|
|
2025-12-21 17:18:33 +00:00
|
|
|
|
// 1. 质量枚举常量(保持不变)
|
|
|
|
|
|
const (
|
|
|
|
|
|
BitmapFilterQualityLow = 1 // LOW:应用1次滤镜
|
|
|
|
|
|
BitmapFilterQualityMedium = 2 // MEDIUM:应用2次滤镜
|
|
|
|
|
|
BitmapFilterQualityHigh = 3 // HIGH:应用3次滤镜(最大值)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 调整取值范围常量为 uint8 类型(贴合 0-255 范围)
|
|
|
|
|
|
const (
|
|
|
|
|
|
alphaMin = 0.0
|
|
|
|
|
|
alphaMax = 1.0
|
|
|
|
|
|
blurMin uint8 = 0 // BlurX/BlurY 最小值
|
|
|
|
|
|
blurMax uint8 = 255 // BlurX/BlurY 最大值(uint8上限)
|
|
|
|
|
|
strengthMin uint8 = 0 // Strength 最小值
|
|
|
|
|
|
strengthMax uint8 = 255 // Strength 最大值(uint8上限)
|
|
|
|
|
|
qualityMin = BitmapFilterQualityLow
|
|
|
|
|
|
qualityMax = BitmapFilterQualityHigh
|
|
|
|
|
|
colorMax = 0xFFFFFF // 颜色值最大值(0xRRGGBB)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-02-28 22:31:33 +08:00
|
|
|
|
func GetDef() GlowFilter {
|
|
|
|
|
|
|
|
|
|
|
|
ret := GlowFilter{
|
|
|
|
|
|
// Color: 16777215, // 0xFFFFFF(对应JSON的color:16777215)
|
|
|
|
|
|
Alpha: 0.1, // 光圈大小,透明度
|
|
|
|
|
|
BlurX: 8, // 局外光圈大小
|
|
|
|
|
|
BlurY: 8, // 局外光圈大小
|
|
|
|
|
|
Strength: 8, // 颜色对比度
|
|
|
|
|
|
Quality: 1, // 背包内光圈大小
|
|
|
|
|
|
Inner: true, // 对应JSON的inner:true
|
|
|
|
|
|
Knockout: false, // 无JSON值,默认false
|
|
|
|
|
|
ColorMatrixFilter: [20]float32{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0}, // 对应JSON的matrix数组
|
|
|
|
|
|
Level: 2, // 对应JSON的level:"1"(转uint8)
|
|
|
|
|
|
}
|
|
|
|
|
|
ret.Color = RandomRGBToUint32()
|
|
|
|
|
|
return ret
|
2026-02-21 17:41:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-28 22:31:33 +08:00
|
|
|
|
// RandomRGBToUint32 生成随机RGB颜色并转为uint32(格式:0x00RRGGBB,最高8位留空)
|
|
|
|
|
|
func RandomRGBToUint32() uint32 {
|
|
|
|
|
|
// 生成0-255的随机R/G/B分量
|
|
|
|
|
|
r := uint32(grand.Intn(256))
|
|
|
|
|
|
g := uint32(grand.Intn(256))
|
|
|
|
|
|
b := uint32(grand.Intn(256))
|
2026-02-21 17:41:49 +08:00
|
|
|
|
|
2026-02-28 22:31:33 +08:00
|
|
|
|
// 位拼接:R左移16位,G左移8位,B不位移,组合成uint32
|
|
|
|
|
|
return (r << 16) | (g << 8) | b
|
2026-02-21 17:41:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-21 17:18:33 +00:00
|
|
|
|
// 精灵加shinylen字段
|
|
|
|
|
|
// 3. 核心结构体:BlurX/BlurY/Strength 改为 uint8
|
|
|
|
|
|
type GlowFilter struct {
|
|
|
|
|
|
// Color 光晕颜色,十六进制格式 0xRRGGBB,默认值 0xFF0000(红色)
|
|
|
|
|
|
Color uint32 `json:"color,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// Alpha 透明度,0.0~1.0(浮点型,无法用uint8,保留float64)
|
|
|
|
|
|
Alpha float32 `json:"alpha,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// BlurX 水平模糊量,0~255(uint8),默认值 6
|
|
|
|
|
|
BlurX uint8 `json:"blurX,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// BlurY 垂直模糊量,0~255(uint8),默认值 6
|
|
|
|
|
|
BlurY uint8 `json:"blurY,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// Strength 发光强度,0~255(uint8),默认值 2
|
|
|
|
|
|
Strength uint8 `json:"strength,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// Quality 滤镜应用次数,1~3,默认值 1
|
|
|
|
|
|
Quality int `json:"quality,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// Inner 是否内侧发光,默认 false
|
|
|
|
|
|
Inner bool `json:"inner,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// Knockout 是否挖空,默认 false
|
|
|
|
|
|
Knockout bool `json:"knockout,omitempty"`
|
|
|
|
|
|
ColorMatrixFilter [20]float32 `json:"matrix,omitempty"`
|
2026-01-25 23:17:46 +08:00
|
|
|
|
Level uint8 `json:"level,omitempty"` //等级
|
2025-12-21 17:18:33 +00:00
|
|
|
|
}
|
2025-12-26 20:38:08 +08:00
|
|
|
|
|
|
|
|
|
|
// ItemInfo
|
|
|
|
|
|
// 用于表示发放物品的信息
|
|
|
|
|
|
type ItemInfo struct {
|
2026-02-12 04:28:20 +08:00
|
|
|
|
ItemId int64 `struc:"uint32"`
|
|
|
|
|
|
ItemCnt int64 `struc:"uint32"`
|
2025-12-26 20:38:08 +08:00
|
|
|
|
}
|