コード例 #1
0
ファイル: ag.py プロジェクト: bajor/apollon
def main():
    color = ColorScheme("colorbrewer.json")
    available = [d["name"] for d in color.info()]

    args = parseArguments(sys.argv, available)

    # Sanity checks
    for c in [args.c1, args.c2, args.c3]:
        if c == 0:
            print("Error: curvature or radius can't be 0")
            exit(1)
    if impossible_combination(args.c1, args.c2, args.c3):
        print("Error: no apollonian gasket possible for these curvatures")
        exit(1)

    # Given curvatures were in fact radii, so take the reciprocal
    if args.radii:
        args.c1 = 1 / args.c1
        args.c2 = 1 / args.c2
        args.c3 = 1 / args.c3

    ag = ApollonianGasket(args.c1, args.c2, args.c3)

    # At a recursion depth > 10 things start to get serious.
    if args.depth > 10:
        if not args.force:
            print(
                "Note: Number of cicles increases exponentially with 2*3^{D+1} at depth D.\nIf you want to use D>10, specify the --force option."
            )
            args.depth = 10

    ag.generate(args.depth)

    # Get smallest and biggest radius
    smallest = abs(min(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)
    biggest = abs(max(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)

    # Construct color map
    if args.color == "none":
        mp = ColorMap("none")
    else:
        # TODO: resolution of 8 is hardcoded, some color schemes have
        # resolutions up to 11. Make this configurable.
        mp = color.makeMap(smallest, biggest, args.color, 8)

    svg = ag_to_svg(ag.genCircles, mp, tresh=args.treshold)

    # User supplied filename? If not, we need to construct something.
    if len(args.output) == 0:
        args.output = "ag_%.4f_%.4f_%.4f.svg" % (args.c1, args.c2, args.c3)

    with open(args.output, "w") as f:
        f.write(svg)
        f.close()
コード例 #2
0
def main():
    color = ColorScheme("colorbrewer.json")
    available = [d['name'] for d in color.info()]

    args = parseArguments(sys.argv, available)

    # Sanity checks
    for c in [args.c1, args.c2, args.c3]:
        if c == 0:
            print("Error: curvature or radius can't be 0")
            exit(1)
    if impossible_combination(args.c1, args.c2, args.c3):
        print("Error: no apollonian gasket possible for these curvatures")
        exit(1)

    # Given curvatures were in fact radii, so take the reciprocal
    if args.radii:
        args.c1 = 1 / args.c1
        args.c2 = 1 / args.c2
        args.c3 = 1 / args.c3

    ag = ApollonianGasket(args.c1, args.c2, args.c3)

    # At a recursion depth > 10 things start to get serious.
    if args.depth > 10:
        if not args.force:
            print(
                "Note: Number of cicles increases exponentially with 2*3^{D+1} at depth D.\nIf you want to use D>10, specify the --force option."
            )
            args.depth = 10

    ag.generate(args.depth)

    # Get smallest and biggest radius
    smallest = abs(min(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)
    biggest = abs(max(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)

    # Construct color map
    if args.color == 'none':
        mp = ColorMap('none')
    else:
        # TODO: resolution of 8 is hardcoded, some color schemes have
        # resolutions up to 11. Make this configurable.
        mp = color.makeMap(smallest, biggest, args.color, 8)

    svg = ag_to_svg(ag.genCircles, mp, tresh=args.treshold)

    # User supplied filename? If not, we need to construct something.
    if len(args.output) == 0:
        args.output = 'ag_%.4f_%.4f_%.4f.svg' % (args.c1, args.c2, args.c3)

    with open(args.output, 'w') as f:
        f.write(svg)
        f.close()
コード例 #3
0
def main(c1=3.,c2=2.,c3=2.,depth=5):
    # Sanity checks
    for c in [c1, c2,c3]:
        if c == 0:
            print("Error: curvature or radius can't be 0")
            exit(1)
    if impossible_combination(c1, c2, c3):
        print("Error: no apollonian gasket possible for these curvatures")
        exit(1)

    ag = ApollonianGasket(c1, c2, c3)
 
    ag.generate(depth)

    # Get smallest and biggest radius
    smallest = abs(min(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)
    biggest = abs(max(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)

    return ag.genCircles
コード例 #4
0
ファイル: ag.py プロジェクト: macbuse/Apollonian
def main(c1=3.,c2=2.,c3=2.,depth=5):


    # Sanity checks
    for c in [c1, c2,c3]:
        if c == 0:
            print("Error: curvature or radius can't be 0")
            exit(1)
    if impossible_combination(c1, c2, c3):
        print("Error: no apollonian gasket possible for these curvatures")
        exit(1)


    ag = ApollonianGasket(c1, c2, c3)
 
    ag.generate(depth)

    # Get smallest and biggest radius
    smallest = abs(min(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)
    biggest = abs(max(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)

    return ag.genCircles
コード例 #5
0
ファイル: ags.py プロジェクト: ixtel/PythonFractals
            exit(1)
        if impossible_combination(ccc[0],ccc[1],ccc[2]):
            print("Error: no apollonian gasket possible for these curvatures")
            exit(1)

        # Given curvatures were in fact radii, so take the reciprocal
        # if args.radii:

        # c1 = 1/ccc[0]
        # c2 = 1/ccc[1]
        # c3 = 1/ccc[2]
        c1=ccc[0]
        c2=ccc[1]
        c3=ccc[2]

        ag = ApollonianGasket(c1,c2,c3)

        # At a recursion depth > 10 things start to get serious.
        # if args.depth > 10:
        #     if not args.force:
        #         print("Note: Number of cicles increases exponentially with 2*3^{D+1} at depth D.\nIf you want to use D>10, specify the --force option.")
        #         args.depth = 10

        ag.generate(depth)

        # Get smallest and biggest radius
        smallest = abs(min(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)
        biggest = abs(max(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)

        # Construct color map 
        # if args.color == 'none':
コード例 #6
0
            exit(1)
        if impossible_combination(ccc[0], ccc[1], ccc[2]):
            print("Error: no apollonian gasket possible for these curvatures")
            exit(1)

        # Given curvatures were in fact radii, so take the reciprocal
        # if args.radii:

        # c1 = 1/ccc[0]
        # c2 = 1/ccc[1]
        # c3 = 1/ccc[2]
        c1 = ccc[0]
        c2 = ccc[1]
        c3 = ccc[2]

        ag = ApollonianGasket(c1, c2, c3)

        # At a recursion depth > 10 things start to get serious.
        # if args.depth > 10:
        #     if not args.force:
        #         print("Note: Number of cicles increases exponentially with 2*3^{D+1} at depth D.\nIf you want to use D>10, specify the --force option.")
        #         args.depth = 10

        ag.generate(depth)

        # Get smallest and biggest radius
        smallest = abs(min(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)
        biggest = abs(max(ag.genCircles, key=lambda c: abs(c.r.real)).r.real)

        # Construct color map
        # if args.color == 'none':