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_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_defs(self, *args, **kw): self.__dict__['elements'].append(helper.defs(*args, **kw)) return self
def set_defs(self, *args, **kw): self.elements.append(helper.defs(*args, **kw)) return self