Exemple #1
0
    def point_pixel(self, point):
        pixel_x = point.x() / self._pixel_size
        pixel_y = point.y() / self._pixel_size

        pixel_x = tools.place_between(pixel_x, 0, self._scene_size.width - 1)
        pixel_y = tools.place_between(pixel_y, 0, self._scene_size.height - 1)

        return tools.Pixel(int(pixel_x), int(pixel_y))
Exemple #2
0
    def set_pixel(self, pixel, number):
        assert 0 <= number < self.INIT_PIXELS_NUMBER

        if number == 0:
            dx = pixel.x - self._pixels[0].x
            dy = pixel.y - self._pixels[0].y
            self._move_figure(dx, dy)
        else:
            Figure.set_pixel(self, tools.Pixel(pixel.x, self.pixels[1].y), 1)
Exemple #3
0
    def set_pixel(self, pixel, pixel_number):
        if pixel_number == 0:
            dx = pixel.x - self._pixels[pixel_number].x
            dy = pixel.y - self._pixels[pixel_number].y
            self._move_figure(dx, dy)
        else:
            if pixel.x > self.pixels[0].x:
                Figure.set_pixel(self, tools.Pixel(pixel.x, self.pixels[0].y),
                                 1)

        self._make_points()
        self._reset_transform()
Exemple #4
0
def bresenham_circle(circle):
    reflector = reflections.Reflector()
    h_line = figure.Line([circle.pixels[0], tools.Pixel(circle.x0 + circle.R, circle.y0)])
    reflector.add_reflection(reflections.LineReflection(h_line))
    reflector.add_reflection(reflections.PointReflection(circle.pixels[0]))

    x, y = 0, circle.R
    di = 0

    while y >= 0:
        for pixel in reflector.reflect(x + circle.x0, int(y) + circle.y0):
            yield pixel

        h_incr = 2 * x + 1
        v_incr = -2 * y + 1
        d_incr = 2 * (x - y + 1)

        dh = di + h_incr
        dv = di + v_incr
        dd = di + d_incr

        if dd < 0:
            delta = 2 * (dd + y) - 1
            if delta <= 0:
                x += 1
                di += h_incr
            else:
                x += 1
                y -= 1
                di += d_incr
        elif dd > 0:
            delta = 2 * (dd - x) - 1
            if delta <= 0:
                x += 1
                y -= 1
                di += d_incr
            else:
                y -= 1
                di += v_incr
        else:
            x += 1
            y -= 1
            di += d_incr
Exemple #5
0
 def _filter_images_listing(img_handles_desc, images_listing):
     """filters the images_listing based on filtering_parameters in img_handles_desc"""
     filtering_parameters = img_handles_desc.filtering_parameters
     images_listing_copy = copy.deepcopy(images_listing)
     for image in images_listing.image:
         match = True
         if filtering_parameters.created:
             match &= (dateutil.parser.parse(image.created)
                       in tools.DatetimeRange(filtering_parameters.created))
         if filtering_parameters.modified:
             match &= (dateutil.parser.parse(image.modified)
                       in tools.DatetimeRange(
                           filtering_parameters.modified))
         if filtering_parameters.encoding:
             match &= (image.encoding == filtering_parameters.encoding)
         if filtering_parameters.pixel:
             match &= (tools.Pixel(image.pixel)
                       in tools.PixelRange(filtering_parameters.pixel))
         if not match:
             images_listing_copy.image.remove(image)
     return images_listing_copy
Exemple #6
0
 def project_point(self, point):
     xp, yp, zp, wp = self._projection_point
     x0, y0, z0, w0 = point
     x = xp + (x0 - xp) * zp / (z0 + zp)
     y = yp + (y0 - yp) * zp / (z0 + zp)
     return tools.Pixel(x, y)
Exemple #7
0
 def _move_figure(self, dx, dy):
     for pixel_number, pixel in enumerate(self._pixels):
         self._pixels[pixel_number] = tools.Pixel(pixel.x + dx,
                                                  pixel.y + dy)
Exemple #8
0
 def __init__(self, pixels, params={}):
     pixels[1] = tools.Pixel(pixels[1].x, pixels[0].y)
     super(Parabola, self).__init__(pixels, params)