Sub DrawLabelWithRect(LabelObject As ABMCanvasObject, Font As String, Size As Int, Color As String, Text As String, halfX As Int, halfY As Int, rectColor As String, rectBorderColor As String)
LabelObject.Clear
LabelObject.fillStyleColor(rectColor)
LabelObject.strokeStyleColor(rectBorderColor)
' because we 'centered' the origin for the text part, we neeed to undo what we have added for the image part
RoundRect(LabelObject, -halfX, -halfY, halfX*2, halfY*2, 5, True, True)
LabelObject.font(Font, Size)
LabelObject.textBaseline(ABM.CANVAS_TEXTBASELINE_MIDDLE)
LabelObject.textAlign(ABM.CANVAS_TEXTALIGN_CENTER)
LabelObject.fillStyleColor(Color)
LabelObject.fillText(Text, 0, 0)
End Sub
Sub RoundRect(labelObject As ABMCanvasObject, x As Int, y As Int, width As Int, height As Int, radius As Int , fill As Boolean, stroke As Boolean)
labelObject.beginPath
labelObject.moveTo(x + radius, y)
labelObject.lineTo(x + width - radius, y)
labelObject.quadraticCurveTo(x + width, y, x + width, y + radius)
labelObject.lineTo(x + width, y + height - radius)
labelObject.quadraticCurveTo(x + width, y + height, x + width - radius, y + height)
labelObject.lineTo(x + radius, y + height)
labelObject.quadraticCurveTo(x, y + height, x, y + height - radius)
labelObject.lineTo(x, y + radius)
labelObject.quadraticCurveTo(x, y, x + radius, y)
labelObject.closePath
If fill Then
labelObject.fill
End If
If stroke Then
labelObject.stroke
End If
End Sub