MCPcopy
hub / github.com/FloatTech/ZeroBot-Plugin / customtext

Function customtext

plugin/score/draw.go:427–490  ·  view source on GitHub ↗
(a *scdata, fontdata []byte, cw, ch, aw float64, textcolor color.Color)

Source from the content-addressed store, hash-verified

425}
426
427func customtext(a *scdata, fontdata []byte, cw, ch, aw float64, textcolor color.Color) (img image.Image, err error) {
428 canvas := gg.NewContext(int(cw), int(ch))
429 canvas.SetColor(textcolor)
430 scw, sch := cw*6/10, ch*6/10
431 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2)
432 if err != nil {
433 return
434 }
435 canvas.DrawStringAnchored(a.nickname, (ch-sch)/2/2+aw/2+aw/40*2, (ch-sch)/2/2, 0, 0.5)
436 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3*2)
437 if err != nil {
438 return
439 }
440 canvas.DrawStringAnchored(time.Now().Format("2006/01/02"), cw-cw/6, ch/2-sch/2-canvas.FontHeight(), 0.5, 0.5)
441
442 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2)
443 if err != nil {
444 return
445 }
446 nextrankScore := 0
447 if a.rank < 10 {
448 nextrankScore = rankArray[a.rank+1]
449 } else {
450 nextrankScore = SCOREMAX
451 }
452 nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore)
453
454 canvas.DrawStringAnchored("Level "+strconv.Itoa(a.rank), cw/3*2-scw/2, ch/2+sch/2+canvas.FontHeight(), 0, 0.5)
455 canvas.DrawStringAnchored(nextLevelStyle, cw/3*2+scw/2, ch/2+sch/2+canvas.FontHeight(), 1, 0.5)
456
457 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3)
458 if err != nil {
459 return
460 }
461
462 canvas.DrawStringAnchored("Create By ZeroBot-Plugin "+banner.Version, 0+4, ch, 0, -0.5)
463
464 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5*3)
465 if err != nil {
466 return
467 }
468
469 tempfh := canvas.FontHeight()
470
471 canvas.DrawStringAnchored(getHourWord(time.Now()), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4, 0, 0.5)
472
473 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5)
474 if err != nil {
475 return
476 }
477
478 canvas.DrawStringAnchored(wallet.GetWalletName()+" + "+strconv.Itoa(a.inc), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh, 0, 0.5)
479 canvas.DrawStringAnchored("EXP + 1", ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh+canvas.FontHeight(), 0, 1)
480
481 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/4)
482 if err != nil {
483 return
484 }

Callers 1

drawScore17b2Function · 0.85

Calls 2

getHourWordFunction · 0.85
FormatMethod · 0.80

Tested by

no test coverage detected