def METHOD_NAME(rec):
    for item in rec['read_segments']:
        item.update({'type': 'r'})
    for item in rec['write_segments']:
        item.update({'type': '2'})
    trace = rec['read_segments'] + rec['write_segments']
    minsize = calc_minsize(trace)
    start, end, duration = calc_duration(trace)
    count = len(trace)
    factor = 720
    if duration == 0:
        duration = 1
    # image properties
    width = sanitize_size( duration * factor )
    #height = int(math.log(minsize))
    height = sanitize_size( math.log(minsize)*math.log(minsize) )
    #print(width, height)
    #img = Image.new('RGB', (width, height), color = (0, 0, 0))
    #img = Image.new('RGBA', (width, height), color = (0, 0, 0, 0))
    img = Image.new('RGBA', (width, height), color = (33, 33, 33, 255))
    # sort?
    trace = sorted(trace, key=itemgetter('start_time'))
    draw = ImageDraw.Draw(img)
    for i, event in enumerate(trace):
        typ = event['type']
        off = event['offset']
        lee = event['length']
        sta = event['start_time'] - start
        end = event['end_time'] - start
        xx = sta/duration * width;
        yy = height * (off / minsize)
        wi = sanitize_size( (end-sta)*factor );
        he = sanitize_size( height * (lee / minsize) )
        fill = None
        #fill = (0,0,0,0)
        if typ == 'r':
            fill = (222, 66, 111, 200)
            #fill = (222, 66, 111)
        elif typ == 'w':
            fill = (66, 222, 222, 200)
            #fill = (66, 222, 222)
        #print([xx, yy, xx+wi, yy+he-1])
        # draw.rectangle(xy, fill=None, outline=None)
        # where yx either [(x0, y0), (x1, y1)] or [x0, y0, x1, y1]
        draw.rectangle([xx, yy, xx+wi-1, yy+he-1], fill=fill, outline=None)
    del draw
    return img