Fill opacity and stroke opacity

VectorPaint fill and stroke opacity: how two properties affect one shape

Compare fill and stroke opacity on two SVG squares and inspect edge overlap and output.

English translation of the Chinese original, translated on . Original publication dates, attribution, code and version notes are retained.

Compare fill and stroke opacity on two SVG squares and inspect edge overlap and output.

Define the two properties

MDN and W3C distinguish SVG fill-opacity, which affects the fill painting operation, from stroke-opacity, which affects the stroke. Both differ from opacity applied to the whole element. Compare two squares on the same background while keeping other properties fixed. SVG specifications do not guarantee that a particular VectorPaint version preserves each attribute; observe the app’s actual result.

Create background and two squares

Create a UTF-8 SVG in a plain-text editor with SVG namespace and viewBox 0 0 240 120. Add a light-gray background covering the canvas, then two non-overlapping squares at x=20 and x=140, both y=20 with width and height 80. Give both red fill, dark-blue stroke and stroke-width 8. The background is not a test object. Save as paint-opacity.svg and copy a backup.

Set opposite paint opacities

Set the left square to fill-opacity=0.25 and stroke-opacity=1; set the right to fill-opacity=1 and stroke-opacity=0.25. Do not add overall opacity or alpha to either paint color, which would introduce another factor. The two squares swap only their separate fill and stroke opacities. Write down the property table and ensure shared CSS does not override the values before opening the file.

Predict interior and outer stroke

The left red interior blends with gray while its dark-blue stroke away from the junction remains opaque. The right red interior is opaque while its dark-blue stroke is partly transparent. A centered stroke lies partly over fill and partly outside it: under the right inner stroke is red and under the outer stroke is gray, so their blends can differ. Do not assume the whole translucent border always blends over one background.

Establish a browser reference

Open the file in an SVG-capable browser and inspect each interior, inner stroke and outer stroke. Zoom the whole view enough to compare, but do not infer exact color from one edge pixel because antialiasing affects boundaries. If the left stroke also looks translucent, check stroke-opacity, overall opacity, paint-color alpha and style overrides. If both squares look identical, first confirm that the latest copy is open.

Change the background alone

Save a copy changing the background from light gray to white while retaining both squares’ properties. The left translucent fill and right translucent outer stroke can look different against the new background; the left opaque stroke and right opaque fill, away from overlap and antialiased edges, should retain their painted colors. This illustrates the influence of underlying content without changing the original fill or stroke color values.

Compare whole-element opacity

Save another copy from the original and add a third square with fill-opacity=1, stroke-opacity=1 and overall opacity=0.25. Compare it separately with the originals, but do not claim all three are identical everywhere. Whole-element opacity applies to the rendered object, while fill and stroke opacities apply to their individual painting operations, producing different compositing at their junction. Keep each file and label the third square as an extra control.

Import a copy into the app

In the VectorPaint gallery, tap the square-and-down-arrow import icon at the top right (accessibility label “Import Artwork”), or “Import from Files” in an empty gallery, and select the exercise SVG working copy in the system file picker. If the interface differs, the entry is unavailable, or the file cannot be read, record the step as incomplete. Before editing, compare interiors and borders, then try selecting the squares separately. The app may convert appearance into a different representation; matching appearance does not prove both SVG attributes remain independent editable settings.

Troubleshoot colors and stacking

If the right border differs on its inner and outer halves, check whether it lies over red fill and gray background respectively; this may be expected compositing. If the background covers the squares, inspect paint order and layers rather than changing opacity alone. CSS fill-opacity or stroke-opacity can override the corresponding presentation attribute. Check styles, inherited values and alpha in the colors themselves before editing; change one condition at a time and record both values.

Save and reopen

Save the app’s editable original, then use a share or export entry actually shown in the current version to save separately without overwriting the SVG backup. Reopen and inspect the background, square interiors and borders. For SVG, inspect whether fill-opacity, stroke-opacity and any overall opacity remain or were converted. A bitmap supports appearance comparison only and does not prove editable properties. Record expectation, browser, app and reopened result; mark unperformed device or export steps pending.

Use three positions to explain the boundary

Mark an interior center, inner stroke and outer stroke on each square. The center is away from the stroke and helps inspect fill and background; the inner stroke overlays fill and the outer stroke overlays background. This explains why the right translucent border can look different on its two sides. A junction pixel is not the stroke paint color alone. Avoid corners and antialiased boundary pixels to reduce zoom-related differences.

Keep a comparison table and copies

Give the original, white-background copy and whole-opacity copy separate rows with fill opacity, stroke opacity, overall opacity, background and observation. If an attribute was not set, record default or unset rather than assuming zero. Check filenames and modification dates and reopen the correct copy; leave unperformed app observations blank or pending and record the version actually used.

Group opacity and overlap; Fill and stroke paint order.

Checked 23 November 2026: Apple public version lookup; MDN: fill opacity; MDN: stroke opacity. No physical-device or private-server test is claimed.