Command Palette

Search for a command to run...

Hectal
Phase 12: Big Data: Canvas, Hit-Testing and Performance
Data Visualization · Exercise 1 of 4Next
Beginner

Which circle is under the pointer?

Two circles overlap on a canvas. Write pick(x, y) so it returns the name of the circle at that point, or null if there is none.

B is drawn after A, so where they overlap the answer is B. A point that is NaN is on nothing.

What Check tests

  1. A point only inside A gives A
  2. A point only inside B gives B
  3. Where they overlap, the later circle wins
  4. Empty space gives null
  5. A NaN position gives null

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.