def draw(canvas): """ Draw (with draw_line()) range of colors in #rgb and #rrggbb formats. :param canvas: simpleguics2pygame.Canvas or simplegui.Canvas """ for i in range(16): # Format #rgb canvas.draw_line((i * 32, 10), ((i + 1) * 32, 10), 10, '#' + hex_fig(i) * 3) canvas.draw_line((i * 32, 30), ((i + 1) * 32, 30), 10, '#' + hex_fig(i) + '00') canvas.draw_line((i * 32, 50), ((i + 1) * 32, 50), 10, '#0' + hex_fig(i) + '0') canvas.draw_line((i * 32, 70), ((i + 1) * 32, 70), 10, '#00' + hex_fig(i)) for i in range(256): # Format #rrggbb canvas.draw_line((i * 2, 110), ((i + 1) * 2, 110), 10, '#' + hex2(i) * 3) canvas.draw_line((i * 2, 130), ((i + 1) * 2, 130), 10, '#' + hex2(i) + '0000') canvas.draw_line((i * 2, 150), ((i + 1) * 2, 150), 10, '#00' + hex2(i) + '00') canvas.draw_line((i * 2, 170), ((i + 1) * 2, 170), 10, '#0000' + hex2(i))
def draw(canvas): """ Draw (with draw_line()) range of colors in #rgb and #rrggbb formats. :param canvas: simpleguics2pygame.Canvas or simplegui.Canvas """ for i in range(16): # Format #rgb canvas.draw_line((i*32, 10), ((i + 1)*32, 10), 10, '#' + hex_fig(i)*3) canvas.draw_line((i*32, 30), ((i + 1)*32, 30), 10, '#' + hex_fig(i) + '00') canvas.draw_line((i*32, 50), ((i + 1)*32, 50), 10, '#0' + hex_fig(i) + '0') canvas.draw_line((i*32, 70), ((i + 1)*32, 70), 10, '#00' + hex_fig(i)) for i in range(256): # Format #rrggbb canvas.draw_line((i*2, 110), ((i + 1)*2, 110), 10, '#' + hex2(i)*3) canvas.draw_line((i*2, 130), ((i + 1)*2, 130), 10, '#' + hex2(i) + '0000') canvas.draw_line((i*2, 150), ((i + 1)*2, 150), 10, '#00' + hex2(i) + '00') canvas.draw_line((i*2, 170), ((i + 1)*2, 170), 10, '#0000' + hex2(i))
def init(): """ Set a grid of point information : [z, C, numbers of iterations, None or color number] """ global colors global grid global nb_iter print('Init.') assert nb_iter_max < 256, nb_iter_max colors = tuple(['#%s%s%s' % (hex2(255 - 256*int(math.log10(i)//nb_iter_max)), hex2(255 - 256*i//nb_iter_max), hex2(255 - 256*i//nb_iter_max)) for i in range(1, nb_iter_max)]) nb_iter = 0 coef_c_real = (z1_real - z0_real)/(CANVAS_WIDTH - 1) coef_c_imag = (z0_imag - z1_imag)/(CANVAS_HEIGHT - 1) grid = [] for y in range(CANVAS_HEIGHT//2 + 1): c_imag = z0_imag - coef_c_imag*y line = [] for x in range(CANVAS_WIDTH): c_real = z0_real + coef_c_real*x line.append([(0, 0), # z (c_real, c_imag), # C 0, # number of iterations None]) # color number grid.append(line) print('\nNumber of iterations:')