--- /dev/null
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle{
+ color: "goldenrod"
+ width: 2000
+ height: 2000
+ ParticleSystem{id: sys}
+ ImageParticle{
+ id: up
+ system: sys
+ image: "content/singlesmile.png"
+ }
+ Emitter{
+ anchors.centerIn: parent
+ system: sys
+ particlesPerSecond: 1000
+ particleSize: 20
+ particleDuration: 10000
+ speed: AngledDirection{angleVariation: 360; magnitudeVariation: 100;}
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: up.autoRotation = !up.autoRotation
+ }
+}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
+ id: root
color: "white"
width: 310
height: 300
ParticleSystem{ id: sys }
- Picture{
+ CustomParticle{
system: sys
- anchors.fill: parent
- image: "content/singlesmile.png"
- onceOff: true
- }
- ColoredParticle{
- system: sys
- image: "content/particle.png"
- color: "black"
- alpha: 0.4
- sizeTable: "content/sizeInOut.png"
+ property real maxWidth: root.width
+ property real maxHeight: root.height
+ ShaderEffectSource{
+ id: pictureSource
+ sourceItem: picture
+ hideSource: true
+ }
+ Image{
+ id: picture
+ source: "content/singlesmile.png"
+ }
+ ShaderEffectSource{
+ id: particleSource
+ sourceItem: particle
+ hideSource: true
+ }
+ Image{
+ id: particle
+ source: "content/particle.png"
+ }
+ vertexShader:"
+ attribute highp vec2 vPos;
+ attribute highp vec2 vTex;
+ attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+ attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+ attribute highp float r;
+
+ uniform highp float maxWidth;
+ uniform highp float maxHeight;
+
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+ uniform highp float timestamp;
+ uniform lowp float qt_Opacity;
+
+ varying highp vec2 fTex;
+ varying highp vec2 fTex2;
+ varying lowp float fFade;
+
+ void main() {
+ fTex = vTex;
+ fTex2 = vec2(vPos.x / maxWidth, vPos.y / maxHeight);
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = vPos
+ - currentSize / 2. + currentSize * vTex // adjust size
+ + vVec.xy * t * vData.y // apply speed vector..
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+ gl_Position = qt_ModelViewProjectionMatrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * qt_Opacity;
+ }
+ "
+ property variant particleTexture: particleSource
+ property variant pictureTexture: pictureSource
+ fragmentShader: "
+ uniform sampler2D particleTexture;
+ uniform sampler2D pictureTexture;
+ varying highp vec2 fTex;
+ varying highp vec2 fTex2;
+ varying highp float fFade;
+ void main() {
+ gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, fTex).w * fFade;
+ }"
}
- TrailEmitter{
+ Emitter{
id: emitter
system: sys
emitting: false
maxParticles: 1200
anchors.fill: parent
particleSize: 32
- speed: PointVector{ xVariation: 12; yVariation: 12 }
+ speed: PointDirection{ xVariation: 12; yVariation: 12 }
}
MouseArea{
anchors.fill: parent
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
color: "goldenrod"
width: 400
height: 400
ParticleSystem{id:sys}
- DeformableParticle{
+ ImageParticle{
system: sys
particles: ["goingLeft", "goingRight"]
image: "content/singlesmile.png"
rotationSpeed: 90
autoRotation: true
}
- DeformableParticle{
+ ImageParticle{
system: sys
particles: ["goingDown"]
image: "content/squarefacespriteXX.png"
rotation: 180
- yVector: PointVector{ y: 0.5; yVariation: 0.25; xVariation: 0.25; }
+ yVector: PointDirection{ y: 0.5; yVariation: 0.25; xVariation: 0.25; }
}
Timer{
running: true
interval: 8400
onTriggered: emitC.emitting = true;
}
- TrailEmitter{
+ Emitter{
id: emitA
x: 0
y: 120
system: sys
emitting: false
particle: "goingRight"
- speed: PointVector{ x: 100 }
+ speed: PointDirection{ x: 100 }
particleDuration: 4000
particlesPerSecond: 2
particleSize: 32
}
- TrailEmitter{
+ Emitter{
id: emitB
x: 400
y: 240
system: sys
emitting: false
particle: "goingLeft"
- speed: PointVector{ x: -100 }
+ speed: PointDirection{ x: -100 }
particleDuration: 4000
particlesPerSecond: 2
particleSize: 32
}
- TrailEmitter{
+ Emitter{
id: emitC
x: 0
y: 360
system: sys
emitting: false
particle: "goingDown"
- speed: PointVector{ x: 100 }
+ speed: PointDirection{ x: 100 }
particleDuration: 4000
particlesPerSecond: 2
particleSize: 32
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
color: "goldenrod"
width: 400
height: 400
- ColoredParticle{
+ ImageParticle{
id: test
particles: ["Test"]
image: "content/particle.png"
color: "#336666CC"
colorVariation: 0.0
}
- SpriteParticle{
+ ImageParticle{
id: single
particles: ["Face"]
system: sys
z: 2
anchors.fill: parent
- Sprite{
+ sprites: Sprite{
source: "content/squarefacesprite.png"
frames: 6
duration: 120
}
}
- Mask{
+ MaskShape{
id: mask
source: "content/smileMask.png"
}
- TrailEmitter{
+ Emitter{
system: sys
particle: "Test"
anchors.fill: parent
particleSize: 10
shape: mask
}
- TrailEmitter{
+ Emitter{
system: sys
particle: "Face"
anchors.fill: parent
particlesPerSecond: 60
particleDuration: 1440
emitting: true
- speed: PointVector{xVariation: 10; yVariation: 10;}
+ speed: PointDirection{xVariation: 10; yVariation: 10;}
particleSize: 30
particleSizeVariation: 10
shape: mask
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
color: "goldenrod"
z:4
}
ParticleSystem{ id: sys }
- SpriteParticle{
+ ImageParticle{
anchors.fill: parent
id: particles
system: sys
duration: 10000
}]
}
- TrailEmitter{
+ Emitter{
system: sys
particlesPerSecond: 16
particleDuration: 10000
emitting: true
- speed: AngleVector{angle: 90; magnitude: 60; angleVariation: 5}
- acceleration: PointVector{ y: 10 }
+ speed: AngledDirection{angle: 90; magnitude: 60; angleVariation: 5}
+ acceleration: PointDirection{ y: 10 }
particleSize: 30
particleSizeVariation: 10
width: parent.width
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
color: "goldenrod"
width: 800
height: 800
ParticleSystem{ id: sys }
- SpriteParticle{
+ ImageParticle{
system: sys
anchors.fill: parent
sprites: [Sprite{
duration: 120
}]
}
- TrailEmitter{
+ Emitter{
id: particleEmitter
system: sys
width: parent.width
particlesPerSecond: 16
particleDuration: 8000
emitting: true
- speed: AngleVector{angle: 90; magnitude: 300; magnitudeVariation: 100; angleVariation: 5}
- acceleration: PointVector{ y: 10 }
+ speed: AngledDirection{angle: 90; magnitude: 300; magnitudeVariation: 100; angleVariation: 5}
+ acceleration: PointDirection{ y: 10 }
particleSize: 30
particleSizeVariation: 10
}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
color: "white"
ParticleSystem{
id: sys
}
- UltraParticle{
+ ImageParticle{
sprites: [
Sprite{
name: "licking"
factor: 0.1
system: sys
}
- TrailEmitter{
+ Emitter{
system: sys
anchors.centerIn: parent
id: particles
particlesPerSecond: 200
particleDuration: 6000
emitting: true
- speed: AngleVector{angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
+ speed: AngledDirection{angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
particleSize: 40
particleEndSize: 80
}
**
****************************************************************************/
-import Qt.labs.particles 2.0
-import Qt.labs.particles 2.0 as Qlp
+import QtQuick.Particles 2.0
+import QtQuick.Particles 2.0 as Qlp
import QtQuick 2.0
Item {
}
}
- ColoredParticle {
+ ImageParticle {
system: sys
particles: ["starfield"]
image: "content/star.png"
colorVariation: 0.3
color: "white"
}
- TrailEmitter {
+ Emitter {
id: starField
system: sys
particle: "starfield"
anchors.centerIn: parent
- //acceleration: AngleVector{angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed?
- acceleration: PointVector{ xVariation: 200; yVariation: 200; }
+ //acceleration: AngledDirection{angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed?
+ acceleration: PointDirection{ xVariation: 200; yVariation: 200; }
particleSize: 0
particleEndSize: 80
particleSizeVariation: 10
}
- TrailEmitter{
+ Emitter{
system: sys
particle: "meteor"
particlesPerSecond: 12
particleDuration: 5000
emitting: true
- acceleration: PointVector{ xVariation: 80; yVariation: 80; }
+ acceleration: PointDirection{ xVariation: 80; yVariation: 80; }
particleSize: 15
particleEndSize: 300
anchors.centerIn: parent
}
- SpriteParticle{
+ ImageParticle{
system: sys
particles: ["meteor"]
sprites:[Sprite{
}
}
- ColoredParticle{
+ ImageParticle{
z:0
system: sys
particles: ["exhaust"]
colorVariation: 0.2
}
- TrailEmitter{
+ Emitter{
id: trailsNormal2
system: sys
particle: "exhaust"
y: holder.y
x: holder.x
- speed: PointVector{ xVariation: 40; yVariation: 40; }
+ speed: PointDirection{ xVariation: 40; yVariation: 40; }
speedFromMovement: 16
- acceleration: PointVector{ xVariation: 10; yVariation: 10; }
+ acceleration: PointDirection{ xVariation: 10; yVariation: 10; }
particleSize: 4
particleSizeVariation: 4
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
id: root
}
}
- TrailEmitter{
+ Emitter{
particle: "stars"
system: particles
particlesPerSecond: 40
emitting: true
particleSize: 30
particleSizeVariation: 10
- speed: PointVector{ x: 220; xVariation: 40 }
+ speed: PointDirection{ x: 220; xVariation: 40 }
height: parent.height
}
- TrailEmitter{
+ Emitter{
particle: "roids"
system: particles
particlesPerSecond: 10
emitting: true
particleSize: 30
particleSizeVariation: 10
- speed: PointVector{ x: 220; xVariation: 40 }
+ speed: PointDirection{ x: 220; xVariation: 40 }
height: parent.height
}
ParticleSystem{
id: particles
anchors.fill: parent
}
- ColoredParticle{
+ ImageParticle{
id: stars
particles: ["stars"]
system: particles
color: "white"
colorVariation: 0.1
}
- SpriteParticle{
+ ImageParticle{
id: roids
particles: ["roids"]
system: particles
speedModifiesDuration: -0.1
}
}
- ColoredParticle{
+ ImageParticle{
id: shot
particles: ["shot"]
system: particles
color: "#0FF06600"
colorVariation: 0.3
}
- ColoredParticle{
+ ImageParticle{
id: engine
particles: ["engine"]
system: particles
drag.axis: Drag.XandYAxis
drag.target: ship
}
- TrailEmitter{
+ Emitter{
particle: "engine"
system: particles
particlesPerSecond: 200
particleSize: 10
particleEndSize: 4
particleSizeVariation: 4
- speed: PointVector{ x: -128; xVariation: 32 }
+ speed: PointDirection{ x: -128; xVariation: 32 }
height: parent.height
width: 20
}
- TrailEmitter{
+ Emitter{
particle: "shot"
system: particles
particlesPerSecond: 32
particleDuration: 2000
emitting: spacePressed
particleSize: 40
- speed: PointVector{ x: 256; }
+ speed: PointDirection{ x: 256; }
x: parent.width
y: parent.height/2
}
--- /dev/null
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle{
+ color: "white"
+ width: 240
+ height: 360
+ ParticleSystem{
+ id: sys
+ }
+ Emitter{
+ system:sys
+ height: parent.height
+ particlesPerSecond: 1
+ particleDuration: 12000
+ speed: PointDirection{x:20;}
+ particleSize: 64
+ }
+ ShaderEffectSource{
+ id: theSource
+ sourceItem: theItem
+ hideSource: true
+ }
+ Image{
+ id: theItem
+ source: "content/smile.png"
+ }
+
+ CustomParticle{
+ system: sys
+ //TODO: Someway that you don't have to rewrite the basics for a simple addition
+ vertexShader:"
+ attribute highp vec2 vPos;
+ attribute highp vec2 vTex;
+ attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+ attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+ attribute highp float r;
+
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+ uniform highp float timestamp;
+ uniform lowp float qt_Opacity;
+
+ varying highp vec2 fTex;
+ varying lowp float fFade;
+ varying lowp float fBlur;
+
+ void main() {
+ fTex = vTex;
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = vPos
+ - currentSize / 2. + currentSize * vTex // adjust size
+ + vVec.xy * t * vData.y // apply speed vector..
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+ gl_Position = qt_ModelViewProjectionMatrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * qt_Opacity;
+ fBlur = max(0.2 * t, t * r);
+ }
+ "
+ property variant source: theSource
+ property variant blurred: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffectItem {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(0.0, 1.0 / height)
+ property variant source: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffectItem {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(1.0 / width, 0.0)
+ property variant source: theSource
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor = 0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta);
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor = 0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta);
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform sampler2D blurred;
+ varying highp vec2 fTex;
+ varying highp float fBlur;
+ varying highp float fFade;
+ void main() {
+ gl_FragColor = mix(texture2D(source, fTex), texture2D(blurred, fTex), min(1.0,fBlur*3.0)) * fFade;
+ }"
+
+ }
+}
+
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
import "../../modelviews/listview/content" as OtherDemo
import "content/script.js" as Script
import "content"
ParticleSystem{
id: sys;
}
- TrailEmitter{
+ Emitter{
system: sys
particle: "A"
width: parent.width/2
x: parent.width/4
y:parent.height
- speed: PointVector{ y: -64; yVariation: 16 }
+ speed: PointDirection{ y: -64; yVariation: 16 }
particlesPerSecond: 1
particleDuration: 8000
}
- Drift{
+ Wander{
system: sys
- xDrift: 200
+ xVariance: 400
+ pace: 200
}
- DataParticle{
+ ModelParticle{
id: mp
z: 0
system: sys
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
import "content"
Item{
height: 240
property bool inGrid: false
ParticleSystem{ id: sys }
- TrailEmitter{
+ Emitter{
system: sys
id: burster;
emitting: false
particlesPerSecond: 1000
- particleDuration: 500
- speed: PointVector{xVariation: 400; yVariation: 400}
+ particleDuration: 50000
+ maxParticles: 100;
+ speed: PointDirection{xVariation: 400; yVariation: 400}
anchors.centerIn: parent
Timer{
interval: 1000
onTriggered: {inGrid = true;}// sys.running = false;}
}
}
- ColoredParticle{
+ ImageParticle{
system: sys
image: "../trails/content/particle.png"
color: "black"
width: 120
height: 120
}
- DataParticle{
+ ModelParticle{
system: sys
model: theModel.parts.particles
+ fade: false
}
Friction{
system: sys
- factor: 1
- }
- Stasis{
- system: sys
- targetLife: 400
+ factor: 5
}
VisualDataModel{
id: theModel
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
import "content"
Rectangle {
width: 200; height:200
model: visualModel.parts.list
}
- DataParticle{
+ ModelParticle{
x: 200; width: 200; height:200
model: visualModel.parts.grid
system: sys
id: sys
anchors.fill: parent
}
- TrailEmitter{
+ Emitter{
system: sys
width: 100
x: 50
- speed: PointVector{ y: 40 }
+ speed: PointDirection{ y: 40 }
particleDuration: 5000
particlesPerSecond: 1.6
}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
import "content/script.js" as Script
import "content"
overwrite: false
startTime: 12000//Doesn't actually work with the loading time though...
}
- TrailEmitter{
+ Emitter{
id: emitter
system: sys
height: parent.height - 132/2
x: -132/2
y: 132/2
- speed: PointVector{ x: 32; xVariation: 8 }
+ speed: PointDirection{ x: 32; xVariation: 8 }
particlesPerSecond: 0.5
particleDuration: 120000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
particle: "photos"
height: parent.height
width: 1000
}
- ColoredParticle{
+ ImageParticle{
system: sys
particles: ["fireworks"]
image: "../trails/content/star.png"
}
property Item alertItem;
function alert(){
- resetter.active = false
+ //resetter.active = false
force.active = true;
alertItem = alertDelegate.createObject(root);
alertItem.x = root.width/2 - alertItem.width/2
interval: 800
onTriggered: {
force.active = false
- resetter.active = true;
+ //resetter.active = true;
mp.take(alertItem, true);
centerEmitter.burst(1);
}
}
- Attractor{
+ PointAttractor{
id: force
system: sys
x: root.width/2
y: root.height/2
- strength: -30000
+ strength: -10000
active: false
anchors.centerIn: parent
width: parent.width/2
height: parent.height/2
particles:["photos"]
+ physics: PointAttractor.Position
}
- Reset{
- id: resetter
- system: sys
- particles:["photos"]
- }
- TrailEmitter{
+ Emitter{
id: centerEmitter
- speed: PointVector{ x: 32; xVariation: 8;}
+ speed: PointDirection{ x: 32; xVariation: 8;}
particlesPerSecond: 0.5
particleDuration: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
maxParticles: 20
//TODO: Zoom in effect
}
- TrailEmitter{
+ Emitter{
id: spawnFireworks
particle: "fireworks"
system: sys
emitting: false
particleSize: 32
particleEndSize: 8
- speed: AngleVector{ magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
- acceleration: PointVector{ y: 160 }
+ speed: AngledDirection{ magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
+ acceleration: PointDirection{ y: 160 }
}
Item{ x: -1000; y: -1000 //offscreen
Repeater{//Load them here, add to system on completed
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
-Rectangle{
- width: 360
- height: 540
- ParticleSystem{ id: particles }
- SpriteParticle{
- system: particles
- Sprite{
- name: "snow"
- source: "content/flake-01.png"
- frames: 51
- duration: 40
+Rectangle {
+ id: container
+
+ property string text: "Button"
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 20
+ smooth: true
+ property color myCol: "#999999"
+ border { width: 1; color: Qt.darker(myCol) }
+ radius: 8
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return Qt.darker(myCol)
+ else
+ return Qt.lighter(myCol)
+ }
}
+ GradientStop { position: 1.0; color: myCol }
}
- Drift{
- system: particles
- anchors.fill: parent
- xDrift: 400;
- }
- TrailEmitter{
- system: particles
- particlesPerSecond: 20
- particleDuration: 7000
- emitting: true
- speed: PointVector{ y:80; yVariation: 40; }
- acceleration: PointVector{ y: 4 }
- particleSize: 20
- particleSizeVariation: 10
- width: parent.width
- height: 100
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: "black"; font.pixelSize: 24
}
}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
+import "content"
Rectangle{
width: 360
height: 540
ParticleSystem { id: particles }
- SpriteParticle {
+ ImageParticle {
system: particles
- Sprite{
+ sprites: Sprite{
name: "snow"
source: "content/flake-01.png"
frames: 51
}
}
Wander {
+ id: wanderer
system: particles
anchors.fill: parent
- xVariance: 40;
- pace: 40;
+ xVariance: 360/(wanderer.physics+1);
+ pace: 100*(wanderer.physics+1);
}
- TrailEmitter {
+ Emitter {
system: particles
particlesPerSecond: 20
particleDuration: 7000
emitting: true
- speed: PointVector{ y:80; yVariation: 40; }
- acceleration: PointVector{ y: 4 }
+ speed: PointDirection{ y:80; yVariation: 40; }
+ acceleration: PointDirection{ y: 4 }
particleSize: 20
particleSizeVariation: 10
width: parent.width
height: 100
}
+ Row{
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ Button{
+ text:"dx/dt"
+ onClicked: wanderer.physics = Wander.Position;
+ }
+ Button{
+ text:"dv/dt"
+ onClicked: wanderer.physics = Wander.Velocity;
+ }
+ Button{
+ text:"da/dt"
+ onClicked: wanderer.physics = Wander.Acceleration;
+ }
+ }
}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.particles 2.0
-
-Rectangle{
- width: 360
- height: 540
- id: root
- ParticleSystem{ id: particles }
- SpriteParticle{
- system: particles
- sprites: Sprite{
- name: "snow"
- source: "content/flake-01.png"
- frames: 51
- duration: 40
- }
- }
- Drift{
- system: particles
- anchors.fill: parent
- xDrift: 200
- }
- SpeedLimit{
- system: particles
- anchors.fill: parent
- speedLimit: 100
- }
- TrailEmitter{
- system: particles
- particlesPerSecond: 20
- particleDuration: 7000
- emitting: true
- speed: PointVector{ y:80; yVariation: 40; }
- acceleration: PointVector{ y: 4 }
- particleSize: 20
- particleSizeVariation: 10
- width: parent.width
- height: 40
- }
-}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
import "content/helpers.js" as Helpers
Rectangle{
property bool fakeMoving: false
property real fakeMovementDir: 0
- TrailEmitter{
+ Emitter{
particle: "stars2"
system: background
particlesPerSecond: 60
anchors.fill: parent
}
ParticleSystem{ id: background }
- ColoredParticle{
+ ImageParticle{
particles: ["stars2"]
system: background
anchors.fill: parent
ParticleSystem{ id: foreground }
- ColoredParticle{
+ ImageParticle{
particles: ["stars"]
anchors.fill: parent
system: foreground
color: "white"
colorVariation: 0.1
}
- ColoredParticle{
+ ImageParticle{
particles: ["shot"]
anchors.fill: parent
system: foreground
color: "orange"
colorVariation: 0.3
}
- ColoredParticle{
+ ImageParticle{
id: engine
particles: ["engine"]
anchors.fill: parent
colorVariation: 0.2
}
- SpriteParticle{
+ ImageParticle{
particles: ["powerups"]
anchors.fill: parent
system: foreground
- Sprite{
+ sprites:[Sprite{
name: "norm"
source: "content/powerupScore.png"
frames: 35
duration: 40
to: {"norm":1, "got":0}
- }
+ },
Sprite{
name: "got"
source: "content/powerupScore_got.png"
frames: 22
duration: 40
to: {"null":1}
- }
+ },
Sprite{
name: "null"
source: "content/powerupScore_gone.png"
frames: 1
duration: 1000
}
+ ]
}
SpriteGoal{
x: rocket.x - 30
onAffected: if(!gameOver) score += 1000
system: foreground
}
- GravitationalSingularity{
+ PointAttractor{
id: gs1; x: vorteX; y: vorteY; strength: 800000;
+ proportionalToDistance: PointAttractor.Quadratic;
system: foreground
}
Kill{
system: foreground
}
- GravitationalSingularity{
+ PointAttractor{
id: gs2; x: vorteX2; y: vorteY2; strength: 800000;
+ proportionalToDistance: PointAttractor.Quadratic;
system: foreground
}
Kill{
system: foreground
}
- GravitationalSingularity{
+ PointAttractor{
id: gs3; x: vorteX3; y: vorteY3; strength: 800000;
+ proportionalToDistance: PointAttractor.Quadratic;
system: foreground
}
Kill{
height: holeSize * 2
system: foreground
}
- GravitationalSingularity{
+ PointAttractor{
id: gs4; x: vorteX4; y: vorteY4; strength: 800000;
+ proportionalToDistance: PointAttractor.Quadratic;
system: foreground
}
Kill{
height: holeSize * 2
system: foreground
}
- TrailEmitter{
+ Emitter{
particle: "powerups"
system: foreground
particlesPerSecond: 1
particleSizeVariation: 10
anchors.fill: parent
}
- TrailEmitter{
+ Emitter{
particle: "stars"
system: foreground
particlesPerSecond: 40
drag.axis: Drag.XandYAxis
drag.target: rocket
},
- TrailEmitter{
+ Emitter{
system: foreground
particle: "engine"
particlesPerSecond: 100
particleSize: 10
particleEndSize: 4
particleSizeVariation: 4
- speed: PointVector{
+ speed: PointDirection{
x: -128 * Math.cos(rocket.rotation * (Math.PI / 180))
y: -128 * Math.sin(rocket.rotation * (Math.PI / 180))
}
width: 4
},
- TrailEmitter{
+ Emitter{
system: foreground
particle: "shot"
particlesPerSecond: 16
particleDuration: 1600
emitting: !gameOver && shoot
particleSize: 40
- speed: PointVector{
+ speed: PointDirection{
x: 256 * Math.cos(rocket.rotation * (Math.PI / 180))
y: 256 * Math.sin(rocket.rotation * (Math.PI / 180))
}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
id: root
ParticleSystem{
id: sys
}
- ColoredParticle{
+ ImageParticle{
system: sys
image: "content/particle.png"
color: "white"
}
Component{
id: emitterComp
- TrailEmitter{
+ Emitter{
id: container
- TrailEmitter{
+ Emitter{
id: emitMore
system: sys
emitting: true
particleDuration: 600
particleSize: 16
particleEndSize: 8
- speed: AngleVector{angleVariation:360; magnitude: 60}
+ speed: AngledDirection{angleVariation:360; magnitude: 60}
}
property int life: 2600
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle {
id: root
}
/*
- ColoredParticle{
+ ImageParticle{
id: fireball
anchors.fill: parent
particles: ["E"]
color: "#00ff400f"
}
*/
- ColoredParticle{
+ ImageParticle{
id: smoke
system: particles
anchors.fill: parent
colorVariation: 0
color: "#00111111"
}
- ColoredParticle{
+ ImageParticle{
id: flame
anchors.fill: parent
system: particles
colorVariation: 0.1
color: "#00ff400f"
}
- TrailEmitter{
+ Emitter{
id: fire
system: particles
particle: "C"
particlesPerSecond: 350
particleDuration: 3500
- acceleration: PointVector{ y: -17; xVariation: 3 }
- speed: PointVector{xVariation: 3}
+ acceleration: PointDirection{ y: -17; xVariation: 3 }
+ speed: PointDirection{xVariation: 3}
particleSize: 24
particleSizeVariation: 8
particlesPerParticlePerSecond: 1
particleDuration: 2000
- speed: PointVector{y:-17*6; yVariation: -17; xVariation: 3}
- acceleration: PointVector{xVariation: 3}
+ speed: PointDirection{y:-17*6; yVariation: -17; xVariation: 3}
+ acceleration: PointDirection{xVariation: 3}
particleSize: 36
particleSizeVariation: 8
emissionWidth: 16
emissionHeight: 16
- speed: PointVector{yVariation: 16; xVariation: 16}
- acceleration: PointVector{y: -16}
+ speed: PointDirection{yVariation: 16; xVariation: 16}
+ acceleration: PointDirection{y: -16}
particleSize: 24
particleSizeVariation: 8
particleEndSize: 8
}
- TrailEmitter{
+ Emitter{
id: balls
system: particles
particle: "E"
particlesPerSecond: 2
particleDuration: 7000
- speed: PointVector{y:-17*4*2; xVariation: 6*6}
- acceleration: PointVector{y: 17*2; xVariation: 6*6}
+ speed: PointDirection{y:-17*4*2; xVariation: 6*6}
+ acceleration: PointDirection{y: 17*2; xVariation: 6*6}
particleSize: 12
particleSizeVariation: 4
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
id: root
id: sys
startTime: 4000
}
- TrailEmitter{
+ Emitter{
system: sys
y:root.height + 20
width: root.width
particlesPerSecond: 200
particleDuration: 4000
- speed: PointVector{ y: -120; }
+ speed: PointDirection{ y: -120; }
}
- SpriteParticle{
+ ImageParticle{
system: sys
visible: !cloneMode
- Sprite{
- source: "content/particle2.png"
- }
+ image: "content/particle2.png"
}
- SpriteParticle{
+ ImageParticle{
system: sys
visible: cloneMode
z: 0
- Sprite{
- source: "content/particle3.png"
- }
+ image: "content/particle3.png"
}
- SpriteParticle{
+ ImageParticle{
system: sys
clip: true
visible: cloneMode
height: 240
width: root.width
z: 1
- Sprite{
- source: "content/particle.png"
- }
+ image: "content/particle.png"
}
}
// highlight bar is moved between items. + Particles.
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
import "content"
Rectangle {
width: 200; height: 300
color: "black"
ParticleSystem{ id: particles }
- ColoredParticle{
+ ImageParticle{
anchors.fill: parent
system: particles
z: 10
y: listView.currentItem.y;
//Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
Behavior on y { NumberAnimation {id: anim} }
- TrailEmitter{
+ Emitter{
anchors.fill: parent
system: particles;
emitting: anim.running
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
color: "black"
width: 360
height: 540
ParticleSystem{ id: sys }
- ColoredParticle{
+ ImageParticle{
system: sys
id: cp
image: "content/particle.png"
colorVariation: 0.4
color: "#000000FF"
}
- TrailEmitter{
+ Emitter{
//burst on click
id: bursty
system: sys
particlesPerSecond: 16000
particleDuration: 1000
maxParticles: 4000
- acceleration: AngleVector{angleVariation: 360; magnitude: 360; }
+ acceleration: AngledDirection{angleVariation: 360; magnitude: 360; }
particleSize: 8
particleEndSize: 16
particleSizeVariation: 4
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
id: root
id: particles
startTime: 2000
}
- ColoredParticle{
+ ImageParticle{
particles: ["center","edge"]
anchors.fill: parent
system: particles
colorVariation: 0.1
color: "#009999FF"
}
- TrailEmitter{
+ Emitter{
anchors.fill: parent
particle: "center"
system: particles
particleSize: 20
particleSizeVariation: 2
particleEndSize: 0
- shape: Ellipse{fill: false}
- speed: DirectedVector{
+ shape: EllipseShape{fill: false}
+ speed: TargetedDirection{
targetX: root.width/2
targetY: root.height/2
proportionalMagnitude: true
magnitude: 0.5
}
}
- TrailEmitter{
+ Emitter{
anchors.fill: parent
particle: "edge"
system: particles
particleSize: 20
particleSizeVariation: 2
particleEndSize: 0
- shape: Ellipse{fill: false}
- speed: DirectedVector{
+ shape: EllipseShape{fill: false}
+ speed: TargetedDirection{
targetX: root.width/2
targetY: root.height/2
proportionalMagnitude: true
magnitude: 0.1
magnitudeVariation: 0.1
}
- acceleration: DirectedVector{
+ acceleration: TargetedDirection{
targetX: root.width/2
targetY: root.height/2
targetVariation: 200
**
****************************************************************************/
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
import QtQuick 2.0
Rectangle {
color: "black"
ParticleSystem{ id: particles }
- ColoredParticle{
+ ImageParticle{
system: particles
colorVariation: 0.5
alpha: 0
colorTable: "content/colortable.png"
sizeTable: "content/colortable.png"
}
- TrailEmitter{
+ Emitter{
system: particles
particlesPerSecond: 500
particleDuration: 2000
speedFromMovement: 20
- speed: PointVector{ xVariation: 5; yVariation: 5;}
- acceleration: PointVector{ xVariation: 5; yVariation: 5;}
+ speed: PointDirection{ xVariation: 5; yVariation: 5;}
+ acceleration: PointDirection{ xVariation: 5; yVariation: 5;}
particleSize: 16
//particleEndSize: 8
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
width: 360
id: particles
running: false
}
- ColoredParticle{
+ ImageParticle{
anchors.fill: parent
system: particles
image: "content/star.png"
alpha: 0
colorVariation: 0.6
}
- TrailEmitter{
+ Emitter{
anchors.fill: parent
system: particles
particlesPerSecond: 2000
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.particles 2.0 as QLP
-
-Rectangle{
- width: 200
- height: 200
- color: "black"
- QLP.ParticleSystem{ id: ps }
- QLP.ColoredParticle{
- system: ps
- particles: ["star1","star2"]
- anchors.fill: parent
- clip: true
- image: "content/star.png"
- }
- QLP.Swarm{
- system: ps
- leaders: ["star2"];
- anchors.fill: parent
- strength: 128
- }
- QLP.TrailEmitter{
- anchors.fill: parent
- system: ps
- particle: "star1"
- particlesPerSecond: 100
- particleDuration: 2000
- }
- QLP.TrailEmitter{
- anchors.fill: parent
- system: ps
- particle: "star2"
- particlesPerSecond: 0.4
- particleDuration: 10000
- particleSize: 64
- particleEndSize: 32
- }
-}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
color: "black"
width: 360
height: 540
ParticleSystem{ id: sys }
- ColoredParticle{
+ ImageParticle{
system: sys
id: cp
image: "content/particle.png"
color: "#00FFFFFF"
colorVariation: 0.4
}
- TrailEmitter{
+ Emitter{
//burst on click
id: bursty
system: sys
emitting: false
particlesPerSecond: 2000
particleDuration: 500
- acceleration: AngleVector{ angle: 90; angleVariation: 360; magnitude: 640; }
+ acceleration: AngledDirection{ angle: 90; angleVariation: 360; magnitude: 640; }
particleSize: 8
particleEndSize: 16
particleSizeVariation: 4
}
- TrailEmitter{
+ Emitter{
system: sys
speedFromMovement: 4.0
emitting: ma.pressed
y: ma.mouseY
particlesPerSecond: 400
particleDuration: 2000
- acceleration: AngleVector{ angle: 90; angleVariation: 22; magnitude: 32; }
+ acceleration: AngledDirection{ angle: 90; angleVariation: 22; magnitude: 32; }
particleSize: 8
particleEndSize: 16
particleSizeVariation: 8
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle{
width: 360
frequency: 64
gridSize: 16
}
- ColoredParticle{
+ ImageParticle{
particles: ["smoke"]
system: ps
image: "content/particle.png"
color: "#11111111"
colorVariation: 0
}
- ColoredParticle{
+ ImageParticle{
particles: ["flame"]
system: ps
image: "content/particle.png"
color: "#11ff400f"
colorVariation: 0.1
}
- TrailEmitter{
+ Emitter{
anchors.centerIn: parent
system: ps
particle: "flame"
particleSize: 20
particleEndSize: 10
particleSizeVariation: 10
- acceleration: PointVector{ y: -40 }
- speed: AngleVector{ angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
+ acceleration: PointDirection{ y: -40 }
+ speed: AngledDirection{ angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
}
FollowEmitter{
id: smoke1
particleSize: 16
particleEndSize: 8
particleSizeVariation: 8
- acceleration: PointVector{ y: -40 }
- speed: AngleVector{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ acceleration: PointDirection{ y: -40 }
+ speed: AngledDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
}
FollowEmitter{
id: smoke2
particleSize: 36
particleEndSize: 24
particleSizeVariation: 8
- acceleration: PointVector{ y: -40 }
- speed: AngleVector{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ acceleration: PointDirection{ y: -40 }
+ speed: AngledDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
}
}
****************************************************************************/
import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
Rectangle {
}
ParticleSystem{ id: sys1 }
- ColoredParticle{
+ ImageParticle{
system: sys1
image: "content/particle.png"
color: "cyan"
}
colorVariation: 0.3
}
- TrailEmitter{
+ Emitter{
id: trailsNormal
system: sys1
y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
- speed: PointVector{xVariation: 4; yVariation: 4;}
- acceleration: PointVector{xVariation: 10; yVariation: 10;}
+ speed: PointDirection{xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection{xVariation: 10; yVariation: 10;}
speedFromMovement: 8
particleSize: 8
particleSizeVariation: 4
}
ParticleSystem { id: sys2 }
- ColoredParticle{
+ ImageParticle{
color: "cyan"
system: sys2
alpha: 0
colorVariation: 0.5
image: "content/star.png"
}
- TrailEmitter{
+ Emitter{
id: trailsStars
system: sys2
y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
- speed: PointVector{xVariation: 4; yVariation: 4;}
- acceleration: PointVector{xVariation: 10; yVariation: 10;}
+ speed: PointDirection{xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection{xVariation: 10; yVariation: 10;}
speedFromMovement: 8
particleSize: 22
particleSizeVariation: 4
}
ParticleSystem { id: sys3; }
- ColoredParticle{
+ ImageParticle{
image: "content/particle.png"
system: sys3
color: "orange"
colorVariation: 0.2
}
- TrailEmitter{
+ Emitter{
id: trailsNormal2
system: sys3
speedFromMovement: 16
- speed: PointVector{xVariation: 4; yVariation: 4;}
- acceleration: PointVector{xVariation: 10; yVariation: 10;}
+ speed: PointDirection{xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection{xVariation: 10; yVariation: 10;}
particleSize: 12
particleSizeVariation: 4
}
ParticleSystem { id: sys4; }
- ColoredParticle{
+ ImageParticle{
system: sys4
image: "content/star.png"
color: "green"
colorVariation: 0.5
}
- TrailEmitter{
+ Emitter{
id: trailsStars2
system: sys4
x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx
speedFromMovement: 16
- speed: PointVector{xVariation: 2; yVariation: 2;}
- acceleration: PointVector{xVariation: 10; yVariation: 10;}
+ speed: PointDirection{xVariation: 2; yVariation: 2;}
+ acceleration: PointDirection{xVariation: 10; yVariation: 10;}
particleSize: 22
particleSizeVariation: 4
QPointF QSGMaskExtruder::extrude(const QRectF &r)
{
ensureInitialized(r);
- if(!m_mask.count())
+ if(!m_mask.count() || m_img.isNull())
return r.topLeft();
const QPointF p = m_mask[rand() % m_mask.count()];
//### Should random sub-pixel positioning be added?
bool QSGMaskExtruder::contains(const QRectF &bounds, const QPointF &point)
{
ensureInitialized(bounds);//###Current usage patterns WILL lead to different bounds/r calls. Separate list?
+ if(m_img.isNull())
+ return false;
QPoint p = point.toPoint() - bounds.topLeft().toPoint();
return m_img.rect().contains(p) && (bool)m_img.pixelIndex(p);
}
void QSGMaskExtruder::ensureInitialized(const QRectF &r)
{
if(m_lastWidth == r.width() && m_lastHeight == r.height())
- return;
+ return;//Same as before
m_lastWidth = r.width();
m_lastHeight = r.height();
+ m_img = QImage();
m_mask.clear();
if(m_source.isEmpty())
return;
m_img = QImage(m_source.toLocalFile());
+ if(m_img.isNull()){
+ qWarning() << "MaskShape: Cannot load" << qPrintable(m_source.toLocalFile());
+ return;
+ }
m_img = m_img.createAlphaMask();
m_img = m_img.convertToFormat(QImage::Format_Mono);//Else LSB, but I think that's easier
m_img = m_img.scaled(r.size().toSize());//TODO: Do they need aspect ratio stuff? Or tiling?
QT_MODULE(Declarative)
-
class QSGParticleAffector : public QSGItem
{
Q_OBJECT
QT_BEGIN_NAMESPACE
QSGPointAttractorAffector::QSGPointAttractorAffector(QSGItem *parent) :
QSGParticleAffector(parent), m_strength(0.0), m_x(0), m_y(0)
+ , m_physics(Velocity), m_proportionalToDistance(Linear)
{
}
{
if(m_strength == 0.0)
return false;
- qreal dx = m_x - d->curX();
- qreal dy = m_y - d->curY();
+ qreal dx = m_y - d->curX();
+ qreal dy = m_x - d->curY();
qreal r = sqrt((dx*dx) + (dy*dy));
qreal theta = atan2(dy,dx);
- qreal ds = (m_strength / r) * dt;
+ qreal ds = 0;
+ switch(m_proportionalToDistance){
+ case Quadratic:
+ ds = (m_strength / qMax(1.,r*r)) * dt;
+ break;
+ case Linear://also default
+ default:
+ ds = (m_strength / qMax(1.,r)) * dt;
+ }
dx = ds * cos(theta);
dy = ds * sin(theta);
- d->setInstantaneousSX(d->pv.sx + dx);
- d->setInstantaneousSY(d->pv.sy + dy);
+ switch(m_physics){
+ case Position:
+ d->pv.x = (d->pv.x + dx);
+ d->pv.y = (d->pv.y + dy);
+ break;
+ case Acceleration:
+ d->setInstantaneousAX(d->pv.ax + dx);
+ d->setInstantaneousAY(d->pv.ay + dy);
+ break;
+ case Velocity: //also default
+ default:
+ d->setInstantaneousSX(d->pv.sx + dx);
+ d->setInstantaneousSY(d->pv.sy + dy);
+ }
+
return true;
}
QT_END_NAMESPACE
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
+ Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
+ Q_PROPERTY(Proportion proportionalToDistance READ proportionalToDistance WRITE setProportionalToDistance NOTIFY proportionalToDistanceChanged)
+ Q_ENUMS(PhysicsAffects)
+ Q_ENUMS(Proportion)
+
public:
+ enum Proportion{
+ Linear,
+ Quadratic
+ };
+
+ enum PhysicsAffects {
+ Position,
+ Velocity,
+ Acceleration
+ };
+
explicit QSGPointAttractorAffector(QSGItem *parent = 0);
qreal strength() const
return m_y;
}
+ PhysicsAffects physics() const
+ {
+ return m_physics;
+ }
+
+ Proportion proportionalToDistance() const
+ {
+ return m_proportionalToDistance;
+ }
+
signals:
void strengthChanged(qreal arg);
void yChanged(qreal arg);
+ void physicsChanged(PhysicsAffects arg);
+
+ void proportionalToDistanceChanged(Proportion arg);
+
public slots:
void setStrength(qreal arg)
{
emit yChanged(arg);
}
}
+void setPhysics(PhysicsAffects arg)
+{
+ if (m_physics != arg) {
+ m_physics = arg;
+ emit physicsChanged(arg);
+ }
+}
+
+void setProportionalToDistance(Proportion arg)
+{
+ if (m_proportionalToDistance != arg) {
+ m_proportionalToDistance = arg;
+ emit proportionalToDistanceChanged(arg);
+ }
+}
+
protected:
virtual bool affectParticle(QSGParticleData *d, qreal dt);
private:
qreal m_strength;
qreal m_x;
qreal m_y;
+PhysicsAffects m_physics;
+Proportion m_proportionalToDistance;
};
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
QSGWanderAffector::QSGWanderAffector(QSGItem *parent) :
- QSGParticleAffector(parent)
+ QSGParticleAffector(parent), m_xVariance(0), m_yVariance(0), m_pace(0)
+ , m_physics(Velocity)
{
m_needsReset = true;
}
bool QSGWanderAffector::affectParticle(QSGParticleData* data, qreal dt)
{
+ /*TODO: Add a mode which does basically this - picking a direction, going in it (random speed) and then going back
WanderData* d = getData(data->systemIndex);
if (m_xVariance != 0.) {
if ((d->x_vel > d->x_peak && d->x_var > 0.0) || (d->x_vel < -d->x_peak && d->x_var < 0.0)) {
p->y += dy;
return true;
+ */
+ qreal dx = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
+ qreal dy = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
+ qreal newX, newY;
+ switch(m_physics){
+ case Position:
+ newX = data->curX() + dx;
+ if(m_xVariance > qAbs(newX) )
+ data->pv.x += dx;
+ newY = data->curY() + dy;
+ if(m_yVariance > qAbs(newY) )
+ data->pv.y += dy;
+ break;
+ default:
+ case Velocity:
+ newX = data->curSX() + dx;
+ if(m_xVariance > qAbs(newX) )
+ data->setInstantaneousSX(newX);
+ newY = data->curSY() + dy;
+ if(m_yVariance > qAbs(newY) )
+ data->setInstantaneousSY(newY);
+ break;
+ case Acceleration:
+ newX = data->pv.ax + dx;
+ if(m_xVariance > qAbs(newX) )
+ data->setInstantaneousAX(newX);
+ newY = data->pv.ay + dy;
+ if(m_yVariance > qAbs(newY) )
+ data->setInstantaneousAY(newY);
+ break;
+ }
+ return true;
}
QT_END_NAMESPACE
class QSGWanderAffector : public QSGParticleAffector
{
Q_OBJECT
+ Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
Q_PROPERTY(qreal xVariance READ xVariance WRITE setXVariance NOTIFY xVarianceChanged)
Q_PROPERTY(qreal yVariance READ yVariance WRITE setYVariance NOTIFY yVarianceChanged)
- Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
+ Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
+ Q_ENUMS(PhysicsAffects)
public:
+ enum PhysicsAffects {
+ Position,
+ Velocity,
+ Acceleration
+ };
+
explicit QSGWanderAffector(QSGItem *parent = 0);
~QSGWanderAffector();
virtual void reset(int systemIdx);
{
return m_pace;
}
+
+ PhysicsAffects physics() const
+ {
+ return m_physics;
+ }
+
protected:
virtual bool affectParticle(QSGParticleData *d, qreal dt);
signals:
void paceChanged(qreal arg);
+
+ void physicsChanged(PhysicsAffects arg);
+
public slots:
void setXVariance(qreal arg)
{
}
}
+
+void setPhysics(PhysicsAffects arg)
+{
+ if (m_physics != arg) {
+ m_physics = arg;
+ emit physicsChanged(arg);
+ }
+}
+
private:
WanderData* getData(int idx);
QHash<int, WanderData*> m_wanderData;
qreal m_xVariance;
qreal m_yVariance;
qreal m_pace;
+ PhysicsAffects m_physics;
};
QT_END_NAMESPACE