Example #1
0
    def __init__(self):
        app.Canvas.__init__(self,
                            title='Arrows example',
                            keys='interactive',
                            size=(1050, 650))

        line1 = curves.curve4_bezier((10.0, 0.0), (50, -190), (350, 190),
                                     (390, 0.0))
        arrows1 = np.array([line1[-2], line1[-1]]).reshape((1, 4))

        line2 = curves.curve4_bezier((10.0, 0.0), (190, -190), (210, 190),
                                     (390, 0.0))
        arrows2 = np.array([line2[1], line2[0], line2[-2], line2[-1]]).reshape(
            (2, 4))

        line3 = curves.curve3_bezier((10.0, 0.0), (50, 190), (390, 0.0))

        arrows3 = np.array([line3[-2], line3[-1]]).reshape((1, 4))

        arrow_types = ["curved", "stealth", "inhibitor_round", "angle_60"]
        self.lines = []

        for i, arrow_type in enumerate(arrow_types):
            arrows = [
                visuals.ArrowVisual(line1,
                                    color='w',
                                    width=6,
                                    method='agg',
                                    arrows=arrows1,
                                    arrow_type=arrow_type,
                                    arrow_size=30.0),
                visuals.ArrowVisual(line2,
                                    color='w',
                                    width=2,
                                    method='agg',
                                    arrows=arrows2,
                                    arrow_type=arrow_type,
                                    arrow_size=5.0),
                visuals.ArrowVisual(line3,
                                    color='w',
                                    width=4,
                                    method='agg',
                                    arrows=arrows3,
                                    arrow_type=arrow_type,
                                    arrow_size=10.0)
            ]

            # Translate each line visual downwards
            for j, visual in enumerate(arrows):
                x = 50 + (i * 250)
                y = 100 + (200 * j)

                visual.transform = STTransform(translate=[x, y],
                                               scale=(0.5, 1.0))
                visual.events.update.connect(lambda event: self.update())

            self.lines.extend(arrows)

        self.show()
Example #2
0
    def __init__(self):
        app.Canvas.__init__(self,
                            title='Bezier lines example',
                            keys='interactive',
                            size=(400, 750))

        self.lines = [
            visuals.LineVisual(curves.curve4_bezier((10, 0), (50, -190),
                                                    (350, 190), (390, 0)),
                               color='w',
                               width=2,
                               method='agg'),
            visuals.LineVisual(curves.curve4_bezier((10, 0), (190, -190),
                                                    (210, 190), (390, 0)),
                               color='w',
                               width=2,
                               method='agg'),
            visuals.LineVisual(curves.curve3_bezier((10, 0), (30, 200),
                                                    (390, 0)),
                               color='w',
                               width=2,
                               method='agg')
        ]

        # Translate each line visual downwards
        for i, line in enumerate(self.lines):
            x = 0
            y = 200 * (i + 1)

            line.transform = STTransform(translate=[x, y])

        self.texts = [
            visuals.TextVisual('Third order curve',
                               bold=True,
                               color='w',
                               font_size=14,
                               pos=(200, 75)),
            visuals.TextVisual('Quadratic curve',
                               bold=True,
                               color='w',
                               font_size=14,
                               pos=(200, 525)),
        ]

        for text in self.texts:
            text.transform = NullTransform()

        self.visuals = self.lines + self.texts
        self.show()
Example #3
0
    def __init__(self):
        app.Canvas.__init__(self, title='Bezier lines example',
                            keys='interactive', size=(400, 750))

        self.lines = [
            visuals.LineVisual(curves.curve4_bezier(
                (10, 0),
                (50, -190),
                (350, 190),
                (390, 0)
            ), color='w', width=2, method='agg'),
            visuals.LineVisual(curves.curve4_bezier(
                (10, 0),
                (190, -190),
                (210, 190),
                (390, 0)
            ), color='w', width=2, method='agg'),
            visuals.LineVisual(curves.curve3_bezier(
                (10, 0),
                (30, 200),
                (390, 0)
            ), color='w', width=2, method='agg')
        ]

        # Translate each line visual downwards
        for i, line in enumerate(self.lines):
            x = 0
            y = 200 * (i + 1)

            line.transform = STTransform(translate=[x, y])

        self.texts = [
            visuals.TextVisual('Third order curve', bold=True, color='w',
                               font_size=14, pos=(200, 75)),
            visuals.TextVisual('Quadratic curve', bold=True, color='w',
                               font_size=14, pos=(200, 525)),
        ]

        for text in self.texts:
            text.transform = NullTransform()

        self.visuals = self.lines + self.texts
        self.show()
Example #4
0
    def __init__(self):
        app.Canvas.__init__(self, title='Arrows example',
                            keys='interactive', size=(1050, 650))

        line1 = curves.curve4_bezier(
            (10.0, 0.0),
            (50, -190),
            (350, 190),
            (390, 0.0)
        )
        arrows1 = np.array([
            line1[-2],
            line1[-1]
        ]).reshape((1, 4))

        line2 = curves.curve4_bezier(
            (10.0, 0.0),
            (190, -190),
            (210, 190),
            (390, 0.0)
        )
        arrows2 = np.array([
            line2[1],
            line2[0],
            line2[-2],
            line2[-1]
        ]).reshape((2, 4))

        line3 = curves.curve3_bezier(
            (10.0, 0.0),
            (50, 190),
            (390, 0.0)
        )

        arrows3 = np.array([
            line3[-2],
            line3[-1]
        ]).reshape((1, 4))

        arrow_types = ["curved", "stealth", "inhibitor_round", "angle_60"]
        self.lines = []

        for i, arrow_type in enumerate(arrow_types):
            arrows = [
                visuals.ArrowVisual(line1, color='w', width=6, method='agg',
                                    arrows=arrows1, arrow_type=arrow_type,
                                    arrow_size=30.0),
                visuals.ArrowVisual(line2, color='w', width=2, method='agg',
                                    arrows=arrows2, arrow_type=arrow_type,
                                    arrow_size=5.0),
                visuals.ArrowVisual(line3, color='w', width=4, method='agg',
                                    arrows=arrows3, arrow_type=arrow_type,
                                    arrow_size=10.0)
            ]

            # Translate each line visual downwards
            for j, visual in enumerate(arrows):
                x = 50 + (i * 250)
                y = 100 + (200 * j)

                visual.transform = STTransform(translate=[x, y],
                                               scale=(0.5, 1.0))
                visual.events.update.connect(lambda event: self.update())

            self.lines.extend(arrows)

        self.show()