SPYR0.DEV

ARCHIVE 03 · DEV NOTE

Keeping the magic inside the portal

The portal effect looked fine until the animation started leaking outside the opening. A normal circle or rounded rectangle was never going to match the actual stone frame.

Updated Oct 2026·SPYR0.DEV·CSS masking

The problem

The frame and the moving part cannot be treated as one image.

The portal artwork has an irregular opening. The animated sky, glow and energy layers need to stay inside that opening, but the stone frame itself obviously must remain fully visible.

Trying to approximate the opening with border-radius or a generic oval leaves either visible leaks or cuts away parts of the artwork.

The setup

Use the real opening as the mask.

The site keeps two assets: a frame-only image and a separate exact mask of the open area. The animated layers sit inside .portal-inner, which receives the mask. The frame image is placed above it as a separate layer.

.portal-inner {
  overflow: hidden;
  background: none;

  -webkit-mask-image: url("/assets/images/portal-mask.png");
  mask-image: url("/assets/images/portal-mask.png");

  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

After that the animation can be as messy as it wants behind the mask. Anything outside the opening just never gets shown.

Layer order

Mask the energy, not the stone.

BELOW

Animated interior

Sky gradients, atmosphere, light, core energy and glints live inside the masked element.

ABOVE

Frame-only image

The portal frame sits on top without the mask, so its irregular silhouette stays crisp and untouched.

OUTSIDE

Aura and glow

Effects that are supposed to spill around the portal can remain outside the masked interior.

REUSE

Different worlds, same structure

Artisans, Magic Crafters, Dream Weavers and the lost world can share the same frame/mask system while changing their internal colors and atmosphere.

Why I kept it

The mask made the portal effects easier to experiment with.

Once the clipping was exact, I could make the internal animation stronger on hover or give each Homeworld a different energy treatment without constantly checking whether the effect escaped through the frame.

Email copied