예제 #1
0
def draw_three(symbols,name):    
    plt.figure()
    side = 10
    zoom = 3
    angle = math.pi/8
    polygon = plt.Polygon([(0,0),(0,-side),(side*math.cos(angle),side*math.sin(angle)-side),(side*math.cos(angle),side*math.sin(angle))],fill=False)
    plt.gca().add_patch(polygon)
    plt.gca().text(side*math.cos(angle)/2, (side*math.sin(angle)- side)/2, symbols[0],
                        # rotation value should in degrees
                        # rotation=self.alphabet_rotation * (180/math.pi) ,
                        fontsize=zoom*side,
                        multialignment='center',
                        verticalalignment='center', horizontalalignment='center',
                        # fontproperties=zhfont1
                    )

    polygon = plt.Polygon([(0,0),(0,-side),(-side*math.cos(angle),side*math.sin(angle)-side),(-side*math.cos(angle),side*math.sin(angle))],fill=False)
    plt.gca().add_patch(polygon)
    plt.gca().text(-side*math.cos(angle)/2, (side*math.sin(angle)- side)/2, symbols[1],
                        # rotation value should in degrees
                        # rotation=self.alphabet_rotation * (180/math.pi) ,
                        fontsize=zoom*side,
                        multialignment='center',
                        verticalalignment='center', horizontalalignment='center',
                        # fontproperties=zhfont1
                    )


    polygon = plt.Polygon([(0,0),(side*math.cos(angle),side*math.sin(angle)),(0,2*side*math.sin(angle)),(-side*math.cos(angle),side*math.sin(angle)) ],fill=False)
    plt.gca().add_patch(polygon)
    plt.gca().text(0, side*math.sin(angle),symbols[2],
                        # rotation value should in degrees
                        # rotation=self.alphabet_rotation * (180/math.pi) ,
                        fontsize=zoom*side,
                        multialignment='center',
                        verticalalignment='center', horizontalalignment='center',
                         # fontproperties=zhfont1
                    )

    plt.axis('image')
    plt.axis('off')
    plt.savefig('./'+name+'.png')   
예제 #2
0
import random
import cv2

X = 4

funcs = ["swap_polygons", "rotate", "flip", "add_vertex"]

for i in range(3):

    # Original figure
    XX = int(random.random() * 10) + 3
    A = Polygon(no_of_sides=XX)
    A.makeRandomCircumcircle()
    polys = [A]

    plt.figure()

    for j in range(2):
        # plt.figure()
        XX = int(random.random() * 10) + 3
        XX = int(random.random()) + 3
        print(XX, "isXX")
        B = Polygon(no_of_sides=XX, size=random.random() * 40)
        B.clone_circumcircle(A)
        # Center remains same as A but the radius can be anything less than A's raduis
        B.circumcircle.radius = 0.8 * B.circumcircle.radius
        B.makeShape()
        # B.drawPolygon()
        polys.append(B)
        A = B
예제 #3
0
def draw_type(layout_type=1):
    """
    This will draw a type.
    """
    # More randomnes unique
    # symbols = ["#","-","*","**","^","?"]
    # symbols = random.choice(['1','2','3','4','5','6']
    symbols = ['#','*','-','?','^','**',u'\u2605',u'\u2020',u'\u002B']
    random.shuffle(symbols)
    # symbols = [random.choice(['#','*','1','-','?','2','^','**','**\n*']) for i in range(6)]
    # symbols = [1,2,3,4,5,6]

    side = 10
    X_base = 0
    Y_base = 0
    zoom=3

    triplets = [ (2,5,1),(6,2,1),(2,3,5),(2,3,6),
                 (1,4,6),(4,1,5),(4,6,3),(5,3,4)]

    wrong_triplets = [ (2,1,4),(2,4,5),(4,6,2),(2,3,4)] 

    plt.figure()


    # Firs four are always drawn the same way
    for i in range(4):
            # draw 1-4
            polygon = plt.Rectangle((0,-i*side),side,side,fill=False)
            plt.gca().text(side/2, -(i*side-side/2), symbols[i],
                        # rotation value should in degrees
                        # rotation=self.alphabet_rotation * (180/math.pi) ,
                        fontsize= side * zoom ,
                        multialignment='center',
                        verticalalignment='center', horizontalalignment='center',
                        # fontproperties=zhfont1
                    )
            plt.gca().add_patch(polygon)


    if layout_type == 1:
        
        #  Type 1
        #   1
        #   |
        # 5-2-6       
        #   |          
        #   3
        #   |
        #   4
        # 
        # 2-1-5 
        # 2-1-6
        # 2-3-5
        # 2-3-6
        # 4-1-6
        # 4-1-5
        # 4-3-6
        # 4-3-5

        # Draw 5
        polygon = plt.Rectangle((-side,-side),side,side,fill=False)
        plt.gca().text(-side/2, -side/2, symbols[4],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)

        # # Draw 6
        polygon = plt.Rectangle((side,-side),side,side,fill=False)
        plt.gca().text(side+side/2, -side/2, symbols[5],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)
    elif layout_type == 2:
        #  Type 2
        # 5-1
        #   |
        #   2-6       
        #   |          
        #   3
        #   |
        #   4
        # 
        # 2-1-5 
        # 2-1-6
        # 2-3-5
        # 2-3-6
        # 4-1-6
        # 4-1-5
        # 4-3-6
        # 4-3-5

        # Draw 5
        polygon = plt.Rectangle((-side,0),side,side,fill=False)
        plt.gca().text(-side/2, +side/2, symbols[4],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)

        # # Draw 6
        polygon = plt.Rectangle((side,-side),side,side,fill=False)
        plt.gca().text(side+side/2, -side/2, symbols[5],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)
    elif layout_type == 3:
        # pass
        #  Type 2
        #   1
        #   |
        # 5-2       
        #   |          
        #   3-6
        #   |
        #   4
        # 
        # 2-1-5 
        # 2-1-6
        # 2-3-5
        # 2-3-6
        # 4-1-6
        # 4-1-5
        # 4-3-6
        # 4-3-5

        # Draw 5
        polygon = plt.Rectangle((-side,-side),side,side,fill=False)
        plt.gca().text(-side/2, -side/2, symbols[4],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)

        # # Draw 6
        polygon = plt.Rectangle((side,-2*side),side,side,fill=False)
        plt.gca().text(side+side/2, -side/2-side, symbols[5],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)

    elif layout_type == 4:
        
        #  Type 2
        # 5-1
        #   |
        #   2      
        #   |          
        #   3-6
        #   |
        #   4
        
        # Draw 5
        polygon = plt.Rectangle((-side,0),side,side,fill=False)
        plt.gca().text(-side/2, -side/2+side, symbols[4],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)

        # # Draw 6
        polygon = plt.Rectangle((side,-2*side),side,side,fill=False)
        plt.gca().text(side+side/2, -side/2-side, symbols[5],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)
    elif layout_type == 5:
        
        #  Type 2
        #   1
        #   |
        # 5-2      
        #   |          
        #   3
        #   |
        #   4-6
        # 
       
        # Draw 5
        polygon = plt.Rectangle((-side,-side),side,side,fill=False)
        plt.gca().text(-side/2, -side/2, symbols[4],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)

        # # Draw 6
        polygon = plt.Rectangle((side,-3*side),side,side,fill=False)
        plt.gca().text(side+side/2, -side/2-2*side, symbols[5],
                    # rotation value should in degrees
                    # rotation=self.alphabet_rotation * (180/math.pi) ,
                    fontsize=zoom*side,
                    multialignment='center',
                    verticalalignment='center', horizontalalignment='center',
                    # fontproperties=zhfont1
                )
        plt.gca().add_patch(polygon)





        
    plt.axis('image')
    plt.axis('off')
    plt.savefig('./dicelayout.png')  

    random.shuffle(triplets)
    random.shuffle(wrong_triplets)
 
    for i in range(3):
        temp_triplet = triplets[i]
        draw_three([symbols[j-1] for j in temp_triplet],'dice'+str(i+1))

    for i in range(3):
        temp_triplet = wrong_triplets[i]
        draw_three([symbols[j-1] for j in temp_triplet],'dice_'+str(i+1))
예제 #4
0
# print(a, ','.join(a))

# filename = ''
# for i in a:
#     filename+= ' ./plot/series/dist'+i+'.png'

# os.system('montage -mode concatenate -tile '+str(max(SIDE_REPEAT_FREQ, HATCH_REPEAT_FREQ))+'x1 '+filename+' ./plot/series/'+ID+'dist.png')

# #############################################################################

polys = []

TOTAL_FIG = 6

for i in range(TOTAL_FIG):
    plt.figure()
    A = Polygon(no_of_sides=3 + int(random.random() * 10),
                isRegular=True,
                hatch=None)
    A.makeRandomCircumcircle()
    polys.append(A)
    A.drawPolygon()
    # plt.axis('off')
    # plt.axis('image')

plt.figure()
for i in range(len(polys)):
    if i % 2 != 0:
        polys[i].gen_inside(polys[i - 1])
        polys[i - 1].hatch = None
        polys[i].hatch = 'random'