Midy is the name of the variable that holds height of the figure, divided by 2. It's the mid point in height (y) value.
How are you displaying the graphic you're creating?
You should draw out on paper, the diagram (large), and note for each color, what the slope should be, for that section:
Magenta pixels are all:
y value > midy
> slope of lineLR
> slope of lineRL
and repeat that for every different colored section. Now you can easily refer to it, when you're coding up your program.