Giter Site home page Giter Site logo

onlyoulyl / moefy-canvas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moefyit/moefy-canvas

0.0 0.0 0.0 866 KB

:framed_picture: 使用可可爱爱的 canvas 动效装点你的网页~

Home Page: https://moefy-canvas.nyakku.moe/

License: MIT License

JavaScript 17.87% TypeScript 78.36% HTML 3.78%

moefy-canvas's Introduction

Moefy Canvas

用可可爱爱的 canvas 动效装饰你的网页吧~

前往文档 → https://moefy-canvas.nyakku.moe

Install

这里以 Sparkler 为例

pnpm add @moefy-canvas/theme-sparkler

Usage

<canvas id="moefy-canvas"></canvas>

零配置就可以快速创建一个动效~

import { Sparkler } from '@moefy-canvas/theme-sparkler'

const el = document.getElementById('moefy-canvas')
const sparkler = new Sparkler()
sparkler.mount(el as HTMLCanvasElement)

如果需要对其进行配置,只需要这样就可以啦~

import {
   Sparkler,
   SparklerMode,
   type SparklerConfig,
   type CanvasOptions,
   MAX_Z_INDEX,
} from '@moefy-canvas/theme-sparkler'

const themeConfig: SparklerConfig = {
   mode: SparklerMode.TRAIL,
}

const canvasOptions: CanvasOptions = {
   opacity: 1,
   zIndex: MAX_Z_INDEX,
}

const el = document.getElementById('moefy-canvas')
const sparkler = new Sparkler(themeConfig, canvasOptions)
sparkler.mount(el as HTMLCanvasElement)

所有主题都有着统一的接口,使用方法一致~

export interface CanvasOptions {
   opacity?: number // default: 1
   zIndex?: number // default: 0
}

export type ThemeConfig = Record<string, any>

export abstract class Theme<T extends ThemeConfig> {
   constructor(themeConfig?: T, canvasOptions?: CanvasOptions) {}
   abstract mount(el: HTMLCanvasElement): void
   abstract unmount(): void
}

Themes

Mouse cursor effects themes

  • theme popper 🎉
  • theme sparkler 🎇

Background themes

  • theme ribbon 🎗️
  • theme sakura 🌸
  • theme meteor 🌠

TODO

moefy-canvas's People

Contributors

renovate[bot] avatar siguremo avatar renovate-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.