Drawing


For this problem, you will draw a single line in the function draw(). The parameters are:

Write code to draw 1 line, with one endpoint at the lower-right corner of the drawable area, and the other endpoint given proportionately by x_pct, y_pct. Reminder: Use canvas.draw_line(x1, y1, x2, y2) to draw the line.

Canvas with blank top and bottom margins. A line connects a point within the drawable area to its lower-right corner.
def draw(canvas, width, height, margin_top, margin_bot,
         x_pct, y_pct):
    
View solution
def draw(canvas, width, height, margin_top, margin_bot,
         x_pct, y_pct):
    canvas.draw_line(
        width - 1,
        height - margin_bot - 1,
        (x_pct / 100) * (width - 1),
        (y_pct / 100) * (height - margin_top - margin_bot - 1) + margin_top
    )