Listing 8

// surf is a surface
rectangle anchor_rect = ...;
// returns immediately
surf.create_full_rect_anchor(anchor_name, anchor_rect);
point anchor_start = ...;
rectangle anchor_rect = ...;
// returns only after the anchored surface has finished drawing
surf.create_start_point_anchor(
  anchor_name, anchor_start, anchor_rect);
// anchor_rect contains the rectangle the surface has drawn in