Developers
The in-page API (window.__pixelpont). For checking what your AI can touch, or calling it from your own scripts.
Overview#
From inside the page, window.__pixelpont lets you read and change PixelPont’s state and run measurements. It’s the same API your AI agent uses.
- Every method returns a Promise
- Everything except
help()needsconnect(passphrase)first. The passphrase is in the prompt you copy from the “Measure & AI” tab - Always available on localhost pages. On other sites you’ve allowed, only while an AI connection is open
- On failure, methods resolve to
{ ok: false, error, hint }instead of throwing.hintsays what to do next
const pp = window.__pixelpont;
await pp.connect('<passphrase>');
const report = await pp.measure({ scope: 'viewport' });The limits of the passphrase (it can’t fully protect against other scripts on the same page) and how color-reading methods behave are covered in AI › Security.
Methods#
Everything below is generated at build time from the extension’s definition table — the source of help(). It’s the same text your AI reads.
| Method | Summary |
|---|---|
help(topic?, page?) | this index, or details for one method |
connect(passphrase, options?) | open the connection (needed once before every other method except help) |
disconnect() | close the connection when the work is finished |
getState() | overlay / layer / calibration state |
setVisible(visible) | show or hide the whole overlay |
setActiveLayer(id) | switch which comp is drawn |
updateLayer(id, patch) | change position, scale, opacity, blend mode, lock, scroll sync, centering |
alignTo(selector, compY) | move the comp so that its row compY sits on an element's top edge |
measure(options?) | compare comp vs render, returns mismatched elements |
getReport(options?) | progress or result of the latest measurement (also ones run from the panel) |
showDiff(mode) | draw the differences on the page (boxes for the last measure(), or a heatmap) |
inspect(selector, options?) | one element in detail: position, size, colors, computed styles |
samplePixel(x, y, options?) | comp color and rendered color at one point |
samplePixels(points, options?) | comp color and rendered color at many points, with one capture |
Connection#
help()
await window.__pixelpont.help(topic?, page?)
this index, or details for one method
help() returns the index. help("<method>") returns arguments, return shape and an example.
help("<method>", page) returns one short page (under 900 characters) of a long topic, for
tools whose return value is cut off; each page says how to get the next one.
Example: await __pixelpont.help("updateLayer")connect()
await window.__pixelpont.connect(passphrase, options?)
open the connection (needed once before every other method except help)
The API is closed by default. The user opens it by copying the prompt in the Measure tab of
the PixelPont panel and pasting the copied text to the AI; that text contains the passphrase.
Button names follow the language of the panel: the hint of an error gives them as shown there.
passphrase: string from that text. options: { client?: string } — a short name of the
calling agent or tool (optional, shown in the panel as a self-reported label).
A browser automation tool that cannot operate the tab the user has open can open the same
origin (same scheme, host and port) in its own tab and call connect() there: PixelPont
then moves to that tab, with the same comps. No focus change or click is needed for that.
Returns { ok, minutesLeft }. After a page reload the page has forgotten the passphrase and
connect() is needed again: in the same tab, while the connection is open, connect() without
a passphrase reconnects (resumed: true); the passphrase works too.
The connection closes after 30 minutes without calls, when the panel closes, or when the
page moves to another origin. A new passphrase then has to be copied by the user.
Errors not-connected / invalid-token mean the user has to copy and paste the prompt again.
Error stopped-by-user: the user stopped the AI from the panel. Stop calling and wait for the
next instruction; the connection stays open and no new passphrase is needed.
Example: await __pixelpont.connect("<passphrase>", { client: "my-agent" })disconnect()
await window.__pixelpont.disconnect()
close the connection when the work is finished
Closes the API for this page and removes the boxes / color diff drawn on it.
Layer settings are left as they are. Returns { ok }.
Calling it at the end of a task is expected; the panel then shows that the AI finished.State#
getState()
await window.__pixelpont.getState()
overlay / layer / calibration state
Returns { ok, ready, domain, visible, activeLayerId, layers[], viewport }.
layers[]: { id, name, active, x, y, scale, opacity, blendMode, locked, syncScroll,
autoCenterX, naturalWidth, naturalHeight, designWidth, renderedWidth }.
Only the active layer is drawn on the page. x / y / renderedWidth are CSS px.
designWidth is the comp image width in comp px; comp px is CSS px divided by scale.
When syncScroll is true, y is a document coordinate; otherwise a viewport coordinate.
When autoCenterX is true, the layer is centered horizontally and x is not used.
viewport: { innerWidth, innerHeight, scrollY, devicePixelRatio }, read at the moment of the
call. Some automation tools change the viewport temporarily (a debugging bar that appears
while the tool is attached, or a resize for screenshots), so the
values can differ from what is on screen; the width of an element (inspect().rect) is the
safer base for calculating a scale, and measure() returns the viewport it actually used.setVisible()
await window.__pixelpont.setVisible(visible)
show or hide the whole overlay
visible: boolean. Layer selection and settings are kept while hidden. Example: await __pixelpont.setVisible(false) before taking a clean screenshot.
setActiveLayer()
await window.__pixelpont.setActiveLayer(id)
switch which comp is drawn
id: a layer id from getState().layers. Returns { ok, activeLayerId }.updateLayer()
await window.__pixelpont.updateLayer(id, patch)
change position, scale, opacity, blend mode, lock, scroll sync, centering
patch fields (all optional): x, y (CSS px, finite numbers), scale (> 0, up to 1,000,000),
opacity (0..1), blendMode (normal | difference | invert | multiply | overlay),
locked, syncScroll, autoCenterX (booleans).
Values are stored as given: toggling syncScroll does not convert y.
Changing blendMode without opacity may also change opacity: each blend mode remembers its own
(first use: difference / multiply / overlay 1, others 0.5), unless the user turned that off.
locked stops Alt-drag and the keyboard shortcuts on the layer and makes it read-only in the panel; it does not block this method.
Returns { ok, id, applied, previous }: previous holds the values before the change for the
fields in patch, so updateLayer(id, previous) undoes it.
Example: await __pixelpont.updateLayer(id, { y: 120, blendMode: "difference" })alignTo()
await window.__pixelpont.alignTo(selector, compY)
move the comp so that its row compY sits on an element's top edge
selector: a CSS selector (first match). compY: a y coordinate in comp px.
Moves the active layer vertically only, and returns { ok, id, y, previousY }.
On long pages, small differences add up, so everything below drifts. Aligning the comp
to a section first shows which offsets are local to that section: measure() afterwards
reports them without the accumulated drift (commonOffset close to 0).
Example: await __pixelpont.alignTo(".pricing", 2480)Measure#
measure()
await window.__pixelpont.measure(options?)
compare comp vs render, returns mismatched elements
options: { scope?: "viewport" | "page" | "<css selector>", ignore?: string[],
tolerance?: number, minConfidence?: number, layer?: { x?, y?, scale? },
format?: "full" | "lines", settle?: number, limit?: number, repeat?: boolean }.
repeat: true measures again with the options of the previous measure() (options passed
along override them): measure({ repeat: true }) after fixing the CSS and reloading.
An option that is not in this list is rejected (unknown-option), not ignored.
limit (1 to 30): how many items each list (mismatches, unmatched, colorMismatches,
borderline, groups) returns at most. The totals stay the same. Small values keep
repeated results short.
settle (ms, 500 to 10000): before measuring, wait until the page has shown no change
(DOM, stylesheets, size) for 300 ms, but no longer than this many ms. For CSS that was
just saved and may not be applied yet. The result then carries settle { waitedMs,
timedOut }; timedOut true means the page was still changing when the time ran out, so
the measurement may show a state in between. A change that has not started within
300 ms of the call is not waited for.
format "lines" returns a short text summary instead of the full result; see
help("getReport"). It suits tools that cut long return values.
layer overrides the layer position or scale for this measurement only; the settings the
user sees in the panel stay untouched (unlike updateLayer).
x and y are layer positions for the scale in use: when scale is overridden, the stored y
usually no longer fits (a header may change height with the page width), so y has to be
overridden too. For y: the top of the element (document coordinate when syncScroll is on)
minus the comp row that should sit there times scale. The comp row is 0 for the section
at the very top of the comp; for others it is the y of that section inside the comp image.
For scale: the width on the page of the area the comp shows (often the main column, not
the whole window) divided by designWidth. With autoCenterX the layer stays centered for
the overridden scale, so x does not need to be overridden.
scope defaults to "viewport". A selector limits the check to that element subtree;
only the part currently scrolled into view is measured.
scope "page" measures the whole page, one screen at a time. It returns
{ ok, started: true } at once; getReport() gives progress, then the result.
The page is first scrolled once to its end and back to the top (so that what loads or
appears on scroll is there), then it stays at the top: each screen is captured without
scrolling, and the scroll position is put back at the end.
During a page run, lazy images are loaded, and a fixed element that is not at its comp
position (a bottom bar, for example) is hidden; see pinned below.
The layer needs syncScroll: true and the window itself has to scroll (a
page that scrolls inside an element returns page-scrolls-inside-element). Elements taller
than the viewport are not measured (counted in tooLarge).
ignore: selectors to skip (photos, sliders, fixed headers). tolerance: CSS px, 0 to 12, default 1.
minConfidence (0..1, default 0.1): offsets below it are counted in uncertain instead of
being listed. { tolerance: 0, minConfidence: 0 } lists every non-zero offset found.
Returns { ok, pass, breakdown, tooSmall, status, by, measuredAt, scope, tolerance, ignore,
settle?, layer?, layerFix?, designWidth, scale, viewport, checked, skipped, total,
mismatches[], borderlineTotal, borderline[], borderlineBand, uncertain, commonOffset,
commonApplied, commonCount, unmatchedTotal, unmatched[], colorTotal, colorMismatches[],
colorSkipped[], groups[], misaligned, scaleDrift, outOfView, tooLarge, pinned, truncated,
pageCut, listedLimit?, notes[] }.
status, by and measuredAt are the ones described in help("getReport"). listedLimit repeats
the limit when one was given (to measure() or getReport()): the lists were cut to it.
Lists are largest first (unmatched: in document order), at most
30 each (borderline 10).
pass is true only when at least one element was compared and there is no mismatch, no
unmatched element, no color mismatch, no range left with colors uncompared (colorSkipped),
no element left out under a stuck fixed or sticky one,
nothing left out of view, no layout shift (layoutShifts empty), heightDrift null,
nothing cut off by a limit (truncated 0, pageCut false), and neither misaligned nor
commonApplied. borderline, uncertain and tooLarge do not fail it, so a strict check also
looks at breakdown.
colorSkipped[] lists the captured ranges ({ x, y, width, height, reason }) that were blanked
as a whole: positions were compared there, colors and the differences outside element boxes
were not. reason "page-changed": the page changed between the scan and the capture; on a
page that never stops, measuring again may give the same result. reason "unreadable": a
frame or an image from another origin covers the range, or its place cannot be determined;
measuring again gives the same result. notes[] says what to do.
truncated counts elements left unmeasured because one screen held more than 200
candidates; pageCut is true when a page taller than 60 screens left a range uncaptured.
breakdown counts every candidate element: matched, mismatched, unmatched, borderline, uncertain,
notAlignable (nothing to align on, or outside the comp), outOfView, overLimit, tooLarge, tooSmall,
coveredByFixedOrFrame (the last two are null for scope "page"), pinned.
tooSmall: { selectors[] } lists the first visible elements left out as too small (scope
"viewport" or a selector; empty for scope "page"). Off-screen and 1px elements are only counted.
The same counts under their older names: total is breakdown.mismatched (position mismatches,
not all elements; that is checked), skipped is notAlignable, truncated is overLimit.
unmatched[]: { selector, rect, styles } lists elements with no matching place
in the comp: what is drawn differs (other text or image, a missing or extra element) or
the offset exceeds the search range.
Their position and color are not compared. You know the code: decide whether the content is
meant to differ (then pass it in ignore) or the element is wrong.
pinned { total, selectors[], by[{ selector, position, rect? }] }: elements skipped because a fixed
or sticky element (by) is stuck over them after scrolling; the comp shows it where it sits
at the top of the page. At scrollY 0 fixed headers and sticky elements are measured as
usual. Scope "page" keeps the page at its top, so a header fixed at the top and sticky
elements are measured once, where they rest. A fixed element that is not at its comp
position there (a bottom bar, a banner) is hidden; pinned then holds what is inside it.
mismatches[] / borderline[]: { selector, rect, delta, deltaDesignPx, moveBy, confidence,
styles, atLimit?, own?, overlapsExcluded?, stretch? }.
stretch: true marks an element that matched no single place, but whose content matches once
stretched sideways (the offset grows steadily from left to right): delta.x / y is the offset
of its left end and delta.width how much wider (negative: narrower) the content is in the
comp. For text this is letter-spacing (delta.width divided by the number of gaps between
the characters of a line), or font-size or the font; its color is not compared.
overlapsExcluded: n marks an element that only matched once the n elements drawn over it
(child images or text that are off by a different amount) were left out of the comparison;
its delta is the offset of the element itself, and its size is not measured.
commonOffset { x, y } (CSS px): the offset shared by at least half of the measured elements
(and 3 or more), or 0 when there is none. Not 0 means the layer position itself (or
everything above) is off by that much; commonApplied is then true and commonCount tells
how many elements share it. Elements off by only that amount are not listed, and the
listed ones carry own { x, y }: their offset with commonOffset removed (delta stays the
full difference from the comp). The value does not depend on tolerance or minConfidence.
layerFix { x?, y } comes with commonApplied: the layer position that removes commonOffset
(the position measured with, minus commonOffset; x is left out while autoCenterX is on).
measure({ layer: layerFix }) tries it for one measurement; updateLayer(id, layerFix) keeps it.
ignore repeats the selectors that were left out; layer { x, y, scale } is present when the
measurement used options.layer, so a result measured under conditions is not read as a
plain one.
borderline[] / borderlineTotal: elements above the tolerance by no more than borderlineBand
(CSS px, one captured pixel: 0.5 at device pixel ratio 2, at most 1). They flip between
runs, so they are kept out of mismatches. With tolerance 1 and band 0.5, 1.5 px is still
borderline; a stricter line can be drawn from the borderline list itself.
groups[]: { parent, moveBy, count, selectors[] } lists sets of two or more listed
mismatches that share a parent element and are off by exactly the same amount (own when
commonApplied). Such a set is usually fixed on the parent (its position, padding or gap)
rather than element by element.
uncertain counts offsets left out because the match was ambiguous.
rect is in viewport coordinates, or document coordinates for scope "page".
delta: how the rendered element differs from the comp, top-left anchored:
y: 3 means the element sits 3px too high (moving it down 3px matches the comp);
delta is CSS px, deltaDesignPx is comp px. x / y come from sliding the comp over the
render to the best match (works over photos). width / height are only reported on
plain backgrounds (width: 4 means the comp is 4px wider); otherwise they are 0.
Elements smaller than 16x8px or under fixed / sticky elements are not measured (counted
in breakdown). Elements larger than 40% of the viewport (backgrounds, containers) are not
measured one by one either, but reported in tooLarge { total, selectors[] }; inspect()
compares one of them on its own.
moveBy { x, y } tells how far to move the rendered element so that it matches the comp. It is
delta.x / delta.y, or own when commonApplied is true (the comp layer offset is not something
to fix on the element).
confidence (0..1) is low over photos, repeated patterns or crowded areas. As a guide:
0.6 or more is dependable, 0.1 to 0.6 is doubtful (worth a look with inspect()), below
minConfidence the offset is not listed (counted in uncertain).
Offsets are searched within about 12 CSS px (a few px for elements under about 20 device
px high or wide). An element that does not match there is searched again up to about 48
CSS px; when its content is clearly found there, that offset is listed. atLimit: true marks
an offset that reached the 12 px range without that: the value is not reliable (larger
offset, or no match).
sinceLast: { previousAt, fixed { total, selectors[] }, appeared { total, selectors[] }, still }
compares with the previous measurement of the same scope and comp (kept across page reloads):
fixed were listed before and are not now, appeared are newly listed (a fix that moved
something else), still is the count listed both times. null when there is none to compare.
scaleDrift: when the horizontal offsets grow in proportion to the horizontal position, the
offset per px (else null). The scale may then be slightly off; notes[] gives a scale to check
it with. It is a hint: offsets come in steps of one captured pixel, so a drift of one step
cannot be told from one side of the page being off by that step.
notes[] explains situations that make the result easy to misread: the whole comp being
far off (misaligned: true, colors then not compared), or elements outside the visible
area that were not measured (outOfView { total, selectors[] }; with scope "page", the ones
sticking out sideways).
layoutShifts[]: { y, by } lists the places from which everything below is off by the same
amount: around y the page is by px taller than the comp (negative: shorter). Something above
has a different height (an extra or missing block, a margin), or the layout changes with the
scroll position. It is found by matching the rows of the page against the rows of the comp,
up to 400px per screen, so it does not depend on the 12px search of single elements.
sections[]: { y, height, offsetY } are the ranges compared after moving the comp by offsetY;
mismatches inside them are what remains besides that offset. Fix layoutShifts first, then
measure again. With the first section already off (y at the top of the measured range), the
real boundary is above it. heightDrift (or null): the vertical offset grows steadily down the
page, so the comp scale or the window width is probably slightly off (layoutShifts is empty and
pass is false then). If both are right, several blocks really differ in height: fix the
heights where sections[].offsetY changes.
colorMismatches[]: { selector, rect, styles, ratio, render, comp } lists elements whose
fill differs from the comp after aligning positions (wrong color, missing gradient).
Colors are compared as 4px block averages, so text anti-aliasing does not count.
ratio is the share of blocks that differ; render / comp are the mean colors (#rrggbb).
An item with patch { x, y, width, height } matches as a whole and differs in one part only
(hidden under another element, wrong stacking order, a clipped image edge). patch is the
differing area (same coordinates as rect) and render / comp are its mean colors. Elements
listed in mismatches get no patch; weakly aligned ones (confidence below 0.3) only for
an area at least 8px thick.
With coveredBy (a selector), the patch is hidden under that element while the comp shows
this element in front (wrong stacking order; confirmed by hiding the covering element,
capturing again and finding that the comp then matches). Fix z-index or the element order.
coveredBy is only looked for with scope "viewport". Without it,
document.elementsFromPoint(center of patch) tells what is on top there (with scope "page",
rect and patch are document coordinates, so subtract the scroll offset).
With residual ("missing" | "extra" | "changed"), the patch was found by comparing the whole
screen, not element by element: something in the comp is not on the page (missing: a line,
a border, a word), something on the page is not in the comp (extra), or the content differs
(changed: different wording, artwork). It catches thin differences and places no measured
element covers. selector / rect are the topmost element at that place (for a line or a
decoration, the container that owns it), ratio is 0. Only with scope "viewport", one per
element (the largest), and not where an element is already listed. Not reported: "changed"
areas only 1 CSS px thin (a line that is slightly lighter or thinner), and the place where a
stuck fixed or sticky element (pinned.by) rests in the comp (elements with no match there
are counted in pinned instead of unmatched).
stalePage: true means the script in the page is older than the panel (the extension was
updated but not reloaded at chrome://extensions), so these checks did not run.
inspect(selector) gives the dominant colors of one element.
The overlay is hidden and animations are paused during the capture, then restored.
The target tab does not have to be in front: it is captured as it is while it is in the
background or in another window.
Example: await __pixelpont.measure({ ignore: [".hero__photo"] })getReport()
await window.__pixelpont.getReport(options?)
progress or result of the latest measurement (also ones run from the panel)
options: { format?: "full" | "lines", limit?: number }. Each one left out falls back to
what the measure() that produced the result was given (default "full", no limit).
limit (1 to 30): how many items each list returns at most.
format "lines" returns { ok, status, pass, format, settle?, lines[] }: one short line per element,
with no styles and no long selectors, for tools that cut return values at about 1000
characters or block some characters (the lines hold no equals sign and no ampersand).
The first line is the totals, the second the conditions (scope, tolerance, viewport width,
ignored selectors, layer override); then come notes on a comp that looks misaligned, on colors
not compared, on the comp offset, on a scale that may be slightly off (scaleDrift), on y offsets
that grow down the page (heightDrift, with the y of each step) and on what was not covered;
then "1 h2.title in section.hero: move x 0 y 3, confidence 0.8" for each mismatch (move has
the meaning of moveBy; "at search limit" is added for atLimit),
"u1 p.lead in section.hero: no match in the comp" for each unmatched element,
"c1 ..." for each color mismatch and
"g1 parent ..." for each group. The element is written as its last selector part "in"
its parent part, which reads well but may not be unique: line n is mismatches[n - 1] of
the full format, and the full selector is there.
While running: { ok, status: "running", scope, progress: { done, total } } (screens).
When finished: { ok, status: "done", by, measuredAt, ...same fields as measure() }.
by is "ai" or "human" (a person pressed Measure in the panel).
Example: poll getReport() every second after measure({ scope: "page" }).showDiff()
await window.__pixelpont.showDiff(mode)
draw the differences on the page (boxes for the last measure(), or a heatmap)
mode: "boxes" | "heatmap" | "off". "boxes" outlines each mismatched element of the last
measure() with a label such as "1 ↓3px" (same meaning as moveBy), "u1 ≠", "c1 Color", "c2 Part" (one part differs) or "c3 Hidden" (hidden under another element); the word follows the browser language. The
number is the place in the result: n is mismatches[n - 1], u is unmatched, c is
colorMismatches (the same numbers as in format "lines"). It returns { ok, mode, boxes }.
"heatmap" captures the current viewport and paints every 4px cell whose color differs
from the comp (darker means a larger difference). It returns { ok, mode, cells, cellSize } and does not need
a measure() first. A screenshot taken afterwards works as a diff image.
The drawing is removed by showDiff("off") or by the next capture (measure, inspect, ...).inspect()
await window.__pixelpont.inspect(selector, options?)
one element in detail: position, size, colors, computed styles
selector: a CSS selector; the first match is used. Only the part on screen is compared.
options: { layer?: { x?, y?, scale? } } — the same temporary layer override as in measure().
Without it the layer settings of the panel are used, so after measure({ layer }) the same
layer has to be passed here too, or the two results will not agree.
Returns { ok, selector, rect, positionMeasured, unmatched, unmatchedCause, farMatch, sizeMatch,
delta,
deltaDesignPx, confidence, overlapsExcluded,
color: { diffRatio, maxDifference, patch, render[], comp[] }, styles, parent, centeredInParent }.
delta has the same meaning as in measure(). positionMeasured is false for plain areas
with nothing to align on (delta is then 0, colors are still compared).
unmatched is true when no matching place was found (the content differs, or the offset
exceeds the search range); delta is then 0 and not a measurement. For those, a wider range
(about 160 CSS px) is searched: unmatchedCause is "offset" when a matching place was found
there, with farMatch: { delta, deltaDesignPx, confidence } giving the way to it, or "content"
when nothing matched (other text or image, another blend) and farMatch is null. With
"offset", color is compared at the place found. unmatchedCause is null when the search
cannot tell: the element is under about 20 device px high or wide (too small for it), the
place found already shows the same thing on the page (repeated content, such as the same
button in the next card), or an image from another origin is near (no search is done).
Where the same content repeats within that range, farMatch can lead to a neighboring copy.
sizeMatch: { resizeBy, delta, deltaDesignPx } when no position matches well but another size
(within 10%) does: the element is drawn larger or smaller than in the comp. resizeBy is the
factor for its size (1.03: make it 3% larger), delta what remains once resized. Else null.
color.render / color.comp: the three most frequent colors as { hex, share }, usually the
background first and the text color next. diffRatio is the share of 4px blocks whose
average color differs (0 means the same fill), maxDifference the largest channel difference.
color.patch { x, y, width, height } is the area where the difference is concentrated when
the element matches as a whole (viewport coordinates), else null. See help("measure").
Like samplePixel(), calls that follow each other within about 1.5 s read the same capture
(no flicker; the position and styles of the element are read anew each time). A new capture
is taken after the page scrolls or its DOM changes.
styles holds computed values (color, backgroundColor, backgroundImage, font, box, and
what often decides the position: position, top, left, translate, transform, gap,
justifySelf, alignSelf).
parent: { selector, styles } gives the parent element and the values that place its
children (display, position, flexDirection, gap, justifyContent, justifyItems, alignItems,
textAlign, paddingTop, paddingLeft).
centeredInParent: "x", "y" or "both" when the element sits in the middle of its parent
(equal space on both sides, within 0.5px), else null. An offset of a few px on a centered
element is often the comp being off-center rather than the code. The comparison is with the
DOM parent, so an element placed against another box (position: absolute or fixed) can be
centered and still get null. An element that only fills its parent with equal non-auto
margins is not reported as centered.
These are plain computed values; which one causes an offset is left to the reader.
color is null when the element overlaps an image from another origin: such colors are
never returned (error protected-area in samplePixel, and no cells in the heatmap), because
scripts on the page cannot normally read them. An element that holds or touches an embedded
frame is not compared at all (error protected-area), as in measure().
Example: await __pixelpont.inspect(".cta__button")samplePixel()
await window.__pixelpont.samplePixel(x, y, options?)
comp color and rendered color at one point
x, y: viewport coordinates in CSS px. Returns { ok, x, y, render, comp, difference }.
options: { layer?: { x?, y?, scale? } } — the same temporary layer override as in measure().
render / comp are #rrggbb averaged over one CSS px. difference is the largest channel
difference (0..255); about 24 or less is the same color to the eye.
Example: sampling a few points along a gradient shows whether it is missing in the render.
Calls that follow each other within about 1.5 s read the same capture (for up to 10 s),
so the page is not captured again and the comp does not flicker. A new capture is taken
after the page scrolls or its DOM changes.
For more than a couple of points (walking across an edge px by px), use samplePixels():
one capture for all of them.samplePixels()
await window.__pixelpont.samplePixels(points, options?)
comp color and rendered color at many points, with one capture
points: an array of 1 to 500 { x, y } (viewport coordinates in CSS px; halves are fine).
options: { layer?: { x?, y?, scale? } } — the same temporary layer override as in measure().
Returns { ok, points: [{ x, y, render, comp, difference }] } in the order given. A point
that cannot be read has error instead ("outside-viewport", "outside-comp",
"protected-area"); the others are still returned.
The page is captured once, and only the area that holds all the points, so this is the way
to find an edge: sample a row or a column across it and look for where render and comp
change. Calling samplePixel() in a loop captures once per point: slow, and the page
flickers each time.
Example: await __pixelpont.samplePixels([{ x: 60, y: 1231 }, { x: 60.5, y: 1231 }, { x: 61, y: 1231 }])Compatibility#
This page describes v0.1.0 (main as of 2026-10-31). While a release is in store review, this page may describe a version that isn’t out yet.
- No compatibility guarantee. The
measure()result in particular has many fields and changes often - Check the installed version’s spec with
help() - Internal values such as the 12px search range may change with the implementation