Exemplo n.º 1
0
	def _checkBbox(self, pointToCheck, boxPoint):
		# boxPoint is the final point of the current node,
		# the other bbox point is the previous final point
		myRect = normRect((self._prev[0], self._prev[1], boxPoint[0], boxPoint[1]))
		if not pointInRect(pointToCheck, myRect):
			if self.extremum_calculate_badness:
				badness = self._getBadness(pointToCheck, myRect)
				if badness >= self.extremum_ignore_badness_below:
					self.errors.append(OutlineError(pointToCheck, "Extremum", badness))
			else:
				self.errors.append(OutlineError(pointToCheck, "Extremum"))
Exemplo n.º 2
0
	def _checkBboxSegment(self, bcp1, bcp2, pt):
		# Like _checkBbox, but checks the whole segment and calculates extrema
		myRect = normRect((self._prev[0], self._prev[1], pt[0], pt[1]))
		if not pointInRect(bcp1, myRect) or not pointInRect(bcp2, myRect):
			extrema = getExtremaForCubic(self._prev, bcp1, bcp2, pt, h=True, v=True)
			for p in extrema:
				if self.extremum_calculate_badness:
					badness = self._getBadness(p, myRect)
					if badness >= self.extremum_ignore_badness_below:
						self.errors.append(OutlineError(p, "Extremum", badness))
				else:
					self.errors.append(OutlineError(p, "Extremum"))
Exemplo n.º 3
0
 def _checkBbox(self, pointToCheck, boxPoint):
     # boxPoint is the final point of the current node,
     # the other bbox point is the previous final point
     myRect = normRect(
         (self._prev[0], self._prev[1], boxPoint[0], boxPoint[1]))
     if not pointInRect(pointToCheck, myRect):
         if self.extremum_calculate_badness:
             badness = self._getBadness(pointToCheck, myRect)
             if badness >= self.extremum_ignore_badness_below:
                 self.errors.append(
                     OutlineError(pointToCheck, "Extremum", badness))
         else:
             self.errors.append(OutlineError(pointToCheck, "Extremum"))
Exemplo n.º 4
0
 def _checkBboxSegment(self, bcp1, bcp2, pt):
     # Like _checkBbox, but checks the whole segment and calculates extrema
     myRect = normRect((self._prev[0], self._prev[1], pt[0], pt[1]))
     if not pointInRect(bcp1, myRect) or not pointInRect(bcp2, myRect):
         extrema = getExtremaForCubic(self._prev,
                                      bcp1,
                                      bcp2,
                                      pt,
                                      h=True,
                                      v=True)
         for p in extrema:
             if self.extremum_calculate_badness:
                 badness = self._getBadness(p, myRect)
                 if badness >= self.extremum_ignore_badness_below:
                     self.errors.append(OutlineError(
                         p, "Extremum", badness))
             else:
                 self.errors.append(OutlineError(p, "Extremum"))
 def mouseUp(self, info):
     # get the glyph
     glyph = info["glyph"]
     # get the current tool
     tool = info["tool"]
     # only work when the curren tools is the editingTool
     if not isinstance(tool, EditingTool):
         return
     # go on when the option is down and there is no point selection in the glyph
     if tool.optionDown and not glyph.selection:
         # get the marque rect from the tool
         (x, y), (w, h) = tool.getMarqueRect()
         # normalize the rect to a minx, miny, maxx, maxy rectangle
         marqueRect = normRect((x, y, x + w, y + h))
         # loop over all components
         for component in glyph.components:
             # get the component bounding box
             comonentBounds = component.box
             # empty components are possible
             if comonentBounds:
                 # check if there an intersection between the marque rect and the component bounding box
                 interesect, intersectionRect = sectRect(marqueRect, component.box)
                 # if so...
                 if interesect:
                     # check if shift is down
                     if tool.shiftDown:
                         # on shift down, just toggle the current selection
                         component.selected = not component.selected
                     else:
                         # othewise set the component as selected
                         component.selected = True
             else:
                 # empty component
                 # check if the off set point of the component is inside the marque rect
                 if pointInRect(component.offset, marqueRect):
                     # check if shift is down
                     if tool.shiftDown:
                         # on shift down, just toggle the current selection
                         component.selected = not component.selected
                     else:
                         # othewise set the component as selected
                         component.selected = True
         # update the glyph
         glyph.update()
Exemplo n.º 6
0
def test_normRect():
    assert normRect((0, 10, 100, 200)) == (0, 10, 100, 200)
    assert normRect((100, 200, 0, 10)) == (0, 10, 100, 200)
Exemplo n.º 7
0
def transform_bbox(bbox, matrix):
	t = Transform(*matrix)
	ll_x, ll_y = t.transformPoint((bbox[0], bbox[1]))
	tr_x, tr_y = t.transformPoint((bbox[2], bbox[3]))
	return normRect((ll_x, ll_y, tr_x, tr_y))
Exemplo n.º 8
0
def test_normRect():
    assert normRect((0, 10, 100, 200)) == (0, 10, 100, 200)
    assert normRect((100, 200, 0, 10)) == (0, 10, 100, 200)
Exemplo n.º 9
0
def transform_bbox(bbox, matrix):
    t = Transform(*matrix)
    ll_x, ll_y = t.transformPoint((bbox[0], bbox[1]))
    tr_x, tr_y = t.transformPoint((bbox[2], bbox[3]))
    return normRect((ll_x, ll_y, tr_x, tr_y))