Exemple #1
0
 def _buildAsset(self):
     pcenter = self._spposinputs.pos
     try:
         pradius = (
             MathApp.distance(self._posinputs.pos(), self._nposinputs.radius())
             * MathApp.scale
         )
     except (AttributeError, TypeError):
         # pylint: disable=no-member
         pradius = self._nposinputs.radius() * MathApp.scale
         # pylint: enable=no-member
     style = self._stdinputs.style()
     fill = self._stdinputs.color()
     ymax = pcenter[1] + pradius
     ymin = pcenter[1] - pradius
     xmax = pcenter[0] + pradius
     xmin = pcenter[0] - pradius
     try:
         if ymin > MathApp.height or ymax < 0 or xmax < 0 or xmin > MathApp.width:
             return CircleAsset(pradius, style, fill)
         if pradius > 2 * MathApp.width:
             # here begins unpleasant hack to overcome crappy circles
             poly = self._buildPolygon(pcenter, pradius)
             if poly:
                 passet = PolygonAsset(poly, style, fill)
                 return passet
     except AttributeError:
         return CircleAsset(pradius, style, fill)
     return CircleAsset(pradius, style, fill)
Exemple #2
0
 def _buildAsset(self):
     pcenter = self._spposinputs.pos
     try:
         pradius = MathApp.distance(
             self._posinputs.pos(),
             self._nposinputs.radius()) * MathApp._scale
     except (AttributeError, TypeError):
         pradius = self._nposinputs.radius() * MathApp._scale
     style = self._stdinputs.style()
     fill = self._stdinputs.color()
     ymax = pcenter[1] + pradius
     ymin = pcenter[1] - pradius
     xmax = pcenter[0] + pradius
     xmin = pcenter[0] - pradius
     try:
         if ymin > MathApp.height or ymax < 0 or xmax < 0 or xmin > MathApp.width:
             return CircleAsset(pradius, style, fill)
         elif pradius > 2 * MathApp.width:
             # here begins unpleasant hack to overcome crappy circles
             poly = self._buildPolygon(pcenter, pradius)
             if len(poly):
                 passet = PolygonAsset(poly, style, fill)
                 return passet
     except AttributeError:
         return CircleAsset(pradius, style, fill)
     return CircleAsset(pradius, style, fill)
Exemple #3
0
 def physicalPointTouching(self, ppos):
     r = MathApp.distance(self._spposinputs.pos(), ppos)
     # pylint: disable=no-member
     pradius = self._nposinputs.radius() * MathApp.scale
     # pylint: enable=no-member
     style = self._stdinputs.style()
     inner = pradius - style.width / 2
     outer = pradius + style.width / 2
     return inner <= r <= outer
Exemple #4
0
 def physicalPointTouching(self, ppos):
     r = MathApp.distance(self._spposinputs.pos(), ppos)
     # pylint: disable=no-member
     pradius = self._nposinputs.radius() * MathApp.scale
     # pylint: enable=no-member
     style = self._stdinputs.style()
     inner = pradius - style.width / 2
     outer = pradius + style.width / 2
     return inner <= r <= outer
Exemple #5
0
 def physicalPointTouching(self, ppos):
     """
     Determine if a physical point is considered to be touching this point.
     
     :param tuple(int,int) ppos: Physical screen coordinates.
     :rtype: boolean
     :returns: True if touching, False otherwise.
     """
     return MathApp.distance(ppos, self._pposinputs.pos) < self._sstdinputs.size
Exemple #6
0
    def distanceTo(self, otherpoint):
        """
        Compute the distance to another :class:`_Point` object.

        :param _Point otherpoint: A reference to the other :class:`_Point`
        :rtype: float
        :returns: The distance (in logical units) to the other point
        """
        try:
            return MathApp.distance(self(), otherpoint())
        except AttributeError:
            return otherpoint  # presumably a scalar - use this distance
Exemple #7
0
    def physicalPointTouching(self, ppos):
        """
        Determine if a physical point is considered to be touching this point.

        :param tuple(int,int) ppos: Physical screen coordinates.
        :rtype: boolean
        :returns: True if touching, False otherwise.
        """
        return (
            MathApp.distance(ppos, self._pposinputs.pos)  # pylint: disable=no-member
            < self._sstdinputs.size
        )
Exemple #8
0
    def distanceTo(self, otherpoint):
        """
        Compute the distance to another :class:`_Point` object.

        :param _Point otherpoint: A reference to the other :class:`_Point`
        :rtype: float
        :returns: The distance (in logical units) to the other point
        """
        try:
            return MathApp.distance(self(), otherpoint())
        except AttributeError:
            return otherpoint  # presumably a scalar - use this distance
Exemple #9
0
 def physicalPointTouching(self, ppos):
     r = MathApp.distance(self._pcenter, ppos)
     inner = self._pradius - self.style.width / 2
     outer = self._pradius + self.style.width / 2
     return r <= outer and r >= inner