Every little fish swimming around is a visitor on this page right now, and one of them is you ( ´ ▽ ` )ノ If they get in the way of reading, feel free to turn them off.
Wavy Lines
bgSimple, unassuming lines pulse with a minimalist rhythm, adding a touch of poetic flair to your website.
Tech Keywords
Section titled “Tech Keywords”| Name | Description |
|---|---|
| Canvas 2D API | Basic 2D drawing API that efficiently renders graphics too complex for the DOM |
| Noise | Produces more natural randomness than Math.random, commonly used for terrain, clouds, and textures |
| Pointer Events | Detects pointer movement, clicks, hovers, and more, providing coordinates and target information |
| Physics Simulation | Simulates real-world physics such as gravity, collisions, and velocity |
| Simplex Noise | Improved Perlin Noise that computes faster without directional bias, commonly used in procedural generation |
| Spring-Damper System | Simulates spring oscillation and rebound with stiffness and damping constants, commonly used for natural UI motion feedback |
Usage Examples
Section titled “Usage Examples”Basic Usage
Section titled “Basic Usage”Besides its overall effect, it can also interact with the mouse.
<template> <div class="w-full flex flex-col gap-4"> <bg-wavy-lines :effect :mouse-interaction="{ type: mouseInteractionType }" class="h-full w-full touch-none example-wrap" > <div class="absolute left-2 top-2 opacity-10"> <!-- {{ fps }} --> </div> </bg-wavy-lines>
<div class="example-ctrl flex gap-6"> <select-stepper v-model="effect" :label="t('effectLabel')" class="w-full" :options />
<select-stepper v-model="mouseInteractionType" :label="t('mouseInteractionLabel')" class="w-full" :options="mouseInteractionTypeOptions" /> </div> </div></template>
<script setup lang="ts">import type { ComponentProps } from 'vue-component-type-helpers'import { ref } from 'vue'import { useI18n } from 'vue-i18n'import SelectStepper from '../../select-stepper.vue'import BgWavyLines from '../bg-wavy-lines.vue'
type Props = ComponentProps<typeof BgWavyLines>
const effect = ref<Props['effect']>('none')const options: NonNullable<Props['effect']>[] = [ 'none', 'wind', 'waves', 'orogeny',]
type MouseInteractionType = NonNullable<Props['mouseInteraction']>['type']
const mouseInteractionType = ref<MouseInteractionType>('smear')const mouseInteractionTypeOptions: MouseInteractionType[] = [ 'smear', 'black-hole', 'white-hole', 'ripple',]
const { t } = useI18n()</script>How it Works
Section titled “How it Works”Tried to directly use the Canvas 2D API to draw generative art.
Originally wanted to try GLSL, but aside from it being quite arcane, there were also many limitations to implementing interactivity.
Ended up going back to the Canvas 2D API. (´・ω・`)
Noise Algorithm
Section titled “Noise Algorithm”The natural movement effect of the lines is based on the Simplex Noise algorithm.
Noise algorithms are mainly used to generate random values that have a certain continuity, unlike typical random values (e.g., Math.random) which are discrete.
This characteristic allows their values to be used to simulate some natural effects, like terrain, clouds, water waves, etc.
However, due to the complexity of natural phenomena, noise algorithms also have many variations, such as Worley Noise, Fractal Noise, Turbulence Noise, and so on, which are quite interesting. ◝( •ω• )◟
Source Code
Section titled “Source Code”type MouseEffect = { type: 'smear'; radius?: number; force?: number;} | { type: 'black-hole'; radius?: number; gravity?: number;} | { type: 'white-hole'; radius?: number; force?: number;} | { /** 點擊後會產生水波 */ type: 'ripple'; speed?: number; maxRadius?: number; amplitude?: number;}
interface Props { /** 線條間距 */ lineGap?: number;
/** 線條之點間距 */ pointGap?: number;
/** 線條顏色 */ lineColor?: string;
/** 各種效果。例:風吹、波動等等 */ effect?: 'none' | 'wind' | 'waves' | 'orogeny';
/** 滑鼠互動效果 */ mouseInteraction?: MouseEffect;}If you have any suggestions or questions, feel free to email me( ´ ▽ ` )ノ
If you like cool components, feel free to " Buy me a cup of coffee " to show your support!