호박이 떨어진다! 🎃

2021년 해피 할로윈!



나는 나 자신에게 도전했고 할로윈과 Canvas과 관련된 작은 프로젝트를 코딩하기로 결정했습니다!



색종이 🎊



저는 캔버스에서 임의 입자 생성기를 얻는 방법을 찾고 있었고 이 프로젝트에 널리 영감을 준 이 훌륭한 도구confetti-js를 발견했습니다.

할로윈-2021



거의 모든 것이 앱 구성에 있습니다.

const app = {
    target: 'canvas',
    images: ['./images/bat.png', './images/pumpkin.png', './images/sweet.png'],
    max: 30,
    speed: 3,
    width: window.innerWidth,
    height: window.innerHeight,
    imageMinWidth: 30,
    imageMaxWidth: 100,
}


한 가지 유용한 기능:

function getRandomInt(min, max) {
    min = Math.ceil(min)
    max = Math.floor(max)
    return Math.floor(Math.random() * (max - min + 1)) + min
}


데모 및 코드(무서울 수도 있음 😱)를 사용할 수 있습니다.

데모: https://0kyn.github.io/halloween-2021/
출처: https://github.com/0kyn/halloween-2021

좋은 웹페이지 즐겨찾기