コード例 #1
0
ファイル: main.py プロジェクト: DiskenPeelen/elektro-zeszyt
def generate_img_2b(C=400):
    '''Image "Linie pola ekektr wokół 2 punktowych ładunków jednoimiennych"'''
    image = Image((C * 4, C * 2), line_width=3)
    # left
    image.draw_circle(Circle((C, C), int(C * 0.4)), fill=[190, 0, 0], width=10)
    image.draw_line(Line((C, int(C + (C * 0.1))), (C, int(C - (C * 0.1)))),
                    fill=[190, 0, 0])
    image.draw_line(Line((int(C + (C * 0.1)), C), (int(C - (C * 0.1)), C)),
                    fill=[190, 0, 0])
    # right
    image.draw_circle(Circle((3 * C, C), int(C * 0.4)),
                      fill=[190, 0, 0],
                      width=10)
    image.draw_line(Line((3 * C, int(C + (C * 0.1))),
                         (3 * C, int(C - (C * 0.1)))),
                    fill=[190, 0, 0])
    image.draw_line(Line((int(3 * C + (C * 0.1)), C),
                         (int(3 * C - (C * 0.1)), C)),
                    fill=[190, 0, 0])
    # vertical
    image.draw_line(Line((2 * C, 0), (2 * C, 2 * C)), width=1)
    # vectors
    image.draw_vector(
        Vector((int(C * 1.5), int(C * 1.1)), (int(C * 0.25), int(C * 0.3))))
    image.draw_vector(
        Vector((int(C * 1.5), int(C * 0.9)), (int(C * 0.25), -int(C * 0.3))))
    image.draw_vector(Vector((int(C * 1.8), int(C * 1.5)), (0, int(C * 0.4))))
    image.draw_vector(Vector((int(C * 1.8), int(C * 0.5)), (0, -int(C * 0.4))))
    image.draw_vector(
        Vector((int(C * 2.5), int(C * 1.1)), (-int(C * 0.25), int(C * 0.3))))
    image.draw_vector(
        Vector((int(C * 2.5), int(C * 0.9)), (-int(C * 0.25), -int(C * 0.3))))
    image.draw_vector(Vector((int(C * 2.2), int(C * 1.5)), (0, int(C * 0.4))))
    image.draw_vector(Vector((int(C * 2.2), int(C * 0.5)), (0, -int(C * 0.4))))
    #
    image.draw_vector(
        Vector((int(C * 1.4), int(C * 1.25)), (int(C * 0.20), int(C * 0.40))))
    image.draw_vector(
        Vector((int(C * 1.4), int(C * 0.75)), (int(C * 0.20), -int(C * 0.40))))
    image.draw_vector(
        Vector((int(C * 2.6), int(C * 1.25)), (-int(C * 0.20), int(C * 0.40))))
    image.draw_vector(
        Vector((int(C * 2.6), int(C * 0.75)),
               (-int(C * 0.20), -int(C * 0.40))))
    #
    image.draw_vector(
        Vector((int(C * 1.2), int(C * 1.4)), (int(C * 0.1), int(C * 0.5))))
    image.draw_vector(
        Vector((int(C * 1.2), int(C * 0.6)), (int(C * 0.1), -int(C * 0.5))))
    image.draw_vector(
        Vector((int(C * 2.8), int(C * 1.4)), (-int(C * 0.1), int(C * 0.5))))
    image.draw_vector(
        Vector((int(C * 2.8), int(C * 0.6)), (-int(C * 0.1), -int(C * 0.5))))
    image.save('img/img_2b.png')
コード例 #2
0
ファイル: main.py プロジェクト: DiskenPeelen/elektro-zeszyt
def generate_img_1b(C=400):
    '''Image "Linie pola ekektr wokół punktowego ładunku ujemnego"'''
    image = Image((C * 2, C * 2), line_width=3)
    image.draw_circle(Circle((C, C), int(C * 0.4)), fill=[0, 0, 190], width=10)
    image.draw_line(Line((int(C + (C * 0.1)), C), (int(C - (C * 0.1)), C)),
                    fill=[0, 0, 190])
    for deg in range(0, 360, 360 // 12):
        prevector = Vector.from_rotation((C, C), deg, int(C * 0.95))
        vector = Vector.from_reversed(prevector)
        vector.scale(0.45)
        vector.round()
        image.draw_vector(vector)
    image.save('img/img_1b.png')
コード例 #3
0
ファイル: main.py プロジェクト: DiskenPeelen/elektro-zeszyt
def generate_img_2a(C=400):
    '''Image "Linie pola ekektr wokół 2 punktowych ładunków różnoimiennych"'''
    image = Image((C * 4, C * 2), line_width=3)
    # pos
    image.draw_circle(Circle((C, C), int(C * 0.4)), fill=[190, 0, 0], width=10)
    image.draw_line(Line((C, int(C + (C * 0.1))), (C, int(C - (C * 0.1)))),
                    fill=[190, 0, 0])
    image.draw_line(Line((int(C + (C * 0.1)), C), (int(C - (C * 0.1)), C)),
                    fill=[190, 0, 0])
    # neg
    image.draw_circle(Circle((3 * C, C), int(C * 0.4)),
                      fill=[0, 0, 190],
                      width=10)
    image.draw_line(Line((int(3 * C + (C * 0.1)), C),
                         (int(3 * C - (C * 0.1)), C)),
                    fill=[0, 0, 190])
    # straight vectors
    image.draw_vector(Vector((int(C * 1.5), C), (int(C * 0.4), 0)))
    image.draw_vector(Vector((int(C * 1.5), int(C * 1.2)), (int(C * 0.4), 0)))
    image.draw_vector(Vector((int(C * 1.5), int(C * 0.8)), (int(C * 0.4), 0)))
    image.draw_vector(Vector((int(C * 2.1), C), (int(C * 0.4), 0)))
    image.draw_vector(Vector((int(C * 2.1), int(C * 1.2)), (int(C * 0.4), 0)))
    image.draw_vector(Vector((int(C * 2.1), int(C * 0.8)), (int(C * 0.4), 0)))
    # slightly curved vectors
    image.draw_vector(
        Vector((int(C * 1.5), int(C * 1.4)), (int(C * 0.4), int(C * 0.05))))
    image.draw_vector(
        Vector((int(C * 2.1), int(C * 1.45)), (int(C * 0.4), int(C * -0.05))))
    image.draw_vector(
        Vector((int(C * 1.5), int(C * 0.6)), (int(C * 0.4), int(C * -0.05))))
    image.draw_vector(
        Vector((int(C * 2.1), int(C * 0.55)), (int(C * 0.4), int(C * 0.05))))
    # curved 3-part vectors
    image.draw_vector(
        Vector((int(C * 1.1), int(C * 1.5)), (int(C * 0.4), int(C * 0.1))))
    image.draw_vector(Vector((int(C * 1.8), int(C * 1.65)), (int(C * 0.4), 0)))
    image.draw_vector(
        Vector((int(C * 2.5), int(C * 1.6)), (int(C * 0.4), int(C * -0.1))))
    image.draw_vector(
        Vector((int(C * 1.1), int(C * 0.5)), (int(C * 0.4), int(C * -0.1))))
    image.draw_vector(Vector((int(C * 1.8), int(C * 0.35)), (int(C * 0.4), 0)))
    image.draw_vector(
        Vector((int(C * 2.5), int(C * 0.4)), (int(C * 0.4), int(C * 0.1))))
    image.save('img/img_2a.png')