""" draw_line(canvas, p1, p2) Draw a white line segment between points p1 and p2 in canvas. Canvas is an image of RGB{Float32} p1 and p2 are 2-tuples of Int The slope of the line is between 0 and 1. """ function draw_line(canvas, p1, p2) white = RGB{Float32}(1.0, 1.0, 1.0) # TODO 1 and 2 end # draw_line (no color) """ draw_line(canvas, p1, p2, v1, v2) Draw a line segment between points p1 and p2 in canvas, interpolating its color between v1 and v2. Canvas is an image of RGB{Float32} p1 and p2 are 2-tuples of Int v1 and v2 are colors of type RGB{Float32} The slope of the line is between 0 and 1. """ function draw_line(canvas, p1, p2, v1, v2) # TODO 3 end # draw_line (with color) function task1test() canvas = zeros(RGB{Float32}, 600, 600) p1 = (4,10) for theta = 0:1:45 x = round(10 + 500*cosd(theta)) y = round(10 + 500*sind(theta)) draw_line(canvas, (10, 10), (x, y)); end canvas = transpose(canvas[:, end:-1:1]) save("t1out.png", canvas) canvas end # task1test function task3test() canvas = zeros(RGB{Float32}, 600, 600) for y2 = 10:10:510 v = y2/510 start_color = RGB{Float32}(0.2, 1.0-v, y2/510) end_color = RGB{Float32}(0.2, y2/510, 1.0-v) draw_line(canvas, (10, 10), (510, y2), start_color, end_color) end canvas = transpose(canvas[:, end:-1:1]) save("t3out.png", canvas) canvas end # task3test