用Python代码画出汤姆杰瑞CP

简介

用python代码画出汤姆杰瑞CP,仅使用turtle库。如下:
在这里插入图片描述

绘画过程可以在下列平台查看:

抖音:用代码画出这对可爱的搭档
b站:用代码画出这对可爱的搭档_哔哩哔哩_bilibili

代码

# coding=gbk

import turtle

def plotLine(points, pencolor=None, width=None, speed=None):
    '''
    功能:画折线
    参数:
    - points : 一系列点,用列表或元组表示
    - pencolor : 画笔颜色,默认不变
    - width : 画笔宽度,默认不变
    - speed : 绘制速度,默认不变
    '''
    # 记录旧参数
    oldpencolor = turtle.pencolor()
    oldwidth = turtle.width()
    oldspeed = turtle.speed()

    # 修改新参数
    if pencolor is not None:
        turtle.pencolor(pencolor)
    if width is not None:
        turtle.width(width)
    if speed is not None:
        turtle.speed(speed)
    
    # 绘制折线
    turtle.up()
    turtle.goto(points[0])
    turtle.down()
    for point in points[1:]:
        turtle.goto(point)
    
    # 恢复旧参数
    turtle.pencolor(oldpencolor)
    turtle.width(oldwidth)
    turtle.speed(oldspeed)


def plotPoly(points, fill=False, pencolor=None, fillcolor=None,
             width=None, speed=None):
    '''
    功能:绘制封闭多边形
    '''
    # 保存旧参数
    oldfillcolor = turtle.fillcolor()

    # 更新新参数
    if fillcolor is not None:
        turtle.fillcolor(fillcolor)

    # 绘制封闭多边形
    points_plotline = list(points) + [points[0]]
    if fill:
        turtle.begin_fill()
        plotLine(points_plotline, pencolor, width, speed)
        turtle.end_fill()
    else:
        plotLine(points_plotline, pencolor, width, speed)

    # 恢复旧参数
    turtle.fillcolor(oldfillcolor)

# 设置一些参数
turtle.setup(600, 600, 100, 100)

# 绘制

# 轮廓
points = [
    (-42, 258), (-47, 251), (-53, 242), (-58, 233), (-63, 224), 
    (-67, 214), (-71, 205), (-75, 193), (-78, 182), (-80, 179), 
    (-83, 174), (-87, 168), (-93, 161), (-92, 167), (-92, 172), 
    (-91, 182), (-94, 191), (-96, 183), (-96, 173), (-98, 166), 
    (-101, 157), (-105, 150), (-108, 142), (-113, 136), (-120, 126), 
    (-113, 129), (-108, 131), (-113, 129), (-119, 126), (-133, 125), 
    (-145, 127), (-161, 129), (-184, 129), (-199, 127), (-212, 124), 
    (-222, 120), (-238, 113), (-247, 105), (-258, 97), (-248, 89), 
    (-241, 81), (-235, 73), (-230, 65), (-225, 59), (-218, 49), 
    (-212, 39), (-205, 30), (-198, 21), (-190, 13), (-180, 4), 
    (-171, -4), (-159, -11), (-147, -16), (-141, -17), (-132, -18), 
    (-131, -22), (-142, -23), (-149, -25), (-156, -30), (-161, -35), 
    (-168, -44), (-175, -55), (-180, -65), (-184, -76), (-188, -88), 
    (-192, -101), (-196, -115), (-200, -132), (-203, -149), (-206, -165), 
    (-207, -180), (-209, -193), (-210, -208), (-210, -224), (-211, -268), 
    (-210, -280), (-209, -291), (-209, -303), (-20, -305), (-23, -298), 
    (-27, -288), (-36, -266), (-18, -265), (1, -257), (15, -246), 
    (26, -233), (34, -224), (72, -241), (84, -246), (103, -246), 
    (110, -243), (116, -240), (122, -234), (126, -224), (130, -215), 
    (132, -205), (135, -196), (137, -185), (137, -175), (137, -162), 
    (145, -164), (154, -164), (161, -162), (166, -157), (172, -151), 
    (174, -144), (175, -141), (179, -139), (188, -134), (195, -129), 
    (202, -121), (206, -113), (208, -104), (209, -94), (210, -82), 
    (209, -78), (213, -72), (216, -66), (219, -60), (219, -53), 
    (221, -39), (218, -31), (213, -26), (213, -22), (209, -17), 
    (206, -14), (209, -10), (211, -4), (212, 3), (212, 8), 
    (211, 13), (210, 21), (206, 31), (205, 34), (208, 38), 
    (210, 44), (209, 53), (208, 54), (204, 54), (195, 49), 
    (194, 46), (187, 50), (180, 51), (171, 51), (168, 57), 
    (164, 61), (162, 69), (159, 76), (153, 80), (145, 81), 
    (141, 79), (135, 75), (131, 67), (125, 58), (122, 50), 
    (121, 43), (122, 29), (114, 30), (110, 33), (109, 45), 
    (108, 53), (106, 62), (102, 67), (96, 74), (99, 80), 
    (100, 89), (99, 98), (96, 106), (92, 112), (85, 115), 
    (79, 115), (74, 113), (70, 109), (66, 106), (61, 118), 
    (55, 131), (49, 141), (43, 151), (35, 160), (26, 169), 
    (12, 176), (-1, 182), (-12, 184), (-27, 183), (-39, 182), 
    (-48, 181), (-37, 186), (-26, 190), (-17, 193), (-7, 194), 
    (1, 196), (8, 198), (-12, 198), (-23, 197), (-30, 195), 
    (-37, 194), (-43, 191), (-43, 200), (-44, 205), (-37, 211), 
    (-30, 216), (-20, 223), (-30, 219), (-39, 215), (-44, 212), 
    (-43, 225), (-43, 239), (-43, 248), 
    ]
plotPoly(points, True, pencolor=(0.15, 0.22, 0.3),
         fillcolor=(0.19, 0.4, 0.58), width=2)

# 肚子
points = [
    (-123, -174), (-127, -186), (-129, -201), (-131, -219), (-131, -247), 
    (-130, -261), (-128, -282), (-125, -298), (-123, -306), (-20, -309), 
    (-22, -298), (-27, -288), (-36, -266), (-47, -262), (-58, -256), 
    (-68, -246), (-78, -237), (-89, -224), (-100, -209), (-110, -192), 
    (-116, -182), 
    ]
plotPoly(points, True, pencolor=(0.0, 0.09, 0.28),
         fillcolor=(0.65, 0.71, 0.77), width=2)

# 肚子
points = [
    (-62, -119), (-57, -116), (-51, -116), (-46, -117), (-46, -126), 
    (-47, -132), (-48, -139), (-51, -143), (-54, -136), (-59, -128), 
    ]
plotPoly(points, True, pencolor=(0.0, 0.08, 0.25),
         fillcolor=(0.65, 0.71, 0.77), width=2)

# 汤姆手臂
points = [
    (-133, -23), (-124, -25), (-114, -31), (-110, -35), (-104, -41), 
    (-99, -47), (-93, -57), (-89, -64), (-85, -72), (-78, -86), 
    (-71, -101), (-63, -120), (-56, -133), (-50, -148), (-44, -159), 
    (-38, -170), (-32, -177), (-29, -181), (-33, -176), (-29, -173), 
    (-20, -164), (-9, -156), (-1, -151), (11, -144), (22, -136), 
    (32, -128), (40, -121), (48, -111), (61, -100), (68, -90), 
    (73, -83), (72, -91), (72, -98), (75, -102), (79, -104), 
    (76, -110), (75, -117), (78, -122), (84, -125), (83, -128), 
    (82, -132), (82, -138), (85, -141), (88, -144), (91, -145), 
    (87, -149), (82, -156), (72, -171), (62, -184), (56, -194), 
    (48, -205), (40, -217), (35, -224), 
    ]
plotLine(points, pencolor=(0.0, 0.14, 0.27), width=2)

# 身体线条
points = [
    (-161, -126), (-152, -132), (-146, -138), (-140, -144), (-135, -152), 
    (-130, -160), (-126, -167), (-122, -173), 
    ]
plotLine(points, pencolor=(0.0, 0.1, 0.31), width=2)

# 身体线条
points = [
    (-150, -151), (-136, -151), 
    ]
plotLine(points, pencolor=(0.0, 0.11, 0.31), width=2)

# 汤姆与杰瑞之间的空白处
points = [
    (-35, -77), (-13, -94), (4, -108), (17, -119), (31, -129), 
    (43, -117), (53, -107), (61, -97), (59, -93), (57, -85), 
    (56, -80), (56, -75), (52, -74), (49, -73), (48, -71), 
    (47, -68), (47, -64), (49, -62), (52, -59), (54, -59), 
    (57, -57), (61, -56), (65, -57), (68, -58), (69, -61), 
    (71, -63), (72, -62), (74, -58), (75, -54), (77, -47), 
    (81, -40), (85, -32), (92, -29), (99, -27), (105, -22), 
    (111, -18), (121, -18), (125, -19), (129, -15), (133, -12), 
    (142, -11), (143, -8), (139, -9), (135, -7), (128, -1), 
    (124, 1), (118, 4), (112, 2), (107, -3), (103, -7), 
    (97, -13), (91, -19), (84, -26), (78, -33), (70, -41), 
    (62, -46), (54, -50), (44, -55), (32, -58), (19, -60), 
    (9, -62), (-3, -64), (-9, -65), (-15, -67), (-21, -70), 
    (-28, -73), 
    ]
plotPoly(points, True, pencolor=(0.0, 0.07, 0.19),
         fillcolor=(0.96, 0.96, 1.0), width=2)

# 汤姆耳朵
points = [
    (-257, 97), (-247, 100), (-234, 103), (-223, 106), (-208, 106), 
    (-190, 106), (-179, 104), (-164, 99), (-154, 95), (-144, 88), 
    (-139, 82), (-135, 74), (-132, 64), (-133, 57), (-135, 52), 
    (-139, 47), (-142, 45), (-150, 44), (-155, 51), (-161, 59), 
    (-157, 48), (-154, 43), (-150, 39), (-148, 38), (-144, 38), 
    (-146, 35), (-148, 32), (-152, 27), (-155, 18), (-150, 23), 
    (-146, 26), (-142, 29), (-137, 29), (-133, 26), (-131, 22), 
    (-128, 17), (-127, 11), (-127, 4), (-128, -2), (-129, -8), 
    (-131, -17), (-144, -17), (-154, -14), (-163, -9), (-174, -2), 
    (-183, 5), (-191, 13), (-198, 21), (-206, 31), (-212, 40), 
    (-218, 48), (-223, 56), (-228, 62), (-233, 71), (-238, 78), 
    (-242, 84), (-248, 89), (-252, 93), (-257, 97), (-247, 100), 
    (-238, 103), 
    ]
plotPoly(points, True, pencolor=(0.12, 0.11, 0.27),
         fillcolor=(0.73, 0.4, 0.62), width=2)

# 嘴鼻部分
points = [
    (-1, 35), (10, 30), (16, 25), (19, 20), (24, 10), 
    (24, 3), (22, -4), (19, -11), (16, -16), (10, -20), 
    (1, -23), (-8, -25), (-16, -27), (-18, -29), (-13, -33), 
    (-7, -41), (4, -48), (12, -52), (24, -56), (33, -57), 
    (44, -54), (59, -49), (70, -41), (79, -33), (87, -25), 
    (94, -17), (99, -10), (105, -4), (111, 1), (115, 4), 
    (122, 4), (127, 0), (132, -5), (136, -7), (139, -9), 
    (143, -7), (144, -4), (144, 2), (144, 8), (144, 12), 
    (146, 15), (148, 20), (150, 23), (152, 28), (151, 32), 
    (149, 35), (146, 35), (143, 34), (137, 32), (131, 30), 
    (128, 29), (122, 28), (117, 29), (110, 32), (110, 43), 
    (109, 50), (107, 57), (105, 62), (101, 69), (96, 74), 
    (91, 77), (85, 78), (79, 78), (74, 77), (69, 74), 
    (64, 72), (58, 69), (54, 67), (50, 63), (47, 59), 
    (43, 53), (39, 46), (37, 38), (34, 34), (28, 34), 
    (20, 34), (10, 35), 
    ]
plotPoly(points, True, pencolor=(0.42, 0.56, 0.68),
         fillcolor=(0.92, 0.92, 0.99), width=2)


# 鼻子
points = [
    (59, 49), (71, 49), (81, 48), (91, 46), (93, 47), 
    (93, 52), (93, 61), (93, 67), (91, 70), (88, 73), 
    (85, 75), (79, 75), (76, 74), (71, 72), (67, 70), 
    (64, 66), (62, 62), (60, 58), 
    ]
plotPoly(points, True, pencolor=(0.14, 0.16, 0.25),
         fillcolor=(0.0, 0.03, 0.21), width=2)

turtle.up()
turtle.goto((77, 65))
turtle.down()
turtle.pencolor((0.9, 0.9, 1))
turtle.dot(13)

# 胡子
points = [
    (-87, -16), (-73, -7), (-58, 1), (-39, 11), (-17, 19), 
    (3, 24), (24, 28), (43, 31), 
    ]
plotLine(points, pencolor=(0.13, 0.15, 0.18), width=2)

points = [
    (-50, -67), (-41, -55), (-28, -40), (-15, -25), (-1, -13), 
    (14, -1), (29, 9), (48, 19), 
    ]
plotLine(points, pencolor=(0.09, 0.11, 0.13), width=2)

points = [
    (200, 85), (181, 85), (161, 83), (143, 81), (128, 77), 
    (114, 73), (104, 68), 
    ]
plotLine(points, pencolor=(0.03, 0.03, 0.07), width=2)

points = [
    (182, 151), (155, 137), (139, 126), (122, 114), (109, 99), 
    (99, 90), (90, 79), 
    ]
plotLine(points, pencolor=(0.0, 0.05, 0.22), width=2)

# 眼睛和脸部线条
points = [
    (-11, 46), (-8, 46), (-6, 49), (-3, 52), (1, 54), 
    (6, 57), (9, 58), (13, 59), (18, 59), (22, 59), 
    (27, 59), (30, 58), (32, 58), (32, 59), (30, 61), 
    (27, 62), (24, 63), (19, 63), (16, 63), (8, 62), 
    (6, 61), (3, 60), (-2, 57), (-4, 56), (-7, 54), 
    (-9, 52), (-12, 50), (-12, 48), 
    ]
plotPoly(points, True, pencolor=(0.0, 0.05, 0.25),
         fillcolor=(0.0, 0.05, 0.25), width=2)

points = [
    (55, 69), (56, 69), (57, 70), (58, 72), (59, 75), 
    (60, 78), (61, 81), (63, 84), (65, 87), (67, 89), 
    (70, 89), (70, 91), (69, 92), (66, 92), (64, 90), 
    (62, 89), (60, 85), (58, 81), (57, 77), (56, 74), 
    (55, 71), 
    ]
plotPoly(points, True, pencolor=(0.0, 0.1, 0.3),
         fillcolor=(0.0, 0.1, 0.3), width=2)



points = [
    (32, 23), (34, 33), (37, 42), (42, 51), (45, 57), 
    (50, 64), (56, 68), 
    ]
plotLine(points, pencolor=(0.33, 0.4, 0.47), width=2)

points = [
    (-27, 34), (-14, 36), (-3, 35), (7, 31), (15, 25), 
    (21, 19), (24, 10), (24, 2), (22, -6), (18, -12), 
    (11, -18), (0, -22), (-10, -24), (-20, -23), (-33, -20), 
    ]
plotLine(points, pencolor=(0.07, 0.25, 0.45), width=2)

points = [
    (66, 103), (69, 92), (71, 81), (72, 76), 
    ]
plotLine(points, pencolor=(0.15, 0.27, 0.48), width=2)

# 双眼之间
points = [
    (38, 42), (32, 60), (20, 85), (11, 104), (-1, 121), 
    (-10, 131), (-10, 137), (-8, 140), (-5, 140), (-3, 139), 
    (-4, 145), (-4, 149), (-3, 154), (1, 155), (5, 155), 
    (10, 153), (12, 148), (13, 152), (16, 155), (19, 155), 
    (22, 153), (25, 149), (26, 144), (28, 137), (31, 129), 
    (34, 120), (39, 108), (42, 99), (45, 90), (51, 79), 
    (56, 68), (53, 65), (48, 61), (43, 55), (40, 47), 
    ]
plotPoly(points, True, pencolor=(0.51, 0.55, 0.63),
         fillcolor=(0.64, 0.69, 0.82), width=2)

# 眉毛
points = [
    (-18, 74), (-22, 85), (-26, 96), (-29, 108), (-30, 115), 
    (-30, 124), (-30, 130), (-29, 132), (-27, 135), (-23, 136), 
    (-19, 135), (-16, 134), (-10, 131), (-13, 134), (-17, 136), 
    (-21, 138), (-23, 139), (-28, 139), (-31, 138), (-32, 136), 
    (-33, 133), (-34, 129), (-34, 126), (-34, 119), (-33, 110), 
    (-31, 100), (-27, 90), (-22, 80), 
    ]
plotPoly(points, True, pencolor=(0.06, 0.25, 0.45),
         fillcolor=(0.02, 0.2, 0.4), width=2)

points = [
    (40, 153), (34, 158), (28, 162), (26, 164), (24, 164), 
    (23, 161), (23, 157), (23, 152), (23, 160), (24, 163), 
    ]
plotLine(points, pencolor=(0.02, 0.18, 0.35), width=2)

points = [
    (-55, 104), (-56, 111), (-57, 119), (-57, 127), (-57, 138), 
    (-57, 141), (-56, 147), (-55, 151), (-53, 154), (-50, 157), 
    (-47, 158), (-43, 158), (-38, 158), (-35, 157), (-39, 160), 
    (-43, 163), (-46, 164), (-52, 163), (-55, 161), (-57, 159), 
    (-59, 156), (-60, 151), (-62, 146), (-62, 139), (-62, 130), 
    (-61, 123), (-59, 116), 
    ]
plotPoly(points, True, pencolor=(0.0, 0.12, 0.26),
         fillcolor=(0.0, 0.03, 0.25), width=2)

points = [
    (2, 166), (2, 170), (2, 175), (4, 177), (6, 178), 
    (10, 177), (7, 177), (10, 176), (7, 176), (5, 175), 
    (4, 173), (3, 172), 
    ]
plotLine(points, pencolor=(0.0, 0.07, 0.24), width=2)

# 发型
points = [
    (-44, 205), (-48, 201), (-53, 197), (-59, 191), (-63, 187), 
    (-69, 181), (-75, 175), (-84, 164), (-72, 173), (-64, 180), 
    (-55, 185), (-45, 190), 
    ]
plotLine(points, pencolor=(0.03, 0.19, 0.31), width=2)

points = [
    (-44, 210), (-49, 207), (-55, 203), (-61, 198), (-66, 193), 
    (-70, 189), (-75, 183), (-79, 179), 
    ]
plotLine(points, pencolor=(0.09, 0.2, 0.31), width=2)

points = [
    (-69, 162), (-66, 166), (-63, 170), (-59, 173), (-56, 176), 
    (-52, 178), (-46, 181), (-42, 183), (-36, 186), 
    ]
plotLine(points, pencolor=(0.02, 0.15, 0.28), width=2)

# 汤姆尾巴
points = [
    (-266, -294), (-272, -281), (-278, -269), (-285, -258), (-289, -251), 
    (-294, -244), (-298, -240), (-303, -235), (-303, -303), (-262, -301), 
    ]
plotPoly(points, True, pencolor=(0.2, 0.2, 0.2),
         fillcolor=(0.2, 0.39, 0.61), width=2)

# 杰瑞小脚
points = [
    (67, -58), (64, -56), (59, -56), (57, -57), (56, -59), 
    (51, -60), (49, -62), (48, -64), (47, -67), (48, -70), 
    (49, -73), (51, -74), (53, -75), (55, -75), (56, -79), 
    (57, -82), (58, -86), (58, -89), (59, -92), (60, -95), 
    (61, -97), (64, -94), (67, -91), (69, -89), (71, -86), 
    (71, -81), (71, -78), (71, -71), (72, -67), (71, -64), 
    (70, -61), (69, -60), (68, -59), 
    ]
plotPoly(points, True, pencolor=(0.2, 0.15, 0.13),
         fillcolor=(0.68, 0.4, 0.32), width=2)

points = [
    (56, -75), (58, -73), (62, -71), (65, -71), (67, -74), 
    (68, -78), (68, -81), (69, -85), (69, -87), (68, -88), 
    (67, -90), (65, -92), (64, -93), (63, -94), (61, -95), 
    (60, -94), (60, -92), (59, -90), (59, -87), (58, -84), 
    (57, -81), (56, -78), 
    ]
plotPoly(points, True, pencolor=(0.47, 0.32, 0.29),
         fillcolor=(0.93, 0.69, 0.62), width=2)

points = [
    (57, -72), (55, -70), (55, -67), (54, -64), (54, -62), 
    (54, -61), (54, -61), 
    ]
plotLine(points, pencolor=(0.34, 0.17, 0.13), width=2)

# 杰瑞轮廓
points = [
    (111, -49), (109, -53), (113, -56), (119, -59), (124, -62), 
    (129, -63), (136, -63), (155, -63), (159, -61), (161, -57), 
    (164, -51), (168, -46), (170, -43), (176, -44), (179, -46), 
    (180, -51), (182, -54), (184, -56), (187, -56), (189, -54), 
    (192, -51), (194, -48), (195, -45), (196, -42), (196, -38), 
    (196, -36), (200, -36), (204, -36), (207, -34), (210, -32), 
    (212, -29), (212, -23), (212, -20), (211, -18), (209, -17), 
    (204, -16), (206, -14), (208, -11), (210, -6), (211, -2), 
    (212, 4), (212, 7), (214, 8), (214, 10), (212, 11), 
    (212, 14), (211, 18), (210, 22), (209, 26), (207, 30), 
    (205, 32), (206, 35), (207, 38), (209, 42), (210, 45), 
    (210, 51), (208, 53), (207, 54), (204, 54), (203, 53), 
    (201, 52), (198, 50), (196, 48), (195, 47), (194, 46), 
    (191, 47), (188, 49), (184, 50), (181, 51), (178, 51), 
    (174, 51), (170, 50), (168, 51), (167, 55), (165, 59), 
    (164, 64), (163, 69), (160, 74), (158, 77), (155, 80), 
    (153, 80), (150, 80), (147, 80), (143, 79), (140, 78), 
    (136, 75), (133, 71), (130, 67), (127, 62), (125, 57), 
    (124, 53), (123, 49), (121, 44), (121, 40), (121, 35), 
    (121, 31), (121, 29), (130, 28), (134, 30), (138, 32), 
    (142, 34), (145, 35), (148, 35), (150, 32), (152, 29), 
    (151, 26), (148, 21), (145, 16), (144, 12), (144, -6), 
    (143, -11), (140, -12), (132, -12), (128, -15), (124, -20), 
    (121, -26), (119, -30), (116, -36), (114, -42), 
    ]
plotPoly(points, True, pencolor=(0.42, 0.3, 0.31),
         fillcolor=(0.68, 0.38, 0.29), width=2)

# 杰瑞身体线条
points = [
    (136, -29), (132, -32), (128, -38), (124, -45), (121, -49), 
    (118, -54), (117, -57), 
    ]
plotLine(points, pencolor=(0.39, 0.2, 0.16), width=2)

# 杰瑞肚子
points = [
    (126, -56), (123, -60), (129, -62), (133, -63), (156, -62), 
    (159, -61), (161, -57), (163, -54), (164, -51), (165, -48), 
    (165, -45), (162, -42), (160, -42), (158, -42), (156, -43), 
    (154, -44), (152, -44), (151, -42), (150, -38), (147, -37), 
    (145, -36), (141, -36), (138, -39), (135, -43), (132, -46), 
    (130, -49), (128, -53), 
    ]
plotPoly(points, True, pencolor=(0.8, 0.55, 0.49),
         fillcolor=(0.93, 0.69, 0.6), width=2)

# 杰瑞嘴巴周围
points = [
    (160, 3), (155, -1), (150, -6), (147, -10), (145, -12), 
    (144, -16), (141, -19), (139, -22), (138, -24), (138, -29), 
    (140, -32), (142, -34), (144, -34), (148, -35), (155, -36), 
    (162, -38), (168, -40), (173, -43), (177, -45), (191, -30), 
    (193, -28), (194, -26), (197, -26), (201, -26), (205, -23), 
    (205, -20), (205, -17), (204, -14), (202, -13), (200, -11), 
    (198, -10), (194, -10), (191, -10), (190, -6), (190, -2), 
    (189, 1), (185, 1), (180, 1), (178, 1), (174, -1), 
    (173, -2), (166, -2), (163, 1), 
    ]
plotPoly(points, True, pencolor=(0.55, 0.29, 0.22),
         fillcolor=(0.92, 0.65, 0.62), width=2)

# 杰瑞另一只小脚
points = [
    (98, -157), (96, -159), (96, -161), (96, -163), (97, -166), 
    (97, -168), (96, -169), (96, -170), (97, -172), (99, -174), 
    (100, -175), (105, -175), (108, -174), (110, -172), (113, -169), 
    (116, -166), (118, -163), (120, -161), (122, -158), (122, -156), 
    (118, -156), (112, -155), (109, -155), (106, -154), (103, -153), 
    (101, -153), (99, -156), 
    ]
plotPoly(points, True, pencolor=(0.24, 0.2, 0.3),
         fillcolor=(0.63, 0.42, 0.37), width=2)

points = [
    (107, -164), (105, -166), (104, -167), (102, -168), (99, -168), 
    (98, -167), (97, -166), (96, -165), 
    ]
plotLine(points, pencolor=(0.33, 0.26, 0.35), width=2)

points = [
    (175, -8), (170, -8), (165, -10), (161, -12), (157, -14), 
    (153, -16), (150, -17), (148, -19), (146, -20), (144, -22), 
    (143, -24), (143, -27), (144, -29), (147, -31), (150, -32), 
    (153, -32), (156, -32), (158, -33), (161, -33), (164, -34), 
    (187, -29), (189, -27), (191, -26), (192, -25), (188, -22), 
    (186, -18), (184, -16), (182, -14), (179, -12), (177, -10), 
    ]
plotPoly(points, True, pencolor=(0.33, 0.07, 0.12),
         fillcolor=(0.29, 0.01, 0.18), width=2)

points = [
    (169, -28), (166, -30), (165, -32), (165, -34), (169, -35), 
    (172, -37), (175, -38), (178, -40), (179, -43), (179, -45), 
    (180, -49), (181, -51), (182, -54), (184, -56), (187, -56), 
    (189, -54), (190, -53), (192, -50), (194, -48), (195, -45), 
    (196, -42), (196, -39), (196, -36), (195, -34), (192, -32), 
    (189, -30), (187, -28), (185, -26), (184, -24), (182, -24), 
    (179, -23), (177, -23), (174, -24), (172, -26), (170, -27), 
    ]
plotPoly(points, True, pencolor=(0.46, 0.09, 0.2),
         fillcolor=(0.69, 0.2, 0.22), width=2)

points = [
    (167, -35), (172, -37), (175, -38), (177, -40), (178, -44), 
    (179, -46), (180, -48), (181, -52), (182, -54), (184, -56), 
    (186, -56), (187, -56), (188, -55), (190, -52), (192, -50), 
    (194, -47), (195, -45), (196, -42), (196, -39), (196, -37), 
    (196, -36), (195, -35), (193, -33), (191, -32), (190, -31), 
    ]
plotLine(points, pencolor=(0.73, 0.29, 0.33), width=2)

points = [
    (192, -10), (195, -10), (199, -9), (200, -8), (201, -4), 
    (200, -2), (197, -1), (196, 0), (194, 0), (191, 0), 
    (190, -1), (190, -2), (191, -4), (192, -8), 
    ]
plotPoly(points, True, pencolor=(0.23, 0.09, 0.09),
         fillcolor=(0.08, 0.04, 0.03), width=2)

points = [
    (185, 15), (187, 12), (188, 10), (189, 7), (189, 4), 
    ]
plotLine(points, pencolor=(0.33, 0.13, 0.09), width=2)

points = [
    (199, -4), (201, -4), (203, -5), 
    ]
plotLine(points, pencolor=(0.28, 0.1, 0.07), width=2)

points = [
    (152, 18), (159, 15), (167, 11), (173, 7), (179, 3), 
    ]
plotLine(points, pencolor=(0.32, 0.08, 0.05), width=2)

points = [
    (157, 25), (165, 20), (171, 14), (176, 11), (180, 5), 
    ]
plotLine(points, pencolor=(0.35, 0.15, 0.09), width=2)

points = [
    (222, -20), (214, -17), (210, -16), (205, -15), (203, -15), 
    ]
plotLine(points, pencolor=(0.45, 0.26, 0.2), width=2)

points = [
    (194, 54), (187, 53), (182, 53), (178, 53), (173, 51), 
    (176, 51), (180, 52), (174, 51), 
    ]
plotLine(points, pencolor=(0.46, 0.33, 0.32), width=2)

points = [
    (196, 50), (190, 50), (185, 50), 
    ]
plotLine(points, pencolor=(0.51, 0.33, 0.29), width=2)

points = [
    (191, 46), (195, 45), (197, 42), (200, 40), (203, 36), 
    (205, 33), (207, 29), (209, 25), 
    ]
plotLine(points, pencolor=(0.31, 0.2, 0.16), width=2)

points = [
    (152, 30), (149, 34), (147, 36), (143, 34), (140, 33), 
    (136, 32), 
    ]
plotLine(points, pencolor=(0.63, 0.45, 0.46), width=2)

points = [
    (136, 32), (133, 30), (130, 29), (121, 29), (120, 33), 
    ]
plotLine(points, pencolor=(0.79, 0.69, 0.71), width=2)

points = [
    (121, 36), (121, 42), (122, 47), (124, 54), (127, 58), 
    (130, 65), (133, 71), (137, 75), (141, 77), (146, 79), 
    (151, 77), (155, 74), (157, 70), (158, 67), (159, 62), 
    (159, 58), (159, 53), (159, 48), (158, 43), (157, 38), 
    (155, 34), (153, 30), (151, 30), (150, 33), (148, 35), 
    (144, 35), (142, 34), (139, 32), (137, 31), (134, 30), 
    (130, 29), (124, 28), (121, 29), (121, 33), 
    ]
plotPoly(points, True, pencolor=(0.47, 0.34, 0.34),
         fillcolor=(0.91, 0.56, 0.56), width=2)

# 汤姆手
points = [
    (199, 1), (203, 5), (209, 8), (213, 10), 
    ]
plotLine(points, pencolor=(0.42, 0.31, 0.32), width=2)

points = [
    (190, 7), (190, 13), (190, 18), (189, 23), (188, 27), 
    ]
plotLine(points, pencolor=(0.62, 0.32, 0.22), width=2)

points = [
    (162, 23), (171, 23), (175, 21), (179, 18), (181, 13), 
    ]
plotLine(points, pencolor=(0.5, 0.22, 0.14), width=2)

points = [
    (117, -32), (110, -30), (102, -27), (95, -27), (88, -29), 
    (83, -34), (80, -40), (77, -46), (75, -55), (73, -61), 
    (72, -68), (70, -76), (71, -81), (72, -83), (72, -88), 
    (71, -92), (72, -98), (75, -102), (77, -103), (79, -104), 
    (78, -106), (77, -109), (75, -114), (75, -119), (78, -122), 
    (82, -124), (85, -125), (83, -127), (82, -130), (81, -134), 
    (81, -138), (84, -141), (87, -143), (91, -145), (89, -146), 
    (92, -148), (97, -151), (105, -154), (111, -154), (120, -155), 
    (126, -155), (131, -157), (135, -161), (139, -163), (144, -164), 
    (155, -164), (162, -161), (167, -158), (171, -152), (173, -148), 
    (174, -145), (175, -141), (180, -139), (186, -137), (191, -134), 
    (196, -128), (201, -121), (204, -116), (206, -111), (208, -105), 
    (209, -100), (210, -95), (211, -90), (211, -84), (210, -81), 
    (209, -78), (212, -75), (214, -71), (216, -68), (218, -61), 
    (219, -57), (220, -53), (220, -47), (220, -40), (219, -34), 
    (217, -30), (214, -26), (212, -26), (211, -30), (210, -32), 
    (208, -34), (206, -35), (204, -36), (200, -36), (197, -37), 
    (196, -40), (196, -43), (194, -47), (193, -49), (191, -52), 
    (188, -55), (187, -56), (184, -56), (182, -54), (181, -50), 
    (180, -48), (178, -46), (176, -44), (172, -42), (170, -43), 
    (168, -45), (165, -49), (163, -54), (161, -58), (159, -62), 
    (156, -63), (148, -63), (134, -63), (128, -62), (121, -60), 
    (116, -57), (111, -55), (109, -53), (112, -48), (114, -44), 
    (115, -40), (117, -37), 
    ]
plotPoly(points, True, pencolor=(0.2, 0.2, 0.2),
         fillcolor=(0.93, 0.93, 0.97), width=2)

points = [
    (100, -27), (103, -24), (106, -21), (110, -19), (114, -18), 
    (118, -18), (122, -19), (124, -20), (123, -23), (121, -26), 
    (120, -29), (119, -31), (117, -33), (114, -32), (111, -30), 
    (106, -29), (104, -28), 
    ]
plotPoly(points, True, pencolor=(0.2, 0.2, 0.2),
         fillcolor=(0.92, 0.95, 0.97), width=2)

# 汤姆手指
points = [
    (159, -61), (159, -69), (160, -73), (161, -78), (164, -82), 
    (167, -84), (170, -87), (174, -89), (179, -90), (184, -90), 
    (190, -90), (195, -89), (200, -87), (205, -83), (208, -80), 
    (210, -77), 
    ]
plotLine(points, pencolor=(0.2, 0.2, 0.2), width=2)

points = [
    (165, -83), (161, -86), (158, -89), (154, -92), (152, -95), 
    (150, -99), (148, -104), (147, -108), (147, -114), (147, -120), 
    (148, -124), (150, -129), (153, -133), (157, -136), (162, -139), 
    (166, -140), (171, -141), (175, -141), 
    ]
plotLine(points, pencolor=(0.2, 0.2, 0.2), width=2)

points = [
    (149, -99), (145, -99), (140, -99), (136, -101), (132, -103), 
    (128, -106), (125, -110), (123, -114), (121, -119), (120, -124), 
    (120, -131), (120, -137), (121, -141), (123, -147), (125, -151), 
    (127, -154), (129, -156), (131, -158), 
    ]
plotLine(points, pencolor=(0.2, 0.2, 0.2), width=2)


# 隐藏海龟
turtle.hideturtle()
turtle.done()

运行效果

在这里插入图片描述

备注

视频已发布到抖音和 b 站。抖音和b站名称:会代码的依古比古

抖音视频网址:用代码画出这对可爱的搭档

b站视频网址:用代码画出这对可爱的搭档_哔哩哔哩_bilibili

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值