Giter Club home page Giter Club logo

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 renovate[bot] avatar siguremo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

onlyoulyl

moefy-canvas's Issues

☑️ Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • ⬆️ deps: Update pnpm to v9.9.0

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/prettify-code.yml
  • actions/checkout v4
  • creyD/prettier_action v4.3
.github/workflows/test.yml
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
.github/workflows/vitepress-deploy.yml
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • peaceiris/actions-gh-pages v4
npm
package.json
  • @types/node ^20.0.0
  • bumpp 9.5.2
  • cheap-watch ^1.0.4
  • markdown-it-task-lists ^2.1.1
  • typescript ^5.0.3
  • vite ^5.0.0
  • vite-plugin-dts 3.9.1
  • vitepress 1.3.4
  • vitest 2.0.5
  • vue ^3.2.47
  • pnpm 9.8.0
packages/core/package.json
packages/theme-meteor/package.json
  • ts-debounce ^4.0.0
packages/theme-popper/package.json
  • ts-debounce ^4.0.0
packages/theme-ribbon/package.json
  • ts-debounce ^4.0.0
packages/theme-sakura/package.json
  • ts-debounce ^4.0.0
packages/theme-sparkler/package.json
  • color2k ^2.0.0
  • ts-debounce ^4.0.0
packages/utils/package.json

  • Check this box to trigger a request for Renovate to run again on this repository

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

This repository currently has no open or pending branches.


  • Check this box to trigger a request for Renovate to run again on this repository

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.