Question

Description of my app

I'm trying to show a nice timeline animation of how bikeracks in a city are affected by traffic (every rack is a dot, that gets more towards green as it's filled up, more towards red as it becomes more empty etc)


What I have so far

Something like this

Something like the image above.

This is my code so far that generated this:

import QtQuick 2.0
import QtQuick.Particles 2.0

Rectangle {
    width: 360
    height: 360

    color: "black"

    id: bg

    ParticleSystem {
        id: sys
    }

    Emitter {
        anchors.fill: parent
        system: sys
        ImageParticle {
            anchors.fill: parent
            system: sys
            source: "images/greenBlip.png"
            clip: true
            id:  redblip
        }

        lifeSpan: 6000
    }

}

Actual question

Unfortunately, in the app right now I cannot control the following:

  • where and how many particles appear
  • how bright they are
  • lifespan (I don't want them to dissapear)

Any ideas how to control this?

Was it helpful?

Solution

To emit, say, 1000 particles with infinite life, in the Emitter set:

lifeSpan: Emitter.InfiniteLife
maximumEmitted: 1000

The emitter's onEmitParticles(Array particles) signal gives you access to all of the particles. You can retain that array, and later modify it at will. I haven't checked how hard would it be to access this array from C++. It's possible, but a Particle has a private implementation and you'd need to pull private headers etc. You could also attach to the signal from C++ code, with same caveat.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top