Esempio n. 1
0
 def to_dict(self):
     """Export to a dict compatible with Tiled's JSON plugin"""
     d = super(ObjectLayer, self).to_dict()
     d.update(dict(type='objectgroup', objects=[o.to_dict() for o in self]))
     if self.color:
         d['color'] = '#' + fileio.to_hexcolor(self.color)
     return d
Esempio n. 2
0
 def to_dict(self):
     """Export to a dict compatible with Tiled's JSON plugin"""
     d = super(ObjectLayer, self).to_dict()
     d.update(dict(
             type='objectgroup',
             objects=[o.to_dict() for o in self]
         ))
     if self.color:
         d['color'] = '#' + fileio.to_hexcolor(self.color)
     return d
Esempio n. 3
0
 def to_dict(self, **kwargs):
     """Export to a dict compatible with Tiled's JSON plugin"""
     d = super(ImageTileset, self).to_dict(**kwargs)
     d.update(dict(
             image=self.image.source,
             imageheight=self.image.height,
             imagewidth=self.image.width,
             margin=self.margin,
             spacing=self.spacing,
             tilewidth=self.tile_width,
             tileheight=self.tile_height,
         ))
     if self.image.trans:
         d['transparentcolor'] = '#' + fileio.to_hexcolor(self.image.trans)
     return d
Esempio n. 4
0
 def to_dict(self, **kwargs):
     """Export to a dict compatible with Tiled's JSON plugin"""
     d = super(ImageTileset, self).to_dict(**kwargs)
     d.update(
         dict(
             image=self.image.source,
             imageheight=self.image.height,
             imagewidth=self.image.width,
             margin=self.margin,
             spacing=self.spacing,
             tilewidth=self.tile_width,
             tileheight=self.tile_height,
         ))
     if self.image.trans:
         d['transparentcolor'] = '#' + fileio.to_hexcolor(self.image.trans)
     return d
Esempio n. 5
0
    def to_dict(self):
        """Export to a dict compatible with Tiled's JSON plugin

        You can use e.g. a JSON or YAML library to write such a dict to a file.
        """
        d = dict(
                height=self.height,
                width=self.width,
                tileheight=self.tile_height,
                tilewidth=self.tile_width,
                orientation=self.orientation,
                properties=self.properties,
                version=1,
                layers=[la.to_dict() for la in self.layers],
                tilesets=[t.to_dict(map=self) for t in self.tilesets],
            )
        if self.background_color:
            d['backgroundcolor'] = '#' + fileio.to_hexcolor(
                self.background_color)
        return d
Esempio n. 6
0
    def to_dict(self):
        """Export to a dict compatible with Tiled's JSON plugin

        You can use e.g. a JSON or YAML library to write such a dict to a file.
        """
        d = dict(
            height=self.height,
            width=self.width,
            tileheight=self.tile_height,
            tilewidth=self.tile_width,
            orientation=self.orientation,
            properties=self.properties,
            version=1,
            layers=[la.to_dict() for la in self.layers],
            tilesets=[t.to_dict(map=self) for t in self.tilesets],
        )
        if self.background_color:
            d['backgroundcolor'] = '#' + fileio.to_hexcolor(
                self.background_color)
        return d