Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var snow = {
- "NUMBER_OF_DROPS": 200,
- "NUMBER_OF_IMAGES": 4,
- "createADrop": function () {
- var dropDiv = Qt.createQmlObject(
- 'import QtQuick 2.0; Item {width: 20; height: 20}',
- dropContainer)
- var image = Qt.createQmlObject(
- 'import QtQuick 2.0; Image {width: 20; height: 20}',
- dropDiv)
- image.source = "snow-" + this.randomInteger(
- 1, this.NUMBER_OF_IMAGES) + ".png"
- var anim = Qt.createQmlObject(
- 'import QtQuick 2.0;import QtGraphicalEffects 1.0; NumberAnimation {}',
- dropDiv)
- dropDiv.y = this.randomInteger(-dropContainer.height * 2,
- -dropContainer.height)
- dropDiv.x = this.randomInteger(0, dropContainer.width)
- anim.target = dropDiv
- anim.property = "y"
- anim.from = dropDiv.y
- anim.to = dropContainer.height
- anim.loops = Animation.Infinite
- anim.duration = Math.random() * (15000 - 1000) + 1000
- anim.start()
- return dropDiv
- },
- "init": function () {
- var container = dropContainer
- for (var i = 0; i < this.NUMBER_OF_DROPS; i++) {
- this.createADrop()
- }
- },
- "randomFloat": function (low, high) {
- return low + Math.random() * (high - low)
- },
- "randomInteger": function (low, high) {
- return low + Math.floor(Math.random() * (high - low))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement