refactor: 注释掉绘制函数中的日志输出,以减少调试信息,保持代码整洁。
This commit is contained in:
19
sprite/2d.go
19
sprite/2d.go
@@ -4,7 +4,6 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"log"
|
||||
|
||||
"git.lxtend.com/lixiangwuxian/imagedd/drawhelper"
|
||||
)
|
||||
@@ -18,8 +17,8 @@ type Line struct {
|
||||
|
||||
// AddToSprite 在精灵图上绘制线条,保留原有的图像
|
||||
func (l *Line) AddToSprite(sprite *Sprite) {
|
||||
log.Printf("开始绘制线条: 起点(%d,%d) 终点(%d,%d) 宽度%d",
|
||||
l.Start.X, l.Start.Y, l.End.X, l.End.Y, l.Width)
|
||||
// log.Printf("开始绘制线条: 起点(%d,%d) 终点(%d,%d) 宽度%d",
|
||||
// l.Start.X, l.Start.Y, l.End.X, l.End.Y, l.Width)
|
||||
|
||||
// 检查精灵是否已有图像
|
||||
if sprite.Image == nil {
|
||||
@@ -35,15 +34,15 @@ func (l *Line) AddToSprite(sprite *Sprite) {
|
||||
img := image.NewRGBA(image.Rect(0, 0, width, height))
|
||||
sprite.Image = img
|
||||
sprite.Position = l.Start
|
||||
log.Printf("创建新图像: 大小(%d,%d) 位置(%d,%d)",
|
||||
width, height, sprite.Position.X, sprite.Position.Y)
|
||||
// log.Printf("创建新图像: 大小(%d,%d) 位置(%d,%d)",
|
||||
// width, height, sprite.Position.X, sprite.Position.Y)
|
||||
}
|
||||
|
||||
// 获取当前图像大小和位置
|
||||
bounds := sprite.Image.Bounds()
|
||||
width, height := bounds.Dx(), bounds.Dy()
|
||||
log.Printf("当前图像: 大小(%d,%d) 位置(%d,%d)",
|
||||
width, height, sprite.Position.X, sprite.Position.Y)
|
||||
// width, height := bounds.Dx(), bounds.Dy()
|
||||
// log.Printf("当前图像: 大小(%d,%d) 位置(%d,%d)",
|
||||
// width, height, sprite.Position.X, sprite.Position.Y)
|
||||
|
||||
// 直接使用原图像,不再扩展
|
||||
var newImage *image.RGBA
|
||||
@@ -52,7 +51,7 @@ func (l *Line) AddToSprite(sprite *Sprite) {
|
||||
// 如果原图像不是RGBA,转换为RGBA
|
||||
newImage = image.NewRGBA(bounds)
|
||||
draw.Draw(newImage, bounds, sprite.Image, bounds.Min, draw.Src)
|
||||
log.Printf("转换图像为RGBA格式")
|
||||
// log.Printf("转换图像为RGBA格式")
|
||||
}
|
||||
|
||||
// 在图像上绘制线条,根据线宽决定使用哪个函数
|
||||
@@ -67,7 +66,7 @@ func (l *Line) AddToSprite(sprite *Sprite) {
|
||||
|
||||
// 更新精灵图像
|
||||
sprite.Image = newImage
|
||||
log.Printf("线条绘制完成")
|
||||
// log.Printf("线条绘制完成")
|
||||
}
|
||||
|
||||
type Circle struct {
|
||||
|
||||
Reference in New Issue
Block a user