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

Function drawStars

plugin/klala/draw.go:314–338  ·  view source on GitHub ↗

drawStars 画星星

(side, all string, num int)

Source from the content-addressed store, hash-verified

312
313// drawStars 画星星
314func drawStars(side, all string, num int) image.Image {
315 dc := gg.NewContext(500, 80)
316 n := 5
317 points := Polygon(n)
318 for x, i := 40, 0; i < num; x += 80 {
319 dc.Push()
320 // s := rand.Float64()*S/4 + S/4
321 dc.Translate(float64(x), 45)
322 // dc.Rotate(rand.Float64() * 1.5 * math.Pi) //旋转
323 dc.Scale(30, 30) // 大小
324 for i := 0; i < n+1; i++ {
325 index := (i * 2) % n
326 p := points[index]
327 dc.LineTo(p.X, p.Y)
328 }
329 dc.SetLineWidth(10)
330 dc.SetHexColor(side) // 线
331 dc.StrokePreserve()
332 dc.SetHexColor(all)
333 dc.Fill()
334 dc.Pop()
335 i++
336 }
337 return dc.Image()
338}
339
340// adjustOpacity 更改透明度
341func adjustOpacity(m image.Image, percentage float64) image.Image {

Callers 1

drawcardMethod · 0.85

Calls 1

PolygonFunction · 0.85

Tested by

no test coverage detected