예제 #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
파일: ags.py 프로젝트: ixtel/PythonFractals
    # then no fourth enclosing circle can be genereated, because it
    # would be a line.
    # We need to see for c1, c2, c3 if they could be "x".
    
    impossible = False
    
    sets = [(c1,c2,c3), (c2,c3,c1), (c3,c1,c2)]
    
    for (x, y, z) in sets:
        if x == 2*math.sqrt(y*z) + y + z:
            impossible = True
    
    return impossible

# def main():
color = ColorScheme("colorbrewer.json")
available = [d['name'] for d in color.info()]
# fig=plt.gcf()
# args = parseArguments(sys.argv, available)
cc_list=[[2., 2., 2.],[2., 2., 3.],[5., 8., 8.],[25., 25., 28.],[10., 15., 19.],[18., 23., 18.]]
# Sanity checks
depth=5
treshold=0.005
width = 500
fig,ax=plt.subplots(figsize=(20,20))
# fig, ax = plt.subplots(1)
for en,ccc in enumerate(cc_list):
    # print en,ccc
    for c in ccc:
        if c == 0:
            print("Error: curvature or radius can't be 0")
예제 #4
0
    # would be a line.
    # We need to see for c1, c2, c3 if they could be "x".

    impossible = False

    sets = [(c1, c2, c3), (c2, c3, c1), (c3, c1, c2)]

    for (x, y, z) in sets:
        if x == 2 * math.sqrt(y * z) + y + z:
            impossible = True

    return impossible


# def main():
color = ColorScheme("colorbrewer.json")
available = [d['name'] for d in color.info()]
# fig=plt.gcf()
# args = parseArguments(sys.argv, available)
cc_list = [[2., 2., 2.], [2., 2., 3.], [5., 8., 8.], [25., 25., 28.],
           [10., 15., 19.], [18., 23., 18.]]
# Sanity checks
depth = 5
treshold = 0.005
width = 500
fig, ax = plt.subplots(figsize=(20, 20))
# fig, ax = plt.subplots(1)
for en, ccc in enumerate(cc_list):
    # print en,ccc
    for c in ccc:
        if c == 0: