コード例 #1
0
ファイル: layer.py プロジェクト: logicplace/pytmxlib
 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
コード例 #2
0
ファイル: layer.py プロジェクト: MikeTam1021/pytmxlib
 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
コード例 #3
0
ファイル: tileset.py プロジェクト: pedro-b/pytmxlib
 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
コード例 #4
0
ファイル: tileset.py プロジェクト: crempp/pytmxlib
 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
コード例 #5
0
ファイル: map.py プロジェクト: Connor124/Gran-Theft-Crop-Toe
    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
コード例 #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