def _set_grid(self): """ Set up background grid for drawing canvas """ grid_sizex = self.__dict__['size'][0] / self.__dict__[ 'grid_aspects'][0] grid_sizey = self.__dict__['size'][1] / self.__dict__[ 'grid_aspects'][0] sizex = grid_sizex * (1.0 / self.__dict__['grid_aspects'][1]) sizey = grid_sizey * (1.0 / self.__dict__['grid_aspects'][1]) defs = helper.defs() defs += helper.pattern( helper.path( **{ 'd': 'M %s 0 L 0 0 0 %s' % (sizex, sizey), 'fill': 'none', 'stroke': 'gray', 'stroke-width': 0.5 }), **{ 'id': self.__dict__['grid_item_id'], 'width': sizex, 'height': sizey, 'patternUnits': 'userSpaceOnUse' }) defs += helper.pattern( helper.path( **{ 'd': 'M %s 0 L 0 0 0 %s' % (grid_sizex, grid_sizey), 'fill': 'none', 'stroke': 'gray', 'stroke-width': 1 }), helper.rect(width=grid_sizex, height=grid_sizey, fill="url(#%s)" % self.__dict__['grid_item_id']), **{ 'id': self.__dict__['grid_id'], 'width': grid_sizex, 'height': grid_sizey, 'patternUnits': 'userSpaceOnUse' }) self += defs self += helper.rect(fill="white", height=self.__dict__['size'][0] + 1, width=self.__dict__['size'][1] + 1) self += helper.rect(fill="url(#%s)" % self.__dict__['grid_id'], height=self.__dict__['size'][0] + 1, width=self.__dict__['size'][1] + 1)
def set_rectangle(self, *args, **kw): kw['x'] = self.__dict__['x'] + kw['x'] if kw.has_key( 'x') else self.__dict__['x'] kw['y'] = self.__dict__['y'] - kw['y'] if kw.has_key( 'y') else self.__dict__['y'] self.__dict__['elements'].append(helper.rect(*args, **kw)) return self
def _set_grid(self): """ Set up background grid for drawing canvas """ grid_sizex = self.size[0]/self.grid_aspects[0] grid_sizey = self.size[1]/self.grid_aspects[0] sizex = grid_sizex*(1.0/self.grid_aspects[1]) sizey = grid_sizey*(1.0/self.grid_aspects[1]) defs = helper.defs() defs << helper.pattern(helper.path(**{'d': 'M %s 0 L 0 0 0 %s' % (sizex, sizey), 'fill': 'none', 'stroke': 'gray', 'stroke-width': 0.5}), **{'id': self.grid_item_id, 'width': sizex, 'height': sizey, 'patternUnits': 'userSpaceOnUse'}) defs << helper.pattern(helper.path(**{'d': 'M %s 0 L 0 0 0 %s' % (grid_sizex, grid_sizey), 'fill': 'none', 'stroke': 'gray', 'stroke-width': 1}), helper.rect(width=grid_sizex, height=grid_sizey, fill="url(#%s)" % self.grid_item_id), **{'id': self.grid_id, 'width': grid_sizex, 'height': grid_sizey, 'patternUnits': 'userSpaceOnUse'}) self << defs self << helper.rect(fill="white", height=self.x*grid_sizex, width=self.y*grid_sizey) self << helper.rect(fill="url(#%s)" % self.grid_id, height=self.x*grid_sizex, width=self.y*grid_sizey)
def set_rectangle(self, *args, **kw): kw['x'] = self.x+kw['x'] if kw.has_key('x') else self.x kw['y'] = self.y-kw['y'] if kw.has_key('y') else self.y self.elements.append(helper.rect(*args, **kw)) return self
def set_rectangle(self, *args, **kw): kw['x'] = self.__dict__['x']+kw['x'] if kw.has_key('x') else self.__dict__['x'] kw['y'] = self.__dict__['y']-kw['y'] if kw.has_key('y') else self.__dict__['y'] self.__dict__['elements'].append(helper.rect(*args, **kw)) return self