Skip to content

ScifiRectangle

WASM Powered
👑Pioneer

A general-purpose foundational component from the TechUI Scifi Geometry series.

ScifiRectangle provides a rectangular container with physical chamfers. In sci-fi interface design, "clipped corners" are often used to convey an industrial and rugged feel, avoiding the monotony of sharp right angles and the softness of rounded corners.

This component dynamically calculates the coordinates of the four corners using mathematical formulas. It supports standard chamfers and complex mechanical corner variants, making it ideal for general information cards, pop-up backgrounds, or text containers.

Basic Usage

Default Form

By default, ScifiRectangle renders as a rectangle with all four corners clipped. The size of the chamfers is optimized via an algorithm and adjusts automatically based on the container's dimensions to ensure visual balance.

vue
<template>
  <div class="card-group">
    <ScifiRectangle />
    
    <ScifiRectangle :width="400" :height="300" />
  </div>
</template>

Visual Features and Variants

ScifiRectangle offers a rich variety of corner treatments and decorative options, allowing it to adapt to scenarios ranging from minimalist to complex.

Mechanical Clipped Corners (Corner Alt)

This is the most significant variant feature of ScifiRectangle.

  • Default (False): Standard Chamfer. The four corners are simple straight-line cuts.
  • True: Mechanical Chamfer. The corners become more complex, taking on a form similar to "brackets" or "reinforcements," providing a greater sense of defense and weight visually.
vue
<template>
  <ScifiRectangle :cornerAlt="true" :borderWidth="2" />
</template>

Double-Layer Phantom (Decoration Alt)

When decorationAlt is enabled, a semi-transparent "ghost layer" is generated beneath the main border. When used in conjunction with cornerAlt, the double-layer structure creates a very precise sense of mechanical interlocking.

  • decoAltScale: Scaling ratio (e.g., 1.03).
  • decoAltTransX/Y: Fine-tuned displacement.
vue
<template>
  <ScifiRectangle 
    :cornerAlt="true"
    :decorationAlt="true"
    :decoAltScale="1.03"
    :decoAltTransX="5"
    :decoAltTransY="5"
  />
</template>

Gradient Background

Supports linear gradient fills, commonly used for creating holographic projection-style panel backgrounds.

vue
<template>
  <ScifiRectangle 
    :gradientBackground="true" 
    :borderd="false"
  />
</template>

Dynamic Calculation

The chamfer dimensions of ScifiRectangle are not fixed pixels but are dynamic chamfers based on mathematical formulas. This means that regardless of how large or small you set the rectangle, the proportions of the chamfers remain harmonious, avoiding the inconsistency of a "giant rectangle with tiny chamfers."

  • Width/Height: Defines the overall boundaries of the rectangle.
  • BorderWidth: The thickness of the border lines.

CSS Variable

You can define the color style of the rectangle via CSS variables.

Case Study: Deep Space Pad

This case defines an information board style with deep blue tones and low transparency.

vue
<template>
  <ScifiRectangle 
    className="geom-pad" 
    :width="350" 
    :height="200"
    :cornerAlt="true"
  />
</template>

<style lang="less">
.geom-pad {
  /* Border and Highlights */
  --sf-geom-bd: #1e3a8a;     /* Deep blue border */
  --sf-geom-hlite: #3b82f6;  /* Bright blue decoration */
  
  /* Background */
  --sf-geom-bg: rgba(15, 23, 42, 0.8); /* Dark solid base */
  
  /* Glow */
  --sf-geom-glow: #60a5fa;
  --sf-geom-glowop: 0.5;
}
</style>

Variable Dictionary

Below are the primary CSS variables supported by ScifiRectangle:

Variable NameDescriptionDefault Value
--sf-geom-bgMain background colorvar(--scifi-bg)
--sf-geom-bg_altSecondary background color (for gradients)var(--scifi-bg_alt)
--sf-geom-bdBorder colorvar(--scifi-bd)
--sf-geom-hliteDecoration layer/Highlight colorvar(--scifi-hlite)
--sf-geom-focusFocus colorvar(--scifi-focus)
--sf-geom-glowGlow colorvar(--scifi-hlite)

API Reference

Props

PropertyDescriptionTypeDefault
widthWidth. Container width (px)Number300
heightHeight. Container height (px)Number150
cornerAltMechanical corner. false=Standard chamfer, true=Mechanical reinforced chamferBooleanfalse
decorationAltDouble-layer deco. Enables the ghost layerBooleanfalse
decoAltScaleDecoration layer scaleNumber
decoAltTransXDecoration layer X-axis displacementNumber
decoAltTransYDecoration layer Y-axis displacementNumber
gradientBackgroundGradient switchBooleanfalse
borderdWhether to display the borderBooleantrue
borderWidthBorder widthNumber
glowGlow switchBooleantrue
backgroundOpacityBackground opacityNumber
classNameCustom class nameString

Slots

Slot NameDescription
defaultComponent content. Content is clipped by an SVG mask to ensure it does not exceed the clipped rectangle boundaries.

Released under the MIT License.