Example #1
0
 def _map_x_numbers_to_context(self, cairo_rectangle, data_rectangle, data):
     """\brief 
     \param cairo_rectangle - cairo rectangle 
     \param data_rectangle - \ref drawing_rectangle.drawing_rectangle instance
     \param data - X coordinates in data context
     """
     yy = data_rectangle.get_lower_y_limit() # common Y for all points to map
     mapped = map_to_context_coordinates(data_rectangle, cairo_rectangle, map(lambda a: (a, yy), data))
     return map(lambda a: a[0], mapped) # using just X
Example #2
0
 def _map_y_numbers_to_context(self, cairo_rect, data_rect, y_numbers):
     """\brief 
     \param cairo_rect - rectangle of cairo context
     \param data_rect - rectangle of data
     \param y_numbers - list of numbers
     \return list of floats, y coordinates in cairo context
     """
     xx = data_rect.get_upper_x_limit()
     maped = map_to_context_coordinates(data_rect, cairo_rect, map(lambda a: (xx, a), y_numbers))
     return map(lambda a: a[1], maped) # we do not use X - it is always 0
Example #3
0
 def draw(self, context, rect):
     context.set_source_rgb(0.1, 0.5, 0)
     drc = drawing_rectangle(lower_x_limit=-10,
                             upper_x_limit=10,
                             lower_y_limit=-1,
                             upper_y_limit=1)
     sin_data = map(lambda a: (a, sin(a)), arange(-10, 10, 0.1))
     mapsin = map_to_context_coordinates(drc, rect, sin_data)
     context.move_to(mapsin[0][0], mapsin[0][1])
     for dsin in mapsin[1:]:
         context.line_to(*dsin)
     context.stroke()