# automatically generated by the FlatBuffers compiler, do not modify

# namespace: foxglove

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# A text label on a 2D image
class TextAnnotation(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = TextAnnotation()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsTextAnnotation(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # TextAnnotation
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Timestamp of annotation
    # TextAnnotation
    def Timestamp(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = o + self._tab.Pos
            from .Time import Time
            obj = Time()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Bottom-left origin of the text label in 2D image coordinates (pixels).
    # The coordinate uses the top-left corner of the top-left pixel of the image as the origin.
    # TextAnnotation
    def Position(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Point2 import Point2
            obj = Point2()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Text to display
    # TextAnnotation
    def Text(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # Font size in pixels
    # TextAnnotation
    def FontSize(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 12.0

    # Text color
    # TextAnnotation
    def TextColor(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Color import Color
            obj = Color()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Background fill color
    # TextAnnotation
    def BackgroundColor(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Color import Color
            obj = Color()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def TextAnnotationStart(builder): builder.StartObject(6)
def Start(builder):
    return TextAnnotationStart(builder)
def TextAnnotationAddTimestamp(builder, timestamp): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(timestamp), 0)
def AddTimestamp(builder, timestamp):
    return TextAnnotationAddTimestamp(builder, timestamp)
def TextAnnotationAddPosition(builder, position): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(position), 0)
def AddPosition(builder, position):
    return TextAnnotationAddPosition(builder, position)
def TextAnnotationAddText(builder, text): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(text), 0)
def AddText(builder, text):
    return TextAnnotationAddText(builder, text)
def TextAnnotationAddFontSize(builder, fontSize): builder.PrependFloat64Slot(3, fontSize, 12.0)
def AddFontSize(builder, fontSize):
    return TextAnnotationAddFontSize(builder, fontSize)
def TextAnnotationAddTextColor(builder, textColor): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(textColor), 0)
def AddTextColor(builder, textColor):
    return TextAnnotationAddTextColor(builder, textColor)
def TextAnnotationAddBackgroundColor(builder, backgroundColor): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(backgroundColor), 0)
def AddBackgroundColor(builder, backgroundColor):
    return TextAnnotationAddBackgroundColor(builder, backgroundColor)
def TextAnnotationEnd(builder): return builder.EndObject()
def End(builder):
    return TextAnnotationEnd(builder)