Exemplo n.º 1
0
    def on_key(*args):

        P = np.random.randint(100,700,(4,2))
        C = CubicBezier(*P)

        plt.cla()
        plt.ion()

        cubic_bezier(C.p0,C.p1,C.p2,C.p3)

        # P = C.flatten_forward_iterative(n=50)
        # P = np.array(P)
        # polyline(P, linewidth=100, alpha=.25)
        # plt.scatter(P[:,0], P[:,1], s=25,
        #             edgecolor='k', facecolor='w', zorder=10, lw=.1)

        P = C.flatten_iterative(flatness=.125, angle=10)
        P = np.array(P)
        polyline(P, linewidth=100, alpha=.1)
        plt.scatter(P[:,0], P[:,1], s=25, edgecolor='k', facecolor='w', zorder=10, lw=.5)

        # P = C.flatten_recursive(flatness=.125, angle=10) 
        # P = np.array(P)
        # polyline(P, linewidth=100, alpha=.1)
        # plt.scatter(P[:,0], P[:,1], s=25, edgecolor='k', facecolor='w', zorder=10, lw=.5)

        #A = C.flatten_behdad_arc(0.125)
        #polyarc(A, linewidth=100, alpha=.1)

        print "[%d,%d %d,%d %d,%d, %d,%d] : %s" % (
            C.p0[0],C.p0[1], C.p1[0],C.p1[1],
            C.p2[0],C.p2[1], C.p3[0],C.p3[1],
            cubic_bezier_type( vec2(C.p0[0],C.p0[1]),
                               vec2(C.p1[0],C.p1[1]),
                               vec2(C.p2[0],C.p2[1]),
                               vec2(C.p3[0],C.p3[1]) ))
        print '%d points generated' % len(P)

        plt.ioff()
Exemplo n.º 2
0
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of Nicolas P. Rougier.
# ----------------------------------------------------------------------------
import time
import numpy as np
from cubic_bezier import CubicBezier
from bezier_type import CubicBezierType, cubic_bezier_type




# np.random.seed(1)
n = 100000
curves = np.random.randint(0,100,(n,4,2))

types = {CubicBezierType.arch   : 0,
         CubicBezierType.line   : 0,
         CubicBezierType.single : 0,
         CubicBezierType.double : 0,
         CubicBezierType.loop   : 0,
         CubicBezierType.cusp   : 0}
         
for i in range(n):
    C = CubicBezier(*curves[i])
    t = cubic_bezier_type(*curves[i])
    types[t] += 1

for key, value in types.items():
    print "%-18s: %.2f%%" % (key, 100* value/float(n))

Exemplo n.º 3
0
#
# The views and conclusions contained in the software and documentation are
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of Nicolas P. Rougier.
# ----------------------------------------------------------------------------
import time
import numpy as np
from cubic_bezier import CubicBezier
from bezier_type import CubicBezierType, cubic_bezier_type

# np.random.seed(1)
n = 100000
curves = np.random.randint(0, 100, (n, 4, 2))

types = {
    CubicBezierType.arch: 0,
    CubicBezierType.line: 0,
    CubicBezierType.single: 0,
    CubicBezierType.double: 0,
    CubicBezierType.loop: 0,
    CubicBezierType.cusp: 0
}

for i in range(n):
    C = CubicBezier(*curves[i])
    t = cubic_bezier_type(*curves[i])
    types[t] += 1

for key, value in types.items():
    print "%-18s: %.2f%%" % (key, 100 * value / float(n))