Skip to content

Main content

Rectangle Center Anchor Transform

Position a rectangle around a supplied fractional anchor, with nonnegative dimensions and arbitrary explicit fractions; no CSS writing-mode interpretation.

Loading tool…

Description

Position a rectangle around a supplied fractional anchor, with nonnegative dimensions and arbitrary explicit fractions; no CSS writing-mode interpretation.

Planar geometry operates on two-coordinate Cartesian points and explicit shape boundaries. A closed rectangle includes its edges, while a segment parameter locates a point along a supporting line. Signed cross products, areas and axis gaps preserve orientation or direction information that a magnitude alone would lose.

Position a rectangle around a supplied fractional anchor, with nonnegative dimensions and arbitrary explicit fractions; no CSS writing-mode interpretation.

When to use this tool

Use this tool to position a rectangle around a supplied fractional anchor, with nonnegative dimensions and arbitrary explicit fractions; no CSS writing-mode interpretation.

How to use the tool and how it works

  1. Enter anchor, width, height, fractionX, fractionY using the input definitions below.
  2. Run the operation. Resolve malformed-input errors before interpreting the result.
  3. Read result.rectangle. Interpret signs, units, ordering and null values using the rules below.

Set minX = anchorX−width×fractionX and minY = anchorY−height×fractionY, then add width and height for the high corner. Width and height must be nonnegative.1

Input fieldMeaning and unitsAccepted input
anchorAnchor point [x,y] in the rectangle’s coordinate units.Dense list of at most 128 finite numbers, subject to the stated integer/shape rules.
widthNonnegative rectangle width in coordinate units.Finite number satisfying the stated comparisons.
heightNonnegative rectangle height in coordinate units.Finite number satisfying the stated comparisons.
fractionXHorizontal anchor fraction; it may lie outside [0,1].Finite number satisfying the stated comparisons.
fractionYVertical anchor fraction; it may lie outside [0,1].Finite number satisfying the stated comparisons.
Output fieldInterpretation
resultObject containing the fields below.
result.rectangleResulting [minX,minY,maxX,maxY] anchor-positioned rectangle.
json
{
  "input": {
    "anchor": [
      10,
      20
    ],
    "width": 4,
    "height": 6,
    "fractionX": 0.5,
    "fractionY": 0.5
  },
  "output": {
    "result": {
      "rectangle": [
        8,
        17,
        12,
        23
      ]
    }
  }
}

Limitations and assumptions

  • Fractions are not restricted to [0,1]; y-axis direction, physical units and anchor semantics are caller conventions.
  • Point components and rectangle bounds are finite within ±1,000,000,000. Rectangles use [minX,minY,maxX,maxY] with ordered inclusive bounds. Floating arithmetic is used without an implicit robustness tolerance.
  • Every declared top-level input is required and unknown fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and within the absolute safe-integer magnitude; exact larger integers use decimal text. Source positions are zero-based UTF-16 offsets and span ends are exclusive unless a different convention is explicitly stated.

Alternative or Complementary methods

Choose the boundary and coordinate convention explicitly. Use robust geometric predicates or a topology-aware library when near-coincidence, holes, invalid polygons or geographic coordinates matter.

References

  1. Tool behavior and example: Rectangle Center Anchor Transform — tool.io

Similar or alternative tools

  • Polygon Rectangle Clip

    Clip an ordered planar polygon against four rectangle half-planes, preserving algorithm order; floating boundary arithmetic, no polygon topology repair.

  • Polyline Rectangle Clip

    Clip each polyline segment independently, retaining source-segment indexes and boundary point intersections instead of inventing path continuity.