How to use the pymunk.vec2d.Vec2d._fromcffi function in pymunk

To help you get started, we’ve selected a few pymunk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github viblo / pymunk / pymunk / autogeometry.py View on Github external
"""Returns a copy of a polyline simplified by using the Douglas-Peucker 
    algorithm.

    This works very well on smooth or gently curved shapes, but not well on 
    straight edged or angular shapes.

    :param polyline: Polyline to simplify.
    :type polyline: [(float,float)]
    :param float tolerance: A higher value means more error is tolerated.
    :rtype: [(float,float)]
    """

    _line = lib.cpPolylineSimplifyCurves(_to_chipmunk(polyline), tolerance)
    simplified = []
    for i in range(_line.count):
        simplified.append(Vec2d._fromcffi(_line.verts[i]))
    return simplified
github viblo / pymunk / pymunk / space.py View on Github external
def cf(_shape, point, normal, alpha, data):
            shape = self._get_shape(_shape)
            p = SegmentQueryInfo(
                shape, Vec2d._fromcffi(point), Vec2d._fromcffi(normal), alpha)
            self.__query_hits.append(p)
github viblo / pymunk / pymunk / space_debug_draw_options.py View on Github external
def f4(count, verts, radius, outline_color, fill_color, data):
            vs = []
            for i in range(count):
                vs.append(Vec2d._fromcffi(verts[i]))
            self.draw_polygon(
                vs, radius, 
                self._c(outline_color), self._c(fill_color))   
        _options.drawPolygon = f4
github viblo / pymunk / pymunk / shapes.py View on Github external
def _get_normal(self):
        return Vec2d._fromcffi(cp.cpSegmentShapeGetNormal(self._shape))
    normal = property(_get_normal,
github viblo / pymunk / pymunk / constraint.py View on Github external
def _get_anchor_b(self):
        return Vec2d._fromcffi(cp.cpPinJointGetAnchorB(self._constraint))
    def _set_anchor_b(self, anchor):
github viblo / pymunk / pymunk / space_debug_draw_options.py View on Github external
def f3(a, b, radius, outline_color, fill_color, data):
            self.draw_fat_segment(
                Vec2d._fromcffi(a), Vec2d._fromcffi(b), radius, 
                self._c(outline_color), self._c(fill_color))
        _options.drawFatSegment = f3
github viblo / pymunk / pymunk / constraint.py View on Github external
def _get_anchor_b(self):
        return Vec2d._fromcffi(cp.cpSlideJointGetAnchorB(self._constraint))
    def _set_anchor_b(self, anchor):
github viblo / pymunk / pymunk / constraint.py View on Github external
def _get_anchor_a(self):
        return Vec2d._fromcffi(cp.cpPivotJointGetAnchorA(self._constraint))
    def _set_anchor_a(self, anchor):
github viblo / pymunk / pymunk / shapes.py View on Github external
def _get_offset (self):
        return Vec2d._fromcffi(cp.cpCircleShapeGetOffset(self._shape))
    offset = property(_get_offset, doc="""Offset. (body space coordinates)""")
github viblo / pymunk / pymunk / shapes.py View on Github external
def segment_query(self, start, end, radius=0):
        """Check if the line segment from start to end intersects the shape.

        :rtype: :py:class:`SegmentQueryInfo`
        """
        info = ffi.new("cpSegmentQueryInfo *")
        r = cp.cpShapeSegmentQuery(
            self._shape, tuple(start), tuple(end), radius, info)
        if r:
            ud = cp.cpShapeGetUserData(info.shape)
            assert ud == self._get_shapeid()
            return SegmentQueryInfo(
                self, Vec2d._fromcffi(info.point), Vec2d._fromcffi(info.normal), info.alpha)
        else:
            return SegmentQueryInfo(
                None, Vec2d._fromcffi(info.point), Vec2d._fromcffi(info.normal), info.alpha)