In short: The order of operations is important, exchange "scale" and "translate" transformations.
Long explanation:The ellipse has its center at "world" coordinates (0, 0) and has radii (0.25, 0.25).
You want the ellipse to be drawn in the center of an image which is SURFACE_WIDTH pixels wide and SURFACE_HEIGHT pixels high ("image coordinates").
There are two possible ways how to achieve this:
scale2:First multiply all world coordinates by (SURFACE_WIDTH, SURFACE_HEIGHT), --> "scale" transformation. This, however, would leave the ellipse in the left/bottom corner since the origin does not move upon multiplication -> you must add (SURFACE_WIDTH div2 , SURFACE_HEIGHT div 2) to all coordinates to bring the scaled ellipse it into the image center --> "translate"
agg^.scale(SURFACE_WIDTH, SURFACE_HEIGHT);
agg^.translate(SURFACE_WIDTH div 2, SURFACE_HEIGHT div 2);
agg^.ellipse(0, 0, 0.25, 0.25);
scale: Here the "translate" transformation has parameters in "world" space (0.5, 0.5). To get the desired effect you must, however, reverse their order: first translate by (0.5, 0.5) - this moves the ellipse out of the center of the world coordinates to the point (0.5, 0.5). Then scale by (SURFACE_WIDTH, SURFACE_HEIGHT) -- this blows up the world space ranging between (0,0) and (1,1) to image space ranging between (0,0) and (SURFACE_WIDTH, SURFACE_HEIGHT); the multiplication shifts the ellipse center at (0.5, 0.5) in world space to (SURFACE_WIDTH div2, SURFACE_HEIGHT div 2), and the ellipse radii become (SURFACEWIDTH div 4, SURFACE_HEIGHT div 4) pixels.
agg^.translate(0.5, 0.5);
agg^.scale(SURFACE_WIDTH, SURFACE_HEIGHT);
agg^.ellipse(0, 0, 0.25, 0.25);
One thing which was confusing me a bit, was that the setting of the line width had no effect on the image. But then I had the idea: after these transformations all coordinates that you use for drawing are in world space; therefore, you must specify the linewidth in world coordinates, too: The diameter of the ellipse is 0.5 - setting agg^.linewidth(0.05) makes the ellipse border 10% of the diameter:
procedure TAggExample1.Draw(agg: Agg2D_ptr);
begin
agg^.clearAll(0, 0, 0, 0);
agg^.lineCap(CapRound);
agg^.lineColor(0, 0, 255, 255);
agg^.translate(0.5, 0.5);
agg^.scale(SURFACE_WIDTH, SURFACE_HEIGHT);
agg^.lineWidth(0.05); // in world coordinates!
agg^.ellipse(0, 0, 0.25, 0.25);
end;
P.S.
I did my tests with the LCL version of aggpas - you probably are using Graeme's because I did not get your screenshot with the scaled linewidth. So be prepared the my code posted here may lead to different linewidths, too.