Skip to content

ScifiTriangle

WASM Powered
👑Pioneer

A warning and directional component from the TechUI Scifi Geometry series.

ScifiTriangle provides a fully parameterized triangular container. Unlike static images, it calculates vertices in real-time based on mathematical formulas, supporting free switching between "regular triangle" and "inverted triangle," and handling chamfer details.

In sci-fi UI, triangles are typically bound to semantics such as Danger, Warning, or Lock, making them essential elements for building HUD tactical interfaces.

Basic Usage

Default Form

By default, ScifiTriangle renders as a regular triangle (tip pointing up). Its center of gravity is lower, making it suitable for wrapping icons or numbers.

vue
<template>
  <div class="alert-zone">
    <ScifiTriangle />
    
    <ScifiTriangle :width="100" :height="100" />
  </div>
</template>

Visual Features and Variants

ScifiTriangle provides direction inversion and unique corner cutting functions.

Direction Inversion

Controls the orientation of the triangle.

  • Default (False): Regular Triangle (tip pointing up). Often used for pyramid charts or upgrade arrows.
  • True: Inverted Triangle (tip pointing down). Often used for "selection" pointers, map markers, or danger warnings.
vue
<template>
  <ScifiTriangle :directionAlt="true" />
</template>

Mechanical Flat Top (Corner Alt)

When cornerAlt is enabled, the sharpest tip of the triangle is "chamfered," turning it into a trapezoidal variant with a flat top edge. This treatment eliminates visual "stinging," adds a sense of industrial mechanical stability, and is suitable for use as button backgrounds or nameplates.

vue
<template>
  <ScifiTriangle 
    :cornerAlt="true" 
    :borderWidth="2"
  />
</template>

Double-Layer Phantom (Decoration Alt)

Enabling decorationAlt generates a semi-transparent "ghost layer" beneath the main graphic. In warning scenarios, this ghosting effect effectively simulates visual jitter or the instability of holographic projections during emergency states.

vue
<template>
  <ScifiTriangle 
    :decorationAlt="true"
    :decoAltScale="1.1"
    :decoAltTransY="5"
  />
</template>

Gradient Flow

Supports linear gradient fills, commonly used for creating energy crystals or charging states.

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

Dynamic Calculation

The geometric calculation formula for ScifiTriangle is based on the base width and vertical height.

  • Width: The length of the triangle's base.
  • Height: The vertical distance from the base to the vertex.

Layout Suggestion: Since the top space of the triangle is narrow, if used as a container, it is recommended to shift the content's center of gravity downward using Flex layout or use padding to avoid the sharp corner area.

CSS Variable

You can define the color theme of the triangle via CSS variables.

Case Study: Crimson Alert

This case defines a warning style with red tones and high flicker frequency.

vue
<template>
  <ScifiTriangle 
    className="geom-alert" 
    :width="150" 
    :height="130"
    :directionAlt="true"
  />
</template>

<style lang="less">
.geom-alert {
  /* Border and Highlights */
  --sf-geom-bd: #991b1b;     /* Dark red border */
  --sf-geom-hlite: #ef4444;  /* Bright red decoration */
  
  /* Background */
  --sf-geom-bg: rgba(69, 10, 10, 0.6);
  
  /* Glow */
  --sf-geom-glow: #f87171;
  --sf-geom-glowop: 0.8;
}
</style>

Variable Dictionary

Below are the primary CSS variables supported by ScifiTriangle:

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. Triangle base width (px)Number300
heightHeight. Vertical height (px)Number150
directionAltDirection inversion. false=Regular (tip up), true=Inverted (tip down)Booleanfalse
cornerAltMechanical flat top. Sharp corners are chamfered when enabledBooleanfalse
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 triangle boundaries.

Released under the MIT License.