Example #1
0
    def do_paint(self):
        x = numpy.arange(-400, 400)
        y = 20 * numpy.sin(x * 0.1)

        # Plot trace, setting down lines wherever both x and y are finite
        # (neither NaN, nor infinity, nor minus infinity)
        pendown = False
        for x, y in zip(x, y):
            if numpy.isfinite(x) and numpy.isfinite(y):
                if pendown:
                    cogl.path_line_to(x, -y)
                else:
                    cogl.path_move_to(x, -y)
                    pendown = True
            else:
                pendown = False
        cogl.set_source_color(self.color)
        cogl.path_stroke()
Example #2
0
    def do_paint(self):
        x = numpy.arange(-400, 400)
        y = 20 * numpy.sin(x * 0.1)

        # Plot trace, setting down lines wherever both x and y are finite
        # (neither NaN, nor infinity, nor minus infinity)
        pendown = False
        for x, y in zip(x, y):
            if numpy.isfinite(x) and numpy.isfinite(y):
                if pendown:
                    cogl.path_line_to(x, -y)
                else:
                    cogl.path_move_to(x, -y)
                    pendown = True
            else:
                pendown = False
        cogl.set_source_color(self.color)
        cogl.path_stroke()
Example #3
0
    def do_paint(self):
        """paint signal handler."""
        w = self.get_width()
        h = self.get_height()
        half_w = 0.5 * w
        half_h = 0.5 * h
        half_major = self.MAJOR_PIXELS / 2
        tenth_major = self.MAJOR_PIXELS / 10

        # Fill background.
        cogl.set_source_color(self.BACKGROUND_COLOR)
        cogl.rectangle(-half_w, -half_h, half_w, half_h)

        # Create paths for vertical gridlines.
        x0 = int((-half_w // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
        for x in xrange(x0, int(math.ceil(half_w)), self.MAJOR_PIXELS):
            halfway = x + half_major
            vline(x, -half_h, half_h)
            vline(halfway, -8, 0)
            for xx in xrange(x + tenth_major, halfway, tenth_major):
                vline(xx, -4, 0)
            for xx in xrange(halfway + tenth_major, x + self.MAJOR_PIXELS,
                             tenth_major):
                vline(xx, -4, 0)

        # Create paths for horizontal gridlines.
        y0 = int((-half_h // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
        for y in xrange(y0, int(math.ceil(half_h)), self.MAJOR_PIXELS):
            halfway = y + half_major
            hline(y, -half_w, half_w)
            hline(halfway, 0, 8)
            for yy in xrange(y + tenth_major, halfway, tenth_major):
                hline(yy, 0, 4)
            for yy in xrange(halfway + tenth_major, y + self.MAJOR_PIXELS,
                             tenth_major):
                hline(yy, 0, 4)

        # Stroke gridlines.
        cogl.set_source_color(self.GRIDLINE_COLOR)
        cogl.path_stroke()

        # Chain up to parent.
        clutter.Group.do_paint(self)
Example #4
0
    def do_paint(self):
        """paint signal handler."""
        w = self.get_width()
        h = self.get_height()
        half_w = 0.5 * w
        half_h = 0.5 * h
        half_major = self.MAJOR_PIXELS / 2
        tenth_major = self.MAJOR_PIXELS / 10

        # Fill background.
        cogl.set_source_color(self.BACKGROUND_COLOR)
        cogl.rectangle(-half_w, -half_h, half_w, half_h)

        # Create paths for vertical gridlines.
        x0 = int((-half_w // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
        for x in xrange(x0, int(math.ceil(half_w)), self.MAJOR_PIXELS):
            halfway = x + half_major
            vline(x, -half_h, half_h)
            vline(halfway, -8, 0)
            for xx in xrange(x + tenth_major, halfway, tenth_major):
                vline(xx, -4, 0)
            for xx in xrange(halfway + tenth_major, x + self.MAJOR_PIXELS, tenth_major):
                vline(xx, -4, 0)

                # Create paths for horizontal gridlines.
        y0 = int((-half_h // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
        for y in xrange(y0, int(math.ceil(half_h)), self.MAJOR_PIXELS):
            halfway = y + half_major
            hline(y, -half_w, half_w)
            hline(halfway, 0, 8)
            for yy in xrange(y + tenth_major, halfway, tenth_major):
                hline(yy, 0, 4)
            for yy in xrange(halfway + tenth_major, y + self.MAJOR_PIXELS, tenth_major):
                hline(yy, 0, 4)

                # Stroke gridlines.
        cogl.set_source_color(self.GRIDLINE_COLOR)
        cogl.path_stroke()

        # Chain up to parent.
        clutter.Group.do_paint(self)