コード例 #1
0
    def __init__(self, height):
        LabelBatch.__init__(self)
        
        center_x = 0
        max_y = height
        y = max_y - 50

        for line in Explanation.text:
            self.add_text(line,
                          font_name=Explanation.font,
                          font_size=40,
                          anchor_x='center', anchor_y='top',
                          position=(center_x, y))
            
            y -= 70
コード例 #2
0
    def __init__(self, height):
        LabelBatch.__init__(self)

        center_x = 0
        max_y = height
        y = max_y - 50

        for line in Explanation.text:
            self.add_text(line,
                          font_name=Explanation.font,
                          font_size=40,
                          anchor_x='center',
                          anchor_y='top',
                          position=(center_x, y))

            y -= 70
コード例 #3
0
    def _construct_node(self):
        """
        Construct a view of current trends.
        """
        node = LabelBatch()

        font = 'Times New Roman'
        center_x = 0
        max_y = self.__height

        # Title
        node.add_text('Stijgers en dalers',
                      font_name=font,
                      font_size=40,
                      anchor_x='center', anchor_y='top',
                      position=(center_x, max_y))
        max_y -= 150

        # Divide rest into two sections: risers and fallers
        margin_center = 50
        risers_left = 0 - self.__width/2
        risers_right = 0 - margin_center
        fallers_left = margin_center
        fallers_right = self.__width/2

        y_spacing = max_y/4

        risers = self.__trend_data[:5]
        fallers = list(reversed(self.__trend_data[-5:]))

        for index, data in enumerate(risers):
            percentage = ((1/data[1]) - 1) * 100

            node.add_text(data[0].name,
                          font_name=font,
                          font_size=30,
                          anchor_x='left',
                          anchor_y='bottom',
                          position=(risers_left, max_y-index*y_spacing))
            node.add_text('+%d %%' % percentage,
                          font_name=font,
                          font_size=30,
                          anchor_x='right',
                          anchor_y='bottom',
                          position=(risers_right, max_y-index*y_spacing))

        for index, data in enumerate(fallers):
            percentage = (1 - (1/data[1])) * 100

            node.add_text(data[0].name,
                          font_name=font,
                          font_size=30,
                          anchor_x='left',
                          anchor_y='bottom',
                          position=(fallers_left, max_y-index*y_spacing))
            node.add_text('-%d %%' % percentage,
                          font_name=font,
                          font_size=30,
                          anchor_x='right',
                          anchor_y='bottom',
                          position=(fallers_right, max_y-index*y_spacing))

        return node
コード例 #4
0
    def _construct_node(self):
        node = LabelBatch()

        font = 'Times New Roman'
        center_x = 0
        max_y = self.__height

        node.add_text(self.__drink.name,
                      font_name=font,
                      font_size=64,
                      anchor_x='center', anchor_y='top',
                      position=(center_x, max_y))

        node.add_text("Alcohol: %2.1f %%" % self.__drink.alc_perc,
                      font_name=font,
                      font_size=20,
                      anchor_x='center', anchor_y='top',
                      position=(center_x, max_y - 100))

        y = max_y - 150
        y_spacing = y / len(self.__drink.drinks)
        y -= y_spacing / 2
        for d in self.__drink.drinks:
            node.add_text(d.name,
                          font_name=font,
                          font_size=20,
                          anchor_x='center', anchor_y='top',
                          position=(center_x, y))
            y -= y_spacing

        node.add_text("%d" % self.__drink.current_price_quartjes,
                      font_name=font,
                      font_size=150,
                      anchor_x='center', anchor_y='center',
                      position=(center_x + 300, (max_y - 150) / 2))

        mix_drawing = cocos.sprite.Sprite(image=self.__mix_image,
                                          position=(center_x - 300, (max_y - 150) / 2),
                                          anchor=(100, (max_y - 150) / 2))
        node.add(mix_drawing)

        return node
コード例 #5
0
    def _construct_node(self):
        """
        Construct a view of current trends.
        """
        node = LabelBatch()

        font = 'Times New Roman'
        center_x = 0
        max_y = self.__height

        # Title
        node.add_text('Stijgers en dalers',
                      font_name=font,
                      font_size=40,
                      anchor_x='center',
                      anchor_y='top',
                      position=(center_x, max_y))
        max_y -= 150

        # Divide rest into two sections: risers and fallers
        margin_center = 50
        risers_left = 0 - self.__width / 2
        risers_right = 0 - margin_center
        fallers_left = margin_center
        fallers_right = self.__width / 2

        y_spacing = max_y / 4

        risers = self.__trend_data[:5]
        fallers = list(reversed(self.__trend_data[-5:]))

        for index, data in enumerate(risers):
            percentage = ((1 / data[1]) - 1) * 100

            node.add_text(data[0].name,
                          font_name=font,
                          font_size=30,
                          anchor_x='left',
                          anchor_y='bottom',
                          position=(risers_left, max_y - index * y_spacing))
            node.add_text('+%d %%' % percentage,
                          font_name=font,
                          font_size=30,
                          anchor_x='right',
                          anchor_y='bottom',
                          position=(risers_right, max_y - index * y_spacing))

        for index, data in enumerate(fallers):
            percentage = (1 - (1 / data[1])) * 100

            node.add_text(data[0].name,
                          font_name=font,
                          font_size=30,
                          anchor_x='left',
                          anchor_y='bottom',
                          position=(fallers_left, max_y - index * y_spacing))
            node.add_text('-%d %%' % percentage,
                          font_name=font,
                          font_size=30,
                          anchor_x='right',
                          anchor_y='bottom',
                          position=(fallers_right, max_y - index * y_spacing))

        return node
コード例 #6
0
    def _construct_node(self):
        node = LabelBatch()

        font = 'Times New Roman'
        center_x = 0
        max_y = self.__height

        node.add_text(self.__drink.name,
                      font_name=font,
                      font_size=64,
                      anchor_x='center',
                      anchor_y='top',
                      position=(center_x, max_y))

        node.add_text("Alcohol: %2.1f %%" % self.__drink.alc_perc,
                      font_name=font,
                      font_size=20,
                      anchor_x='center',
                      anchor_y='top',
                      position=(center_x, max_y - 100))

        y = max_y - 150
        y_spacing = y / len(self.__drink.drinks)
        y -= y_spacing / 2
        for d in self.__drink.drinks:
            node.add_text(d.name,
                          font_name=font,
                          font_size=20,
                          anchor_x='center',
                          anchor_y='top',
                          position=(center_x, y))
            y -= y_spacing

        node.add_text("%d" % self.__drink.current_price_quartjes,
                      font_name=font,
                      font_size=150,
                      anchor_x='center',
                      anchor_y='center',
                      position=(center_x + 300, (max_y - 150) / 2))

        mix_drawing = cocos.sprite.Sprite(image=self.__mix_image,
                                          position=(center_x - 300,
                                                    (max_y - 150) / 2),
                                          anchor=(100, (max_y - 150) / 2))
        node.add(mix_drawing)

        return node