MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / adjustOpacity

Function adjustOpacity

plugin/klala/draw.go:341–354  ·  view source on GitHub ↗

adjustOpacity 更改透明度

(m image.Image, percentage float64)

Source from the content-addressed store, hash-verified

339
340// adjustOpacity 更改透明度
341func adjustOpacity(m image.Image, percentage float64) image.Image {
342 bounds := m.Bounds()
343 dx, dy := bounds.Dx(), bounds.Dy()
344 nimg := image.NewRGBA64(bounds)
345 for i := 0; i < dx; i++ {
346 for j := 0; j < dy; j++ {
347 r, g, b, a := m.At(i, j).RGBA()
348 opacity := uint16(float64(a) * percentage)
349 r, g, b, a = nimg.ColorModel().Convert(color.NRGBA64{R: uint16(r), G: uint16(g), B: uint16(b), A: opacity}).RGBA()
350 nimg.SetRGBA64(i, j, color.RGBA64{R: uint16(r), G: uint16(g), B: uint16(b), A: uint16(a)})
351 }
352 }
353 return nimg
354}

Callers 1

drawcardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected