def get_bounding_box(self,adjusted=False): """ Returns the bounding box, or corner points of the graphic as a list in the format [minx,maxx,miny,maxy]. If adjusted is true, the bounding box is adjusted to not include the weedline padding. """ had_weedline = self.get_weedline_status() if adjusted: self.set_weedline(False) # removes weedline if it is enabled path = cubicsuperpath.parsePath(simplepath.formatPath(self._data)) self.set_weedline(had_weedline) # adds weedline back if it was enabled return list(simpletransform.roughBBox(path))
def get_bounding_box(self, adjusted=False): """ Returns the bounding box, or corner points of the graphic as a list in the format [minx,maxx,miny,maxy]. If adjusted is true, the bounding box is adjusted to not include the weedline padding. """ had_weedline = self.get_weedline_status() if adjusted: self.set_weedline(False) # removes weedline if it is enabled path = cubicsuperpath.parsePath(simplepath.formatPath(self._data)) self.set_weedline(had_weedline) # adds weedline back if it was enabled return list(simpletransform.roughBBox(path))
def curveto(p0, curve, flat=smoothness): poly = [] d = simplepath.formatPath([['M', p0], curve]) p = cubicsuperpath.parsePath(d) cspsubdiv.cspsubdiv(p, flat) for sp in p: first = True for csp in sp: if first: first = False else: for subpath in csp: poly.append(['L', list(subpath)]) return poly
def curveto(p0,curve,flat=smoothness): poly = [] d = simplepath.formatPath([['M',p0],curve]) p = cubicsuperpath.parsePath(d) cspsubdiv.cspsubdiv(p, flat) for sp in p: first = True for csp in sp: if first: first = False else: for subpath in csp: poly.append(['L',list(subpath)]) return poly
def get_data(self): """ Breaks all paths up into basic paths. Returns the graphic as an etree element wrapped in group tags. """ group = etree.Element('g') group.set('id', u"data.%s" % id(self)) spl = self.get_data_array() for i in range(0, len(spl)): path = etree.Element('path') path.set('d', simplepath.formatPath(spl[i])) if self.get_weedline_status() and i == len(spl): path.set('class', 'weedline') group.append(path) return group
def get_data(self): """ Breaks all paths up into basic paths. Returns the graphic as an etree element wrapped in group tags. """ group = etree.Element('g') group.set('id',u"data.%s" %id(self)) spl = self.get_data_array() for i in range(0,len(spl)): path = etree.Element('path') path.set('d',simplepath.formatPath(spl[i])) if self.get_weedline_status() and i==len(spl): path.set('class','weedline') group.append(path) return group
def _update_bounding_box(self): path = cubicsuperpath.parsePath(simplepath.formatPath(self._data)) bbox = list(simpletransform.roughBBox(path)) self._properties['bounding_box'] = bbox