Exemplo n.º 1
0
 def __init__(self, name=""):
     self._name = name
     self._device_type = -1
     self._device_channel = -1
     self._rect = geo.Rect()
     self._pin_list = []
     self._pin_name_map = {}
Exemplo n.º 2
0
 def calculate_design_bbox(self):
     """
     @brief Going through all the devices and find the boundary for the design
     """
     self._bbox = geo.Rect()
     for device in self._devices:
         self._bbox.union(device.rect())
Exemplo n.º 3
0
def fractal_rectangle(start_position,
                      max_width,
                      max_height,
                      min_width=1,
                      min_height=1):
    visited = set()
    frame = geo.Rect(start_position, max_width, max_height).border_points()

    length = max_width / 4 if frame[0][0] == 0 or frame[0][
        0] == max_width else max_height / 4
    for point in frame:
        libtcod.line_init(start_position[0], start_position[1], point[0],
                          point[1])
        x, y = libtcod.line_step()
        max_length = max_width / 2 if point[0] == 0 or point[
            0] == max_width else max_height / 2
        min_length = min_width / 2 if point[1] == 0 or point[
            1] == min_width else min_height / 2
        delta = random.sample([0, 0, 0, 0, 1, 1, -1, -1, -1], 1)[0]
        length = min(max((delta + length), min_length), max_length)
        i = length
        while not x is None and i > 0:
            visited.add((x, y))
            x, y = libtcod.line_step()
            i -= 1

    return visited
Exemplo n.º 4
0
 def compute_bbox(self):
     assert len(self._shapes) > 0
     """
     Here need a deep copy. Re-construct a new object for covenience
     """
     self._bbox = geo.Rect(self._shapes[0].x_lo(), self._shapes[0].y_lo(),
                           self._shapes[0].x_hi(), self._shapes[0].y_hi())
     for idx in range(1, len(self._shapes)):
         self._bbox.union(self._shapes[idx])
Exemplo n.º 5
0
    def __init__(self, x, y, box):

        self.coordinate = [x, y]
        self.x = x
        self.y = y
        self.box = g.Rect((box[0], box[1]), (box[0] + box[2], box[1] + box[3]))

        self.nearestNeighbours = []
        self.parentWord = None
Exemplo n.º 6
0
    def __init__(self, config, config_curves):
        self.config_curves = config_curves
        self.elements = []

        title = "Setup"
        titleText = text.ExoTextBold([config["SCREEN"]["WIDTH"] / 2 - 75, 0],
                                     title, 60, color.name_to_rgb("black"))
        instruction = "Press Enter to continue"
        instructionText = text.MuliText([
            config["SCREEN"]["WIDTH"] / 2 - 150,
            config["SCREEN"]["HEIGHT"] - 50
        ], instruction, 30, color.name_to_rgb("black"))

        self.elements.append(titleText)
        self.elements.append(instructionText)

        y = 0

        for player in self.config_curves:
            if player.active:
                box = geometry.Rect([150, 175 + y], 50, 50, player.color, True)

                keysText = player.leftKeyName
                keysText += " + "
                keysText += player.rightKeyName
                keys = text.MuliTextBold([500, 181 + y], keysText, 25,
                                         color.name_to_rgb("black"))
                self.elements.append(keys)

            else:
                box = geometry.Rect([150, 175 + y], 50, 50,
                                    color.name_to_rgb("grey"), True)

            self.elements.append(box)

            name = text.MuliTextBold([275, 181 + y], player.name, 25,
                                     color.name_to_rgb("black"))
            self.elements.append(name)

            y += 125

        Menu.__init__(self, color.name_to_rgb("white"), self.elements)
Exemplo n.º 7
0
    def calc_rect(self):
        sample_point = random.sample(self.points, 1)[0]
        left = sample_point[0]
        right = sample_point[0]
        up = sample_point[1]
        down = sample_point[1]

        for point in self.points:
            left = min(point[0], left)
            right = max(point[0], right)
            up = min(point[1], up)
            down = max(point[1], down)
        return geo.Rect((left, up), right - left, down - up)
Exemplo n.º 8
0
def building_zone(m, startx, starty, endx, endy, building_divider, minwidth,
                  minhight, maxwidth, maxhight):
    buildings = []
    for x in range(int((endx - startx) * (endy - starty) / building_divider)):
        building = random_building2(minwidth, minhight, maxwidth, maxhight)
        bx = randint(startx, endx)
        by = randint(starty, endy)
        #(building_x, building_y, building) = random_building2(startx, starty , endx, endy, minwidth, minhight, maxwidth, maxhight)
        brect = g.Rect(bx, by, len(building[0]), len(building))

        collide = False
        for b in buildings:
            if b.overlaps_with(brect):
                collide = True
                break
        if collide == False:
            buildings.append(brect)

            stamp(bx, by, building, m, 2)
Exemplo n.º 9
0
    def __init__(self, config, curves, standings):
        self.elements = []
        self.curves = curves
        self.standings = standings

        title = "End"
        titleText = text.ExoTextBold([config["SCREEN"]["WIDTH"] / 2 - 60, 0],
                                     title, 60, color.name_to_rgb("black"))
        instruction = "Press Enter to restart"
        instructionText = text.MuliText([
            config["SCREEN"]["WIDTH"] / 2 - 150,
            config["SCREEN"]["HEIGHT"] - 50
        ], instruction, 30, color.name_to_rgb("black"))

        self.elements.append(titleText)
        self.elements.append(instructionText)

        y = 0
        i = 1

        for curve in self.curves:
            if curve not in self.standings:
                self.standings.append(curve)

        for player in reversed(self.standings):
            box = geometry.Rect([150, 175 + y], 50, 50, player.color, True)
            self.elements.append(box)

            ranking = str(i)
            ranking += "."

            rankingText = text.MuliTextBold([155, 170 + y], ranking, 45,
                                            color.name_to_rgb("black"))
            self.elements.append(rankingText)

            name = text.MuliTextBold([275, 181 + y], player.name, 25,
                                     color.name_to_rgb("black"))
            self.elements.append(name)

            y += 125
            i += 1

        Menu.__init__(self, color.name_to_rgb("white"), self.elements)
Exemplo n.º 10
0
 def export_connect_net_bbox(self, filename):
     """
     @brief try to catch the connectivity information into images
     @param filename: the file name of the output images
     """
     img = np.zeros((self._image_size, self._image_size), dtype=int)
     for net_idx in range(0, self._db.num_nets()):
         #print("Net ", net_idx)
         net = self._db.net_idx(net_idx)
         bbox = geo.Rect()
         for pin_idx in net.pin_list():
             pin = self._db.pin_idx(pin_idx)
             #print(pin.rect().to_str())
             bbox.union(pin.rect())
         #print("BBOX: ", bbox.to_str())
         xl_px = self._db.circuit().pixel_x(bbox.x_lo())
         yl_px = self._db.circuit().pixel_y(bbox.y_lo())
         xh_px = self._db.circuit().pixel_x(bbox.x_hi())
         yh_px = self._db.circuit().pixel_y(bbox.y_hi())
         for x_px in range(xl_px, xh_px):
             for y_px in range(yl_px, yh_px):
                 img[y_px][x_px] += 1  # Increment the value
     export_grayscale_image(img, self._image_size, filename)
Exemplo n.º 11
0
def command_list_rectangle():
    return geo.Rect((0, 0), constants.RIGHT_SIDE_BAR_WIDTH,
                    constants.GUI_BOX_HEIGHT)
Exemplo n.º 12
0
def ratio_of_screen_rect(width, height, x_ratio, y_ratio):
    x = int((settings.SCREEN_WIDTH - width) * x_ratio)
    y = int((settings.SCREEN_HEIGHT - height) * y_ratio)
    return geo.Rect((x, y), width, height)
Exemplo n.º 13
0
 def rect(self):
     return geo.Rect(self.offset, self.width, self.height)
Exemplo n.º 14
0
def message_display_rect():
    message_display_position =\
        (constants.LEFT_SIDE_BAR_WIDTH, settings.SCREEN_HEIGHT - constants.GUI_BOX_HEIGHT)
    return geo.Rect(message_display_position, constants.MESSAGES_BAR_WIDTH,
                    constants.GUI_BOX_HEIGHT)
Exemplo n.º 15
0
def right_side_menu_rect():
    x = settings.SCREEN_WIDTH - constants.RIGHT_SIDE_BAR_WIDTH
    y = 0
    return geo.Rect((x, y), constants.RIGHT_SIDE_BAR_WIDTH,
                    settings.SCREEN_HEIGHT)
Exemplo n.º 16
0
def monster_status_rect():
    return geo.Rect(geo.zero2d(), constants.LEFT_SIDE_BAR_WIDTH,
                    constants.MONSTER_STATUS_BAR_HEIGHT)
Exemplo n.º 17
0
def player_status_rect():
    return geo.Rect((0, 0), constants.LEFT_SIDE_BAR_WIDTH,
                    constants.GUI_BOX_HEIGHT)
Exemplo n.º 18
0
 def set_rect(self, x_lo, y_lo, x_hi, y_hi):
     self._rect = geo.Rect(x_lo, y_lo, x_hi, y_hi)
Exemplo n.º 19
0
 def add_shape(self, layer, x_lo, y_lo, x_hi, y_hi):
     self._layers.append(layer)
     self._shapes.append(geo.Rect(x_lo, y_lo, x_hi, y_hi))
Exemplo n.º 20
0
 def __init__(self):
     self._name = ""
     self._layers = []
     self._shapes = []
     self._bbox = geo.Rect()
Exemplo n.º 21
0
 def __init__(self):
     self._device_idx = -1
     self._rect = geo.Rect()
     self._net_idx = -1
     self._name = ""
Exemplo n.º 22
0
def right_side_menu_rect():
    return geo.Rect((0, 0), constants.RIGHT_SIDE_BAR_WIDTH,
                    inventory.ITEM_CAPACITY + 8)
Exemplo n.º 23
0
def get_rect(x, y, width, height):
    return geometry.Rect(geometry.Point(x, y), geometry.Point(x + width, y + height))
Exemplo n.º 24
0
def full_screen_rect():
    return geo.Rect(geo.zero2d(), settings.SCREEN_WIDTH,
                    settings.SCREEN_HEIGHT)
Exemplo n.º 25
0
def item_stat_rectangle():
    return geo.Rect(
        (0, 0),
        min(40, settings.SCREEN_WIDTH - constants.RIGHT_SIDE_BAR_WIDTH), 12)
Exemplo n.º 26
0
def description_rectangle():
    return geo.Rect(
        (0, 0),
        min(40, settings.SCREEN_WIDTH - constants.RIGHT_SIDE_BAR_WIDTH), 10)