Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

波纹运动(Wave) #20

Open
Barrior opened this issue Apr 6, 2021 · 1 comment
Open

波纹运动(Wave) #20

Barrior opened this issue Apr 6, 2021 · 1 comment

Comments

@Barrior
Copy link
Owner

Barrior commented Apr 6, 2021

https://jparticles.js.org/#/en/examples/wave

JParticles is a lightweight JavaScript library for build user interfaces base on the Canvas. That provide some cool particle effects to bring a surprise for the users.

@Barrior Barrior changed the title Wave 波纹运动(Wave) Apr 7, 2021
@Barrior
Copy link
Owner Author

Barrior commented Apr 13, 2021

避免图片加载闪烁:

function loadImage(url, successCallback) {
  const image = new Image()
  image.addEventListener('load', () => successCallback(image))
  image.crossOrigin = 'Anonymous'
  image.src = url
}

loadImage('https://raw.githubusercontent.com/Barrior/assets/main/github-logo-text.svg', (image) => {
  new JParticles.Wave('#demo', {
    num: 1,
    line: false,
    fill: true,
    fillColor: '#27C9E5',
    offsetTop: 0.5,
    crestHeight: 5,
    crestCount: 3,
    speed: 0.2,
    // 设置为已加载完毕的图像数据
    mask: image,
  })
})

或者使用 JParticles 内置的加载函数:

// ES6: import { loadImage } from 'jparticles/lib/utils'

JParticles.utils.loadImage('https://raw.githubusercontent.com/Barrior/assets/main/github-logo-text.svg', (image) => {
  new JParticles.Wave('#demo', {
    num: 1,
    line: false,
    fill: true,
    fillColor: '#27C9E5',
    offsetTop: 0.5,
    crestHeight: 5,
    crestCount: 3,
    speed: 0.2,
    // 设置为已加载完毕的图像数据
    mask: image,
  })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant