liveBook · Manning

Point

As explained in Math for Web Design

A point is a location in space represented without length, width, or height, commonly by coordinates.

A point is one exact location. In browser work, represent it with an x coordinate for horizontal position and a y coordinate for vertical position. The viewport or a container commonly supplies the origin: (0, 0) is its top-left corner, x increases rightward, and y increases downward. Thus (100, 150) sits 100px right and 150px below that origin. section 1.4.7 section 10.1

Points make pointer input and element geometry concrete. MouseEvent.clientX and clientY identify the pointer relative to the viewport. On a canvas, two points can define a line: moveTo() sets the start point and lineTo() sets the end point. Absolute positioning and transforms can likewise depend on precise coordinate locations. section 1.4.7 section 10.1

Use points as the fixed locations behind common interface calculations:

  • Record a drawing cursor as an (x, y) point, then extend the current canvas path to that location. section 1.4.7
  • Find an element center from its bounding rectangle: left + width / 2 and top + height / 2. section 10.2.3
  • Turn a pointer position into an offset from that center by subtracting centerX and centerY from clientX and clientY. section 10.2.3
  • Treat the difference between two points as the input for direction, distance, and rotation calculations. section 10.1 section 10.2.3

Pointer-driven card tilt

For a hover effect, first calculate the card’s center point from getBoundingClientRect(). Subtract that point from the mouse point to get center-relative x and y values. Their distance controls tilt intensity: a pointer near the center produces less rotation, while one nearer an edge produces more. Angle and trigonometric calculations then turn that relative position into horizontal and vertical rotation values. section 10.2.3

Table 1.7 Some geometric examples

Task

Code

Explanation

Find the x and y coordinates of the point that represents the current mouse position in JavaScript.

element.addEventListener
(
'mousemove', (e) => { const x = e.clientX; const y = e.clientY; });

The MouseEvent properties clientX and clientY return the horizontal and vertical positions of the mouse pointer relative to the top-left corner (0, 0) of the browser viewport.

Draw a line on a canvas element with JavaScript.

ctx.beginPath();

ctx.moveTo(50, 50); // Start point

ctx.lineTo(250, 100); // End point

ctx.stroke();

Given a canvas context ctx, this code draws a line from the point (50, 50) to (250, 100).

Rotate an element 45 degrees in CSS.

.box { transform: rotate(45deg); }

The rotate() CSS function rotates an element. A positive angle rotates the element clockwise; a negative angle rotates it counterclockwise.

Create a shape in CSS.

.shape { clip-path: polygon( 25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50% ); }

The clip-path property sets an element’s clipping region to a custom shape—a hexagon, in this case—as defined by the polygon function.

Compare retrieving a mouse point, drawing between two canvas points, and rotating an element in concise browser code. section 1.4.7

How Math for Web Design covers it

How deep it goes
Defines 2D coordinates and browser origins, then works through center-relative pointer calculations for a hover effect.
Examples
Uses cursor coordinates for canvas drawing and a card’s center point for mouse-responsive rotation.
What it assumes
Introduces 2D points and coordinates from basic browser-layout contexts without requiring advanced geometry.
What you can do after
Apply it via MouseEvent, canvas, and getBoundingClientRect() to calculate pointer and element locations.
How it connects
Connects points to coordinates, vectors, bounding boxes, canvas lines, angles, distance, and CSS transforms.

Also explained in

Compare how 4 books explain point →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math for Web Design. The section links point to the parts of the book it draws on.