Single-loop icecream

Single-loop icecream from PIL import Image, ImageDraw w,h = 600, 700 centerx, centery = w/2, h/2 topy, bottomy = 30, 660 iters = 29 cone_color_idx, ice_color_idx = 0, 0 seq1, seq2 = [(centerx, topy)], [(centerx, topy)] seq3, seq4 = [(centerx, bottomy)], [(centerx, bottomy)] icecream_colors = ['E500E3', 'E40AA5', 'E3146D', 'E21F3C', 'E14029', 'E07933', 'DFAC3D', 'DED947', 'BADD50', '97DC5A', '7BDB64', '6DDA77', '77D99B', '80D8B9', '89D7D1', '92C8D6', '9CB9D5', 'A5B0D4'] cone_colors = ['F8ED88', 'F0E373'] im = Image.new('RGB', (w, h), 'white') draw = ImageDraw.ImageDraw(im) for i in range(iters): # icecream contours seq1.append((seq1[-1][0] - i, seq1[-1][1]) if i&1 else (seq1[-1][0] , seq1[-1][1] + i)) seq2.append((seq2[-1][0] + i, seq2[-1][1]) if i&1 else (seq2[-1][0] , seq2[-1][1] + i)) seq3.append((seq3[-1][0] - i*0.75, seq3[-1][1]) if i&1 else (seq3[-1][0] , seq3[-1][1] - i*2)) seq4.append((seq4[-1][0] + i*0.75, seq4[-1][1]) if i&1 else (seq4[-1][0] , seq4[-1][1] - i*2)) if i != iters - 1: x1, y1 = seq1[-1] x2, y2 = seq2[-1] x3, y3 = seq3[-1] x4, y4 = seq4[-1] y1 += 0.5*i y2 += 0.5*i y3 -= i y4 -= i if i % 2 == 1: # cone coloring draw.line([(x3, y3), (x4, y4)], fill='#' + cone_colors[cone_color_idx], width=2*i) cone_color_idx = 0 if cone_color_idx == 1 else 1 # draw colors between layers (two per layer) if i > 0: draw.line([(x1, y1-1), (x2, y2-1)], fill='#' + icecream_colors[ice_color_idx], width=i) draw.line([(x1, y1+1), (x2, y2+1)], fill='#' + icecream_colors[ice_color_idx+1], width=i) ice_color_idx += 1 # horizontal layer boundaries draw.line([(x1+i, y1), (x2, y2)], fill='#EFEFEF', width=2) draw.line([(x1, y1-0.5*i), (x2-2*i, y2-0.5*i)], fill='#666666', width=2) for seq in [seq1, seq2, seq3, seq4]: draw.line(seq, fill='black', width=3) draw.line([seq1[-1], seq2[-1]], fill='black', width=3) im.show()