int horizon = 300; void setup() { size(600,500); } void draw() { background(204); line(0,300,width,300); float diameter; if (mouseY < horizon) { // we want interpolation mapping horizon --> 0 and topEdge --> 100 diameter = map(mouseY, horizon, 0, 0, 100); } else { // we want interpolation mapping horizon --> 0 and bottomEdge --> 100 diameter = map(mouseY, horizon, height, 0, 100); } ellipse(mouseX, mouseY, diameter, diameter); }