�������Ա�Ķ���IJ��ͣ�??������Ϧ������������������Python�� _ ��IIS7վ��֮�ҡ�

��ǰλ�� ������ҳ > �������Ա�Ķ���IJ��ͣ�??������Ϧ������������������Python��

    �������Ա�Ķ���IJ��ͣ�??������Ϧ������������������Python��

    ���ߣ�[db:����] ʱ�䣺2021-08-14 12:00

    һ��һ�ȵ���Ϧ��Ҫ������,���ߵ�����������:��ʲô?������ô��,��ô���������������͵�ʲô��!ڤ˼����֮����Ϊ����Գ����������Ҫ�����һ�����������Լ�������,�������ʹ��Ŵ����Python���롱����Ϧ��

    PS:��Ϧ��Ȼ��Ҫ��һ��ר��������,���ĵ����гɹ������Զ���,�����ղ�!

    ??��̬��Ƭ��ά��

    ������һ���򵥵�ľ�̬��Ƭ��ά������,������/��/������Ƭ,���ú�����˵�Ļ�,������Ƭ�Ϳ����ˡ�
    �������ǿ������ö��ֲ�����������ά��Ĺ��,��ͬ��

    • words:��ά������,���ӻ��߾���(�ݲ�֧������)
    • veision:��ά���С,��ΧΪ[1,40]
    • level:��ά���������,��ΧΪ{L,M,Q,H},HΪ��߼�,Ĭ�ϡ�
    • picture:�Զ����ά�뱳��ͼ,֧�ָ�ʽΪ .jpg,.png,.bmp,.gif,Ĭ��Ϊ�ڰ�ɫ
    • colorized:��ά�뱳����ɫ,Ĭ��Ϊ False,���ڰ�ɫ
    • contrast:�Աȶ�,ֵԽ�߶Աȶ�Խ��,Ĭ��Ϊ 1.0
    • brightness:����,ֵԽ������Խ��,Ĭ��Ϊ 1.0,�����ͶԱȶ���ͬ
    • save_name:��ά������,Ĭ��Ϊ qrcode.png
    • save_dir:��ά��·��,Ĭ��Ϊ������·��
    from MyQR import myqr
    myqr.run(words="Welcome to Here!",
             version=6,
             picture="lye.jpg",
             colorized=True,
             save_name="lye.png",
            )
    # �����Ҫ�����洢·��,����ʹ��save_dir=""������        
    

    ���չʾ����:
    ������ͼƬ����
    ��ô��,һ�������Ķ�ά���Dz����ܹ����㲶�����ķ�����,���ܵĻ����Ǽ���������~

    🌟��̬��Ƭ��ά��

    ���˾�̬�Ķ�ά������,�϶�Ҳ�ٲ������ɶ�̬�Ķ�ά��,���ɶ�̬��ά����Ҫ����ʹ��һ��gifͼƬǶ�뵽��ά���ڲ�,��������Ƽ����ʹ��һЩ��ƵƬ�λ�������Ƭ�ϼ�����gif��ʹ�á����ɶ�̬��ά��ķ�ʽ�����澲̬��ά��ķ�ʽ��ͬ,ֱ���ϴ���:

    from MyQR import myqr
    myqr.run(
        words="I Love You",
        version=6,
        picture="linyuner.gif",
        colorized=True,
        save_name="lyeqr.gif",
    )
    

    ���չʾ����(ͼûѡ��,΢΢��ģ����):
    ������ͼƬ����
    ʲô?�������ò�����?����������һ��!

    🌹�ַ�����ͼ

    �����˶�ά��,���ܱ��׵����Ȼ�������, ��ô����?��������ٴ������һ���ַ�����ͼ,�ô���ܹ����黰����������/��/��������ȥ������䡣
    ʵ���ַ�����ͼ������˼·����:

    • ����������ַ�,���ɰ׵׺��ֵ�ͼƬ����(һ����Ҫ��͸���ı���,����ɻ��ƴ��Ƴ���)
    • ��ȡ��һ�����õ�ͼƬ,���ƴ���ͼ���ɡ�

    �ڴ��ƵĴ�����и����˸����ܹ��Դ���ͼ��Ч�����е�����ע��,��Ҹ���ע��ֱ�ӽ�����Ӧ�ĵ�������,������ֱ���ϴ���:

    from wordcloud import WordCloud
    import wordcloud
    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    from PIL import Image, ImageDraw, ImageFont
    # �����ȡͼƬ����
    from PIL import ImageFile
    ImageFile.LOAD_TRUNCATED_IMAGES = True
    import os
    
    # ��ȡ��������
    def gen_text_img(text, font_size, font_path=None):
        '''
        ����:
        text:��Ƭǽ����ʽ����
        font_size:����Ĵ�С
        font_path:����
        ����:
        ����ͼ��
        '''
        font = ImageFont.truetype(font_path, font_size)
        (width, length) = font.getsize(text)
        text_img = Image.new('RGB', (width + 100, length+100), color='white')
        draw = ImageDraw.Draw(text_img)
        # �����Ͻǿ�ʼ����,ÿ�ε���λ�����ڼӴ�����
        for i in range(100):
            draw.text((i, i), text, fill=(0, 0, 0), font=font)
        text_img.save('background.png')
        return text_img
    
    
    def word_cloud(img, word, font_path=None):
        
        wc_mask = np.array(Image.open('background.png'))
        wc = wordcloud.WordCloud(
            # ���������ʽ
            font_path=font_path,
            # ���ñ���ͼ
            mask=wc_mask,
            # �����ʾ����
            max_words=200,
            # �������ֵ
            max_font_size=320,
            # ���屳��ɫ
            background_color='White',
            # ���Ƶı߿��С
            contour_width=2,
            # ���Ƶı߿���ɫ
            contour_color='pink',
            # ���������ظ�
            repeat=True,
            color_func=lambda *args, 
            **kwargs: "pink")
    
        # ���ֵ����ɴ���
        wc.generate(word)
        # �ӱ���ͼ������ɫ����
        image_colors = wordcloud.ImageColorGenerator(wc_mask)
        # ��ʾ����
        plt.figure(figsize=[10, 10], dpi=300)
        plt.imshow(wc)
        plt.axis('off')
        plt.show()
    
    def main(font_path='buzz_cloud_font.ttf',
             font_size=2000,
             ):
        word = input('����������:')
        text = input('�����뱳����:')
        img = gen_text_img(text,font_size, font_path)
        word_cloud(img,word,font_path)
    main()
    

    ���չʾ����(����һ��):
    ���������ͼƬ����
    ����͵͵���Լ����Լ�����ͼ,��������һ�¸�λС�����,��Ҫ��ɱ��˵�����,����ÿ���ּǵô���ȷ��,��Ȼ�����ٲ��˵ļ�ͥì��(��������ô֪����)��

    💎�������ı���

    ���������ǻ����Ի���һ���������ĵı���Ч������һ�¡�
    ��Ч����Ҫʹ�ú�����ͼ�ķ���������,���ȶ���û�����ͨ���ĵĴ���,Ϊ�˺ÿ�һЩ����������ķ�ʽ���л���,����ij��ֵĵ�ַ,�����ɫ,�����С,�������Ҫ��������ķ�Χ�ڴ��������е������ɡ�����ϸ�����ڽǶȵİѿ�,���ﲻ��������׸��,ֱ���ϴ��롣

    import random
    import turtle
    from turtle import mainloop, hideturtle
    
    
    # ����
    def draw_heart(size, color_):
        turtle.speed(0)
        turtle.colormode(255)
        turtle.color(color_)
        turtle.pensize(2)
        turtle.pendown()
        turtle.setheading(150)
        turtle.begin_fill()
        turtle.fd(size)
        turtle.circle(size * -3.745, 45)
        turtle.circle(size * -1.431, 165)
        turtle.left(120)
        turtle.circle(size * -1.431, 165)
        turtle.circle(size * -3.745, 45)
        turtle.fd(size)
        turtle.end_fill()
    
    
    # �����ɫ,��С,λ��
    def draw():
    	# �����ɫ
        colors1 = random.randint(0, 255)
        colors2 = random.randint(0, 255)
        colors3 = random.randint(0, 255)
        turtle.penup()
        # ����
        x = random.randint(-400, 400)
        y = random.randint(-200, 200)
        turtle.goto(x, y)
        # �����С
        size = random.randint(10, 20)
        draw_heart(size, (colors1, colors2, colors3))
    
    
    # ������
    def main():
        hideturtle()
        turtle.setup(900, 500)
        # �����ij��ֵĸ���
        for i in range(30):
            draw()
        turtle.penup()
        turtle.goto(-200, 0)
        turtle.color('Black')
        turtle.write('���������ް�!', font=('����', 60, 'normal'))
        mainloop()
    
    
    main()
    

    ������:
    ������ͼƬ����
    ����һ���������ĵ�ͼ�������Dz��ǻ�˵�ù�ȥ,�����ְ��Լ�����ȥ��,ϣ����ҵ���ް�~������Ȼ�����,�Ǿ�ֻ���ٻ�һ�����һ���ͼ�ˡ�

    🔥BiuBiuBiu~

    ���,���ǿ�����һ����ֵ�С�˺Ͱ���,С��Ҫ���������ڹ�������������,���ֿ��ŵĶ������ﻭ����̫��,���������Ȼ�һ������ʹ��һ��,С�˵Ĺ��������д�������������������滭������С���ľͿ����ˡ�ֱ�ӿ������~

    import turtle
    import time
    from turtle import mainloop, hideturtle
    
    
    def clear_all():
        turtle.penup()
        turtle.goto(0, 0)
        turtle.color('white')
        turtle.pensize(800)
        turtle.pendown()
        turtle.setheading(0)
        turtle.fd(300)
        turtle.bk(600)
    
    
    # �ض�λ�����λ��
    def go_to(x, y, state):
        turtle.pendown() if state else turtle.penup()
        turtle.goto(x, y)
    
    
    def draw_heart(size):
        turtle.color('red', 'pink')
        turtle.pensize(2)
        turtle.pendown()
        turtle.setheading(150)
        turtle.begin_fill()
        turtle.fd(size)
        turtle.circle(size * -3.745, 45)
        turtle.circle(size * -1.431, 165)
        turtle.left(120)
        turtle.circle(size * -1.431, 165)
        turtle.circle(size * -