# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flatbuffers

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


class Image(object):
    __slots__ = ["_tab"]

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

    # Image
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Image
    def Position(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = o + self._tab.Pos
            from casymda.visualization.web_server.flatbuffers.CanvasPosition import (
                CanvasPosition,
            )

            obj = CanvasPosition()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Image
    def Anchor(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = o + self._tab.Pos
            from casymda.visualization.web_server.flatbuffers.Anchor import Anchor

            obj = Anchor()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Image
    def PhotoId(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(
                flatbuffers.number_types.Uint16Flags, o + self._tab.Pos
            )
        return 0

    # Image
    def Path(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # Image
    def Factor(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.Get(
                flatbuffers.number_types.Float32Flags, o + self._tab.Pos
            )
        return 1.0


def ImageStart(builder):
    builder.StartObject(5)


def ImageAddPosition(builder, position):
    builder.PrependStructSlot(
        0, flatbuffers.number_types.UOffsetTFlags.py_type(position), 0
    )


def ImageAddAnchor(builder, anchor):
    builder.PrependStructSlot(
        1, flatbuffers.number_types.UOffsetTFlags.py_type(anchor), 0
    )


def ImageAddPhotoId(builder, photoId):
    builder.PrependUint16Slot(2, photoId, 0)


def ImageAddPath(builder, path):
    builder.PrependUOffsetTRelativeSlot(
        3, flatbuffers.number_types.UOffsetTFlags.py_type(path), 0
    )


def ImageAddFactor(builder, factor):
    builder.PrependFloat32Slot(4, factor, 1.0)


def ImageEnd(builder):
    return builder.EndObject()
