コード例 #1
0
ファイル: parser.py プロジェクト: beans15/swf
class Header(object):
    def __init__(self, data):
        self.is_compressed = data[0] == 'C'
        self.version = ord(data[3])
        self.file_size = unpack('<L', data[4:8])[0]

        if self.is_compressed:
            data = data[:8] + zlib.decompress(data[8:])
        self.data = data

        self.frame_size = Rect(islice(data, 8, None))
        index = 8 + self.frame_size.tell()

        self.frame_rate = unpack('<H', data[index:index + 2])[0] / 256.0
        self.frame_count = unpack('<H', data[index + 2:index + 4])[0]

        self.end = index + 4

    @property
    def decompressed_data(self):
        return self.data

    def tell(self):
        """ヘッダが占めるバイト数を返す"""
        return self.end
コード例 #2
0
ファイル: parser.py プロジェクト: beans15/swf
    def __init__(self, data):
        self.is_compressed = data[0] == 'C'
        self.version = ord(data[3])
        self.file_size = unpack('<L', data[4:8])[0]

        if self.is_compressed:
            data = data[:8] + zlib.decompress(data[8:])
        self.data = data

        self.frame_size = Rect(islice(data, 8, None))
        index = 8 + self.frame_size.tell()

        self.frame_rate = unpack('<H', data[index:index + 2])[0] / 256.0
        self.frame_count = unpack('<H', data[index + 2:index + 4])[0]

        self.end = index + 4
コード例 #3
0
ファイル: heliport.py プロジェクト: bcorfman/heliport
def find_helipad_radius(edges: CandidateEdges, roof: Roof) -> float:
    # If polygon is defined in counterclockwise direction, then if we are moving right at the start,
    # the first time we move up (Y) is when we start measuring the min X value. That is the largest
    # possible X value for the right side. Once this is done for all four sides, take the difference
    # between Xs and Ys, figure out which is greater and divide by 2 to get the radius.
    largest_radius = -99.0
    outline_points = roof.upper_right_points + roof.bottom_left_points
    for left in edges.left:
        for right in edges.right:
            for top in edges.top:
                for bottom in edges.bottom:
                    possible_location = Rect(left, top, right, bottom)
                    helipad_center = Point(left + (right - left) / 2, bottom + (top - bottom) / 2)
                    radius = find_largest_radius_inside(possible_location)
                    possible_helipad = Circle(helipad_center, radius)
                    points_inside = [point_in_circle(pt, possible_helipad) for pt in outline_points]
                    if not any(points_inside) and radius > largest_radius:
                        largest_radius = radius
    return largest_radius