University of Sydney · FACULTY OF COMPUTER SCIENCE

IDEA9103 Chap.4 SVG Coordinates and Drawing Order

- one subject, every graph, every model, every mark
6 Chapters4-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 4 of 10 · IDEA9103

SVG Coordinates and Drawing Order

SVG describes vector shapes through geometry and style attributes. Its origin sits at the top left, x increases to the right and y increases downward. This chapter computes shape extents, compares vector and raster media, and treats paint order as an algorithmic choice. Later elements cover earlier ones where their visible regions overlap.

In this chapter

What this chapter covers

  • 01

    Top left origin

  • 02

    Circle attributes

  • 03

    Rectangle extents

  • 04

    Lines and endpoints

  • 05

    Vector versus raster

  • 06

    SVG paint order

Worked example · free

Check whether a circle fits

Q [4 marks]. The practice mark allocation used here is not part of the University's published assessment scheme. A 320 by 220 SVG contains a circle with centre 280, 70 and radius 48. Determine every edge and diagnose clipping.
The axes begin at the canvas top left; the circle centre moves right with x and downward with y while radius controls size.The axes begin at the canvas top left; the circle centre moves right with x and downward with y while radius controls size.(0,0)x grows righty grows downcx, cy
The axes begin at the canvas top left; the circle centre moves right with x and downward with y while radius controls size.
  • 1Left edge is 232.
  • 1Right edge is 328, eight beyond the canvas.
  • 1Top and bottom edges are 22 and 118.
  • 1Move the centre left or reduce radius to repair the right boundary.
Only the right edge clips because 280 + 48 exceeds the 320 wide canvas by eight units.
Sia tip — Calculate cx minus r, cx plus r, cy minus r and cy plus r before changing the canvas size.
Glossary

Key terms

SVG
A markup vocabulary for scalable vector shapes and paths inside a web document.
Coordinate origin
The point 0,0 from which SVG x and y positions are measured.
Radius
The distance from a circle's centre to its edge.
Bounding extent
The left, right, top and bottom limits implied by position and size.
Paint order
The overlap order produced when later SVG elements are drawn over earlier ones.
FAQ

SVG Coordinates and Drawing Order FAQ

Why does the SVG y coordinate grow downward?

SVG follows the browser canvas convention with the origin at the top left. Increasing x moves right, while increasing y moves down, so visual geometry must be computed in that orientation.

How can I tell whether a circle will be clipped?

Subtract and add its radius from the centre coordinates. Compare those four edges with zero, canvas width and canvas height before rendering or changing any visual styles.

Why did one shape cover another?

SVG paints nodes in source order. Where shapes overlap, a later element appears above an earlier one. Reordering the elements changes layering without changing their coordinates or colours.

How do rectangle bounds differ from circle bounds?

For a rectangle, x and y mark the upper-left corner, while right and bottom come from adding width and height. For a circle, subtract and add radius around the centre. Both methods reduce clipping to comparisons between calculated extents and the canvas limits.

When should I choose SVG rather than a raster image?

Choose SVG for diagrams, interface shapes and generative geometry whose relationships should remain inspectable and scale cleanly. Choose raster media for photographs or pixel-based texture. The decision depends on the visual problem, not on a claim that one representation is always more advanced or more useful.

How can I debug overlap without moving shapes?

Name which element should own one shared region, then test source order while leaving geometry unchanged. Temporary contrasting fills or strokes make the intersection visible. If reordering repairs the intended depth, restore the palette and preserve the established coordinates rather than compensating with unnecessary movement.

What should I calculate before randomising geometry?

Write the permitted x and y ranges from the canvas size and the shape's extent. A circle centre must stay at least one radius from every edge, while a rectangle start position must leave room for its width and height. Generate values only inside those derived ranges, then test their endpoints.

How can I prove whether an SVG shape is clipped?

Calculate the shape's left, right, top and bottom extents and compare each with the viewBox boundaries. For a circle, subtract and add the radius to its centre coordinates. For a rectangle, add width and height to its starting position. State which inequality fails rather than relying on a screenshot alone. Then move only the offending coordinate or reduce the relevant extent and recompute all four edges.

A corrected set of inequalities demonstrates that the geometry is contained and distinguishes clipping from later paint-order coverage. Keep the original and revised calculations together so a reviewer can see which boundary changed, why the repair is sufficient and whether the adjustment preserved the intended size and relationship to neighbouring shapes.

Study strategy

Assessment move

Draw the coordinate axes and label the top left origin from memory. For each shape, write the attributes that define position and size, then compute its extent. Practise predicting overlap from source order before viewing the output. When a picture fails, classify the fault as geometry, presentation or paint order and test only that relationship.

Working through SVG Coordinates and Drawing Order in IDEA9103? Sia is AskSia’s AI Computer Science tutor — ask any IDEA9103 SVG Coordinates and Drawing Order question and get a clear, step-by-step explanation grounded in how IDEA9103 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 202 of your University of Sydney subjects - and 1,000+ Bibles across every Australian university.
Sia - your IDEA9103 tutor, unlimited, worked the way the exam marks it
The full 4-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works