MCPcopy Create free account
hub / github.com/FloatTech/NanoBot-Plugin / customtext

Function customtext

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

Source from the content-addressed store, hash-verified

183}
184
185func customtext(a *scoredata, fontdata []byte, cw, ch, aw float64, textcolor color.Color) (img image.Image, err error) {
186 canvas := gg.NewContext(int(cw), int(ch))
187 canvas.SetColor(textcolor)
188 scw, sch := cw*6/10, ch*6/10
189 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2)
190 if err != nil {
191 return
192 }
193 canvas.DrawStringAnchored(a.nickname, (ch-sch)/2/2+aw/2+aw/40*2, (ch-sch)/2/2, 0, 0.5)
194 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3*2)
195 if err != nil {
196 return
197 }
198 canvas.DrawStringAnchored(time.Now().Format("2006/01/02"), cw-cw/6, ch/2-sch/2-canvas.FontHeight(), 0.5, 0.5)
199
200 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2)
201 if err != nil {
202 return
203 }
204 nextrankScore := 0
205 if a.rank < 10 {
206 nextrankScore = rankArray[a.rank+1]
207 } else {
208 nextrankScore = scoreMax
209 }
210 nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore)
211
212 canvas.DrawStringAnchored("Level "+strconv.Itoa(a.rank), cw/3*2-scw/2, ch/2+sch/2+canvas.FontHeight(), 0, 0.5)
213 canvas.DrawStringAnchored(nextLevelStyle, cw/3*2+scw/2, ch/2+sch/2+canvas.FontHeight(), 1, 0.5)
214
215 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3)
216 if err != nil {
217 return
218 }
219
220 canvas.DrawStringAnchored("Create By NanoBot-Plugin "+banner.Version, 0+4, ch, 0, -0.5)
221
222 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5*3)
223 if err != nil {
224 return
225 }
226
227 tempfh := canvas.FontHeight()
228
229 canvas.DrawStringAnchored(getHourWord(time.Now()), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4, 0, 0.5)
230
231 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5)
232 if err != nil {
233 return
234 }
235
236 canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(a.inc), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh, 0, 0.5)
237 canvas.DrawStringAnchored("EXP + 1", ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh+canvas.FontHeight(), 0, 1)
238
239 err = canvas.ParseFontFace(fontdata, (ch-sch)/2/4)
240 if err != nil {
241 return
242 }

Callers 1

floatstyleFunction · 0.85

Calls 2

getHourWordFunction · 0.85
FormatMethod · 0.80

Tested by

no test coverage detected