From 025894f802fabc479d308eb32635c9703046d239 Mon Sep 17 00:00:00 2001 From: Oliver Eftevaag Date: Mon, 8 Nov 2021 16:46:32 +0100 Subject: Particle examples: use new cmake api The particles directory contains 5 different examples and a shared directory with some images files. This patch changes the examples to use qt_add_qml_module() in the CMakeLists.txt project files, and changes the .qrc files to directory reference the files needed by the individual projects, which removes the need for images.qrc. (The .pro files still reference the shared.qrc file) The "content" directories located in the different example projects, have been removed, and the containing files have simply been moved to the parent directories instead. Some unused files in the itemparticle example have also been deleted. This example looks very outdated and should ideally be improved, or perhaps simply removed, but I decided to leave it for now. Task-number: QTBUG-98130 Change-Id: If05986b4347814715bca50b8d3f6a5cddbf9ced4 Reviewed-by: Ulf Hermann (cherry picked from commit aa4897e017c027c935cd349450bf787393ce5552) --- examples/quick/particles/affectors/CMakeLists.txt | 143 +++------ examples/quick/particles/affectors/GreyButton.qml | 91 ++++++ examples/quick/particles/affectors/affectors.pro | 1 - examples/quick/particles/affectors/affectors.qml | 28 +- examples/quick/particles/affectors/affectors.qrc | 39 ++- examples/quick/particles/affectors/age.qml | 109 +++++++ examples/quick/particles/affectors/attractor.qml | 200 +++++++++++++ .../particles/affectors/content/GreyButton.qml | 91 ------ examples/quick/particles/affectors/content/age.qml | 109 ------- .../particles/affectors/content/attractor.qml | 200 ------------- .../particles/affectors/content/customaffector.qml | 156 ---------- .../quick/particles/affectors/content/friction.qml | 121 -------- .../quick/particles/affectors/content/gravity.qml | 115 -------- .../particles/affectors/content/groupgoal.qml | 213 -------------- .../quick/particles/affectors/content/move.qml | 157 ---------- .../particles/affectors/content/spritegoal.qml | 222 -------------- .../particles/affectors/content/turbulence.qml | 142 --------- .../quick/particles/affectors/content/wander.qml | 107 ------- .../quick/particles/affectors/customaffector.qml | 156 ++++++++++ .../particles/affectors/doc/src/affectors.qdoc | 34 +-- examples/quick/particles/affectors/friction.qml | 121 ++++++++ examples/quick/particles/affectors/gravity.qml | 115 ++++++++ examples/quick/particles/affectors/groupgoal.qml | 213 ++++++++++++++ .../quick/particles/affectors/images/_explo.png | Bin 0 -> 81528 bytes .../affectors/images/backgroundLeaves.jpg | Bin 0 -> 78665 bytes .../quick/particles/affectors/images/candle.png | Bin 0 -> 1348 bytes .../particles/affectors/images/finalfrontier.png | Bin 0 -> 695061 bytes .../quick/particles/affectors/images/matchmask.png | Bin 0 -> 2369 bytes .../quick/particles/affectors/images/meteor.png | Bin 0 -> 83169 bytes .../quick/particles/affectors/images/nullRock.png | Bin 0 -> 140 bytes .../quick/particles/affectors/images/particleA.png | Bin 0 -> 870 bytes .../quick/particles/affectors/images/realLeaf1.png | Bin 0 -> 15625 bytes .../quick/particles/affectors/images/realLeaf2.png | Bin 0 -> 13660 bytes .../quick/particles/affectors/images/realLeaf3.png | Bin 0 -> 23809 bytes .../quick/particles/affectors/images/realLeaf4.png | Bin 0 -> 23655 bytes .../quick/particles/affectors/images/rocket.png | Bin 0 -> 7315 bytes .../quick/particles/affectors/images/rocket2.png | Bin 0 -> 1918 bytes .../quick/particles/affectors/images/snowflake.png | Bin 0 -> 189327 bytes examples/quick/particles/affectors/main.cpp | 2 +- examples/quick/particles/affectors/move.qml | 157 ++++++++++ examples/quick/particles/affectors/spritegoal.qml | 222 ++++++++++++++ examples/quick/particles/affectors/turbulence.qml | 142 +++++++++ examples/quick/particles/affectors/wander.qml | 107 +++++++ examples/quick/particles/emitters/CMakeLists.txt | 126 ++------ .../quick/particles/emitters/burstandpulse.qml | 122 ++++++++ .../particles/emitters/content/burstandpulse.qml | 122 -------- .../particles/emitters/content/customemitter.qml | 106 ------- .../quick/particles/emitters/content/emitmask.qml | 84 ------ .../particles/emitters/content/maximumemitted.qml | 92 ------ .../emitters/content/shapeanddirection.qml | 122 -------- .../particles/emitters/content/trailemitter.qml | 186 ------------ .../emitters/content/velocityfrommotion.qml | 322 --------------------- .../quick/particles/emitters/customemitter.qml | 106 +++++++ .../quick/particles/emitters/doc/src/emitters.qdoc | 12 +- examples/quick/particles/emitters/emitmask.qml | 84 ++++++ examples/quick/particles/emitters/emitters.pro | 1 - examples/quick/particles/emitters/emitters.qml | 22 +- examples/quick/particles/emitters/emitters.qrc | 18 +- .../quick/particles/emitters/images/portal_bg.png | Bin 0 -> 96858 bytes .../particles/emitters/images/starfish_mask.png | Bin 0 -> 7403 bytes examples/quick/particles/emitters/main.cpp | 2 +- .../quick/particles/emitters/maximumemitted.qml | 92 ++++++ .../quick/particles/emitters/shapeanddirection.qml | 122 ++++++++ examples/quick/particles/emitters/trailemitter.qml | 186 ++++++++++++ .../particles/emitters/velocityfrommotion.qml | 322 +++++++++++++++++++++ .../quick/particles/imageparticle/CMakeLists.txt | 132 ++------- .../quick/particles/imageparticle/allatonce.qml | 110 +++++++ examples/quick/particles/imageparticle/colored.qml | 98 +++++++ .../quick/particles/imageparticle/colortable.qml | 96 ++++++ .../particles/imageparticle/content/allatonce.qml | 110 ------- .../particles/imageparticle/content/colored.qml | 98 ------- .../particles/imageparticle/content/colortable.qml | 96 ------ .../imageparticle/content/deformation.qml | 135 --------- .../particles/imageparticle/content/rotation.qml | 83 ------ .../particles/imageparticle/content/sharing.qml | 217 -------------- .../particles/imageparticle/content/sprites.qml | 126 -------- .../quick/particles/imageparticle/deformation.qml | 135 +++++++++ .../imageparticle/doc/src/imageparticle.qdoc | 14 +- .../particles/imageparticle/imageparticle.pro | 1 - .../particles/imageparticle/imageparticle.qml | 20 +- .../particles/imageparticle/imageparticle.qrc | 24 +- .../particles/imageparticle/images/bear_tiles.png | Bin 0 -> 40349 bytes .../particles/imageparticle/images/colortable.png | Bin 0 -> 571 bytes .../particles/imageparticle/images/flower.png | Bin 0 -> 4683 bytes .../particles/imageparticle/images/starfish_0.png | Bin 0 -> 15972 bytes .../particles/imageparticle/images/starfish_1.png | Bin 0 -> 15746 bytes .../particles/imageparticle/images/starfish_2.png | Bin 0 -> 16067 bytes .../particles/imageparticle/images/starfish_3.png | Bin 0 -> 16201 bytes .../particles/imageparticle/images/starfish_4.png | Bin 0 -> 14698 bytes examples/quick/particles/imageparticle/main.cpp | 2 +- .../quick/particles/imageparticle/rotation.qml | 83 ++++++ examples/quick/particles/imageparticle/sharing.qml | 217 ++++++++++++++ examples/quick/particles/imageparticle/sprites.qml | 126 ++++++++ examples/quick/particles/images.qrc | 35 --- examples/quick/particles/images/_explo.png | Bin 81528 -> 0 bytes .../quick/particles/images/backgroundLeaves.jpg | Bin 78665 -> 0 bytes examples/quick/particles/images/bear_tiles.png | Bin 40349 -> 0 bytes examples/quick/particles/images/candle.png | Bin 1348 -> 0 bytes examples/quick/particles/images/colortable.png | Bin 571 -> 0 bytes examples/quick/particles/images/finalfrontier.png | Bin 695061 -> 0 bytes examples/quick/particles/images/flower.png | Bin 4683 -> 0 bytes examples/quick/particles/images/matchmask.png | Bin 2369 -> 0 bytes examples/quick/particles/images/meteor.png | Bin 83169 -> 0 bytes examples/quick/particles/images/meteor_explo.png | Bin 219946 -> 0 bytes examples/quick/particles/images/meteors.png | Bin 132137 -> 0 bytes examples/quick/particles/images/nullRock.png | Bin 140 -> 0 bytes examples/quick/particles/images/particle2.png | Bin 1073 -> 0 bytes examples/quick/particles/images/particle3.png | Bin 574 -> 0 bytes examples/quick/particles/images/particleA.png | Bin 870 -> 0 bytes examples/quick/particles/images/portal_bg.png | Bin 96858 -> 0 bytes examples/quick/particles/images/realLeaf1.png | Bin 15625 -> 0 bytes examples/quick/particles/images/realLeaf2.png | Bin 13660 -> 0 bytes examples/quick/particles/images/realLeaf3.png | Bin 23809 -> 0 bytes examples/quick/particles/images/realLeaf4.png | Bin 23655 -> 0 bytes examples/quick/particles/images/rocket.png | Bin 7315 -> 0 bytes examples/quick/particles/images/rocket2.png | Bin 1918 -> 0 bytes examples/quick/particles/images/sizeInOut.png | Bin 132 -> 0 bytes examples/quick/particles/images/snowflake.png | Bin 189327 -> 0 bytes examples/quick/particles/images/sparkleSize.png | Bin 378 -> 0 bytes examples/quick/particles/images/starfish_0.png | Bin 15972 -> 0 bytes examples/quick/particles/images/starfish_1.png | Bin 15746 -> 0 bytes examples/quick/particles/images/starfish_2.png | Bin 16067 -> 0 bytes examples/quick/particles/images/starfish_3.png | Bin 16201 -> 0 bytes examples/quick/particles/images/starfish_4.png | Bin 14698 -> 0 bytes examples/quick/particles/images/starfish_mask.png | Bin 7403 -> 0 bytes .../quick/particles/itemparticle/CMakeLists.txt | 125 ++------ .../particles/itemparticle/content/Delegate.qml | 98 ------- .../particles/itemparticle/content/Delegate2.qml | 89 ------ .../itemparticle/content/ExpandingDelegate.qml | 215 -------------- .../particles/itemparticle/content/bubble.png | Bin 2347 -> 0 bytes .../quick/particles/itemparticle/content/script.js | 27 -- .../quick/particles/itemparticle/delegates.qml | 6 +- .../quick/particles/itemparticle/images/rocket.png | Bin 0 -> 7315 bytes .../quick/particles/itemparticle/itemparticle.pro | 6 +- .../quick/particles/itemparticle/itemparticle.qml | 309 ++++++++++++++++++++ .../quick/particles/itemparticle/itemparticle.qrc | 8 + examples/quick/particles/itemparticle/main.cpp | 2 +- .../quick/particles/itemparticle/particleview.qml | 309 -------------------- examples/quick/particles/itemparticle/script.js | 27 ++ examples/quick/particles/particles.pro | 3 - examples/quick/particles/system/CMakeLists.txt | 121 ++------ .../particles/system/content/dynamiccomparison.qml | 149 ---------- .../particles/system/content/dynamicemitters.qml | 150 ---------- .../particles/system/content/multiplepainters.qml | 106 ------- .../quick/particles/system/content/startstop.qml | 96 ------ .../particles/system/content/timedgroupchanges.qml | 137 --------- .../quick/particles/system/doc/src/system.qdoc | 10 +- .../quick/particles/system/dynamiccomparison.qml | 149 ++++++++++ .../quick/particles/system/dynamicemitters.qml | 150 ++++++++++ .../quick/particles/system/images/particle2.png | Bin 0 -> 1073 bytes .../quick/particles/system/images/particle3.png | Bin 0 -> 574 bytes .../quick/particles/system/images/sparkleSize.png | Bin 0 -> 378 bytes examples/quick/particles/system/main.cpp | 2 +- .../quick/particles/system/multiplepainters.qml | 106 +++++++ examples/quick/particles/system/startstop.qml | 96 ++++++ examples/quick/particles/system/system.pro | 1 - examples/quick/particles/system/system.qml | 18 +- examples/quick/particles/system/system.qrc | 15 +- .../quick/particles/system/timedgroupchanges.qml | 137 +++++++++ 159 files changed, 4809 insertions(+), 5578 deletions(-) create mode 100644 examples/quick/particles/affectors/GreyButton.qml create mode 100644 examples/quick/particles/affectors/age.qml create mode 100644 examples/quick/particles/affectors/attractor.qml delete mode 100644 examples/quick/particles/affectors/content/GreyButton.qml delete mode 100644 examples/quick/particles/affectors/content/age.qml delete mode 100644 examples/quick/particles/affectors/content/attractor.qml delete mode 100644 examples/quick/particles/affectors/content/customaffector.qml delete mode 100644 examples/quick/particles/affectors/content/friction.qml delete mode 100644 examples/quick/particles/affectors/content/gravity.qml delete mode 100644 examples/quick/particles/affectors/content/groupgoal.qml delete mode 100644 examples/quick/particles/affectors/content/move.qml delete mode 100644 examples/quick/particles/affectors/content/spritegoal.qml delete mode 100644 examples/quick/particles/affectors/content/turbulence.qml delete mode 100644 examples/quick/particles/affectors/content/wander.qml create mode 100644 examples/quick/particles/affectors/customaffector.qml create mode 100644 examples/quick/particles/affectors/friction.qml create mode 100644 examples/quick/particles/affectors/gravity.qml create mode 100644 examples/quick/particles/affectors/groupgoal.qml create mode 100644 examples/quick/particles/affectors/images/_explo.png create mode 100644 examples/quick/particles/affectors/images/backgroundLeaves.jpg create mode 100644 examples/quick/particles/affectors/images/candle.png create mode 100644 examples/quick/particles/affectors/images/finalfrontier.png create mode 100644 examples/quick/particles/affectors/images/matchmask.png create mode 100644 examples/quick/particles/affectors/images/meteor.png create mode 100644 examples/quick/particles/affectors/images/nullRock.png create mode 100644 examples/quick/particles/affectors/images/particleA.png create mode 100644 examples/quick/particles/affectors/images/realLeaf1.png create mode 100644 examples/quick/particles/affectors/images/realLeaf2.png create mode 100644 examples/quick/particles/affectors/images/realLeaf3.png create mode 100644 examples/quick/particles/affectors/images/realLeaf4.png create mode 100644 examples/quick/particles/affectors/images/rocket.png create mode 100644 examples/quick/particles/affectors/images/rocket2.png create mode 100644 examples/quick/particles/affectors/images/snowflake.png create mode 100644 examples/quick/particles/affectors/move.qml create mode 100644 examples/quick/particles/affectors/spritegoal.qml create mode 100644 examples/quick/particles/affectors/turbulence.qml create mode 100644 examples/quick/particles/affectors/wander.qml create mode 100644 examples/quick/particles/emitters/burstandpulse.qml delete mode 100644 examples/quick/particles/emitters/content/burstandpulse.qml delete mode 100644 examples/quick/particles/emitters/content/customemitter.qml delete mode 100644 examples/quick/particles/emitters/content/emitmask.qml delete mode 100644 examples/quick/particles/emitters/content/maximumemitted.qml delete mode 100644 examples/quick/particles/emitters/content/shapeanddirection.qml delete mode 100644 examples/quick/particles/emitters/content/trailemitter.qml delete mode 100644 examples/quick/particles/emitters/content/velocityfrommotion.qml create mode 100644 examples/quick/particles/emitters/customemitter.qml create mode 100644 examples/quick/particles/emitters/emitmask.qml create mode 100644 examples/quick/particles/emitters/images/portal_bg.png create mode 100644 examples/quick/particles/emitters/images/starfish_mask.png create mode 100644 examples/quick/particles/emitters/maximumemitted.qml create mode 100644 examples/quick/particles/emitters/shapeanddirection.qml create mode 100644 examples/quick/particles/emitters/trailemitter.qml create mode 100644 examples/quick/particles/emitters/velocityfrommotion.qml create mode 100644 examples/quick/particles/imageparticle/allatonce.qml create mode 100644 examples/quick/particles/imageparticle/colored.qml create mode 100644 examples/quick/particles/imageparticle/colortable.qml delete mode 100644 examples/quick/particles/imageparticle/content/allatonce.qml delete mode 100644 examples/quick/particles/imageparticle/content/colored.qml delete mode 100644 examples/quick/particles/imageparticle/content/colortable.qml delete mode 100644 examples/quick/particles/imageparticle/content/deformation.qml delete mode 100644 examples/quick/particles/imageparticle/content/rotation.qml delete mode 100644 examples/quick/particles/imageparticle/content/sharing.qml delete mode 100644 examples/quick/particles/imageparticle/content/sprites.qml create mode 100644 examples/quick/particles/imageparticle/deformation.qml create mode 100644 examples/quick/particles/imageparticle/images/bear_tiles.png create mode 100644 examples/quick/particles/imageparticle/images/colortable.png create mode 100644 examples/quick/particles/imageparticle/images/flower.png create mode 100644 examples/quick/particles/imageparticle/images/starfish_0.png create mode 100644 examples/quick/particles/imageparticle/images/starfish_1.png create mode 100644 examples/quick/particles/imageparticle/images/starfish_2.png create mode 100644 examples/quick/particles/imageparticle/images/starfish_3.png create mode 100644 examples/quick/particles/imageparticle/images/starfish_4.png create mode 100644 examples/quick/particles/imageparticle/rotation.qml create mode 100644 examples/quick/particles/imageparticle/sharing.qml create mode 100644 examples/quick/particles/imageparticle/sprites.qml delete mode 100644 examples/quick/particles/images.qrc delete mode 100644 examples/quick/particles/images/_explo.png delete mode 100644 examples/quick/particles/images/backgroundLeaves.jpg delete mode 100644 examples/quick/particles/images/bear_tiles.png delete mode 100644 examples/quick/particles/images/candle.png delete mode 100644 examples/quick/particles/images/colortable.png delete mode 100644 examples/quick/particles/images/finalfrontier.png delete mode 100644 examples/quick/particles/images/flower.png delete mode 100644 examples/quick/particles/images/matchmask.png delete mode 100644 examples/quick/particles/images/meteor.png delete mode 100644 examples/quick/particles/images/meteor_explo.png delete mode 100644 examples/quick/particles/images/meteors.png delete mode 100644 examples/quick/particles/images/nullRock.png delete mode 100644 examples/quick/particles/images/particle2.png delete mode 100644 examples/quick/particles/images/particle3.png delete mode 100644 examples/quick/particles/images/particleA.png delete mode 100644 examples/quick/particles/images/portal_bg.png delete mode 100644 examples/quick/particles/images/realLeaf1.png delete mode 100644 examples/quick/particles/images/realLeaf2.png delete mode 100644 examples/quick/particles/images/realLeaf3.png delete mode 100644 examples/quick/particles/images/realLeaf4.png delete mode 100644 examples/quick/particles/images/rocket.png delete mode 100644 examples/quick/particles/images/rocket2.png delete mode 100644 examples/quick/particles/images/sizeInOut.png delete mode 100644 examples/quick/particles/images/snowflake.png delete mode 100644 examples/quick/particles/images/sparkleSize.png delete mode 100644 examples/quick/particles/images/starfish_0.png delete mode 100644 examples/quick/particles/images/starfish_1.png delete mode 100644 examples/quick/particles/images/starfish_2.png delete mode 100644 examples/quick/particles/images/starfish_3.png delete mode 100644 examples/quick/particles/images/starfish_4.png delete mode 100644 examples/quick/particles/images/starfish_mask.png delete mode 100644 examples/quick/particles/itemparticle/content/Delegate.qml delete mode 100644 examples/quick/particles/itemparticle/content/Delegate2.qml delete mode 100644 examples/quick/particles/itemparticle/content/ExpandingDelegate.qml delete mode 100644 examples/quick/particles/itemparticle/content/bubble.png delete mode 100644 examples/quick/particles/itemparticle/content/script.js create mode 100644 examples/quick/particles/itemparticle/images/rocket.png create mode 100644 examples/quick/particles/itemparticle/itemparticle.qml create mode 100644 examples/quick/particles/itemparticle/itemparticle.qrc delete mode 100644 examples/quick/particles/itemparticle/particleview.qml create mode 100644 examples/quick/particles/itemparticle/script.js delete mode 100644 examples/quick/particles/system/content/dynamiccomparison.qml delete mode 100644 examples/quick/particles/system/content/dynamicemitters.qml delete mode 100644 examples/quick/particles/system/content/multiplepainters.qml delete mode 100644 examples/quick/particles/system/content/startstop.qml delete mode 100644 examples/quick/particles/system/content/timedgroupchanges.qml create mode 100644 examples/quick/particles/system/dynamiccomparison.qml create mode 100644 examples/quick/particles/system/dynamicemitters.qml create mode 100644 examples/quick/particles/system/images/particle2.png create mode 100644 examples/quick/particles/system/images/particle3.png create mode 100644 examples/quick/particles/system/images/sparkleSize.png create mode 100644 examples/quick/particles/system/multiplepainters.qml create mode 100644 examples/quick/particles/system/startstop.qml create mode 100644 examples/quick/particles/system/timedgroupchanges.qml diff --git a/examples/quick/particles/affectors/CMakeLists.txt b/examples/quick/particles/affectors/CMakeLists.txt index c082bea86d..9434063429 100644 --- a/examples/quick/particles/affectors/CMakeLists.txt +++ b/examples/quick/particles/affectors/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from affectors.pro. - cmake_minimum_required(VERSION 3.16) project(affectors LANGUAGES CXX) @@ -7,7 +5,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) set(INSTALL_EXAMPLESDIR "examples") @@ -15,119 +12,61 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/affectors") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Core Gui Quick Qml) + +add_subdirectory("../../shared" "shared") -qt_add_executable(affectors +qt_add_executable(affectorsexample WIN32 MACOSX_BUNDLE main.cpp ) -set_target_properties(affectors PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(affectors PUBLIC +target_link_libraries(affectorsexample PRIVATE Qt::Core Qt::Gui Qt::Qml Qt::Quick ) +add_dependencies(affectorsexample affectors_shared) # Resources: -set(affectors_resource_files - "affectors.qml" - "content/GreyButton.qml" - "content/age.qml" - "content/attractor.qml" - "content/customaffector.qml" - "content/friction.qml" - "content/gravity.qml" - "content/groupgoal.qml" - "content/move.qml" - "content/spritegoal.qml" - "content/turbulence.qml" - "content/wander.qml" -) - -qt6_add_resources(affectors "affectors" - PREFIX - "/particles/affectors" - FILES - ${affectors_resource_files} -) -set(images_resource_files - "../images/_explo.png" - "../images/backgroundLeaves.jpg" - "../images/bear_tiles.png" - "../images/candle.png" - "../images/colortable.png" - "../images/finalfrontier.png" - "../images/flower.png" - "../images/matchmask.png" - "../images/meteor.png" - "../images/meteor_explo.png" - "../images/meteors.png" - "../images/nullRock.png" - "../images/particle2.png" - "../images/particle3.png" - "../images/particleA.png" - "../images/portal_bg.png" - "../images/realLeaf1.png" - "../images/realLeaf2.png" - "../images/realLeaf3.png" - "../images/realLeaf4.png" - "../images/rocket.png" - "../images/rocket2.png" - "../images/sizeInOut.png" - "../images/snowflake.png" - "../images/sparkleSize.png" - "../images/starfish_0.png" - "../images/starfish_1.png" - "../images/starfish_2.png" - "../images/starfish_3.png" - "../images/starfish_4.png" - "../images/starfish_mask.png" +qt_add_qml_module(affectorsexample + URI affectors + VERSION 1.0 + QML_FILES + "affectors.qml" + "GreyButton.qml" + "age.qml" + "attractor.qml" + "customaffector.qml" + "friction.qml" + "gravity.qml" + "groupgoal.qml" + "move.qml" + "spritegoal.qml" + "turbulence.qml" + "wander.qml" + RESOURCES + "images/snowflake.png" + "images/finalfrontier.png" + "images/meteor.png" + "images/rocket.png" + "images/rocket2.png" + "images/backgroundLeaves.jpg" + "images/realLeaf1.png" + "images/realLeaf2.png" + "images/realLeaf3.png" + "images/realLeaf4.png" + "images/particleA.png" + "images/matchmask.png" + "images/nullRock.png" + "images/_explo.png" + "images/candle.png" ) -qt6_add_resources(affectors "images" - PREFIX - "/particles" - BASE - ".." - FILES - ${images_resource_files} -) -set(shared_resource_files - "../../shared/Button.qml" - "../../shared/CheckBox.qml" - "../../shared/FlickrRssModel.qml" - "../../shared/Label.qml" - "../../shared/LauncherList.qml" - "../../shared/SimpleLauncherDelegate.qml" - "../../shared/Slider.qml" - "../../shared/TabSet.qml" - "../../shared/TextField.qml" - "../../shared/images/back.png" - "../../shared/images/checkmark.png" - "../../shared/images/next.png" - "../../shared/images/qt-logo.png" - "../../shared/images/slider_handle.png" - "../../shared/images/tab.png" -) - -qt6_add_resources(affectors "shared" - PREFIX - "/shared" - BASE - "../../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS affectors +install(TARGETS affectorsexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) + +bundle_shared(affectorsexample) diff --git a/examples/quick/particles/affectors/GreyButton.qml b/examples/quick/particles/affectors/GreyButton.qml new file mode 100644 index 0000000000..d78d913cf0 --- /dev/null +++ b/examples/quick/particles/affectors/GreyButton.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + id: container + + property string text: "Button" + property string subText: "" + signal clicked + + width: buttonLabel.width + 20; height: col.height + 12 + + MouseArea { + id: mouseArea; + anchors.fill: parent; + onClicked: container.clicked(); + onPressed: background.color = Qt.darker("lightgrey"); + onReleased: background.color="lightgrey"; + } + + Rectangle { + id: background + anchors.fill: parent + color: "lightgrey" + radius: 4 + border.width: 1 + border.color: Qt.darker(color) + } + + Column { + spacing: 2 + id: col + x: 10 + y: 6 + Text { + id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24 + } + Text { + id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12 + } + } +} diff --git a/examples/quick/particles/affectors/affectors.pro b/examples/quick/particles/affectors/affectors.pro index 673ccfbb81..fc049c21b0 100644 --- a/examples/quick/particles/affectors/affectors.pro +++ b/examples/quick/particles/affectors/affectors.pro @@ -4,7 +4,6 @@ QT += quick qml SOURCES += main.cpp RESOURCES += \ affectors.qrc \ - ../images.qrc \ ../../shared/shared.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/particles/affectors diff --git a/examples/quick/particles/affectors/affectors.qml b/examples/quick/particles/affectors/affectors.qml index 81240fed9b..9fa067713e 100644 --- a/examples/quick/particles/affectors/affectors.qml +++ b/examples/quick/particles/affectors/affectors.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,26 +48,26 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import "../../shared" as Examples +import QtQuick +import shared Item { height: 480 width: 320 - Examples.LauncherList { + LauncherList { id: ll anchors.fill: parent Component.onCompleted: { - addExample("Age", "Kills off particles that enter the affector", Qt.resolvedUrl("content/age.qml")); - addExample("Attractor", "Simulates a small black hole", Qt.resolvedUrl("content/attractor.qml")); - addExample("Custom Affector", "Custom falling leaves", Qt.resolvedUrl("content/customaffector.qml")); - addExample("Friction", "Leaves that slow down as they fall", Qt.resolvedUrl("content/friction.qml")); - addExample("Gravity", "Leaves that fall towards the earth as you move it", Qt.resolvedUrl("content/gravity.qml")); - addExample("GroupGoal", "Balls that can be set on fire various ways", Qt.resolvedUrl("content/groupgoal.qml")); - addExample("Move", "Some effects you can get by altering trajectory midway", Qt.resolvedUrl("content/move.qml")); - addExample("SpriteGoal", "A ship that makes asteroids explode", Qt.resolvedUrl("content/spritegoal.qml")); - addExample("Turbulence", "A candle with faint wind", Qt.resolvedUrl("content/turbulence.qml")); - addExample("Wander", "Drifting snow flakes", Qt.resolvedUrl("content/wander.qml")); + addExample("Age", "Kills off particles that enter the affector", Qt.resolvedUrl("age.qml")); + addExample("Attractor", "Simulates a small black hole", Qt.resolvedUrl("attractor.qml")); + addExample("Custom Affector", "Custom falling leaves", Qt.resolvedUrl("customaffector.qml")); + addExample("Friction", "Leaves that slow down as they fall", Qt.resolvedUrl("friction.qml")); + addExample("Gravity", "Leaves that fall towards the earth as you move it", Qt.resolvedUrl("gravity.qml")); + addExample("GroupGoal", "Balls that can be set on fire various ways", Qt.resolvedUrl("groupgoal.qml")); + addExample("Move", "Some effects you can get by altering trajectory midway", Qt.resolvedUrl("move.qml")); + addExample("SpriteGoal", "A ship that makes asteroids explode", Qt.resolvedUrl("spritegoal.qml")); + addExample("Turbulence", "A candle with faint wind", Qt.resolvedUrl("turbulence.qml")); + addExample("Wander", "Drifting snow flakes", Qt.resolvedUrl("wander.qml")); } } } diff --git a/examples/quick/particles/affectors/affectors.qrc b/examples/quick/particles/affectors/affectors.qrc index c1d797e4d8..e26bf0b173 100644 --- a/examples/quick/particles/affectors/affectors.qrc +++ b/examples/quick/particles/affectors/affectors.qrc @@ -1,16 +1,31 @@ - + affectors.qml - content/age.qml - content/attractor.qml - content/customaffector.qml - content/friction.qml - content/gravity.qml - content/GreyButton.qml - content/groupgoal.qml - content/move.qml - content/spritegoal.qml - content/turbulence.qml - content/wander.qml + age.qml + attractor.qml + customaffector.qml + friction.qml + gravity.qml + GreyButton.qml + groupgoal.qml + move.qml + spritegoal.qml + turbulence.qml + wander.qml + images/snowflake.png + images/finalfrontier.png + images/meteor.png + images/rocket.png + images/rocket2.png + images/backgroundLeaves.jpg + images/realLeaf1.png + images/realLeaf2.png + images/realLeaf3.png + images/realLeaf4.png + images/particleA.png + images/matchmask.png + images/nullRock.png + images/_explo.png + images/candle.png diff --git a/examples/quick/particles/affectors/age.qml b/examples/quick/particles/affectors/age.qml new file mode 100644 index 0000000000..a787563506 --- /dev/null +++ b/examples/quick/particles/affectors/age.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + id: root + width: 360 + height: 600 + color: "white" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + sprites: Sprite { + name: "snow" + source: "images/snowflake.png" + frameCount: 51 + frameDuration: 40 + frameDurationVariation: 8 + } + } + + Emitter { + system: particles + emitRate: 20 + lifeSpan: 8000 + velocity: PointDirection { y:80; yVariation: 40; } + acceleration: PointDirection { y: 4 } + size: 36 + endSize: 12 + sizeVariation: 8 + width: parent.width + height: 100 + } + + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + } + + Rectangle { + color: "#803333AA" + border.color: "black" + x: ma.mouseX - 36 + y: ma.mouseY - 36 + width: 72 + height: 72 + //! [0] + Age { + anchors.fill: parent + system: particles + once: true + lifeLeft: 1200 + advancePosition: false + } + //! [0] + } +} diff --git a/examples/quick/particles/affectors/attractor.qml b/examples/quick/particles/affectors/attractor.qml new file mode 100644 index 0000000000..41055e3629 --- /dev/null +++ b/examples/quick/particles/affectors/attractor.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + Image { + source: "images/finalfrontier.png" + anchors.centerIn:parent + } + ParticleSystem { + id: particles + anchors.fill: parent + + Emitter { + group: "stars" + emitRate: 40 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + velocity: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + Emitter { + group: "roids" + emitRate: 10 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + velocity: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + ImageParticle { + id: stars + groups: ["stars"] + source: "qrc:///particleresources/star.png" + color: "white" + colorVariation: 0.1 + alpha: 0 + } + ImageParticle { + id: roids + groups: ["roids"] + sprites: Sprite { + id: spinState + name: "spinning" + source: "images/meteor.png" + frameCount: 35 + frameDuration: 60 + } + } + ImageParticle { + id: shot + groups: ["shot"] + source: "qrc:///particleresources/star.png" + + color: "#0FF06600" + colorVariation: 0.3 + } + ImageParticle { + id: engine + groups: ["engine"] + source: "qrc:///particleresources/fuzzydot.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + //! [0] + Attractor { + id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; + affectedParameter: Attractor.Acceleration + proportionalToDistance: Attractor.InverseQuadratic + } + //! [0] + Age { + x: gs.pointX - 8; + y: gs.pointY - 8; + width: 16 + height: 16 + } + Rectangle { + color: "black" + width: 8 + height: 8 + radius: 4 + x: gs.pointX - 4 + y: gs.pointY - 4 + } + + Image { + source:"images/rocket2.png" + id: ship + width: 45 + height: 22 + //Automatic movement + SequentialAnimation on x { + loops: -1 + NumberAnimation{to: root.width-45; easing.type: Easing.InOutQuad; duration: 2000} + NumberAnimation{to: 0; easing.type: Easing.OutInQuad; duration: 6000} + } + SequentialAnimation on y { + loops: -1 + NumberAnimation{to: root.height-22; easing.type: Easing.OutInQuad; duration: 6000} + NumberAnimation{to: 0; easing.type: Easing.InOutQuad; duration: 2000} + } + } + Emitter { + group: "engine" + emitRate: 200 + lifeSpan: 1000 + size: 10 + endSize: 4 + sizeVariation: 4 + velocity: PointDirection { x: -128; xVariation: 32 } + height: ship.height + y: ship.y + x: ship.x + width: 20 + } + Emitter { + group: "shot" + emitRate: 32 + lifeSpan: 1000 + enabled: true + size: 40 + velocity: PointDirection { x: 256; } + x: ship.x + ship.width + y: ship.y + ship.height/2 + } + } +} + diff --git a/examples/quick/particles/affectors/content/GreyButton.qml b/examples/quick/particles/affectors/content/GreyButton.qml deleted file mode 100644 index d78d913cf0..0000000000 --- a/examples/quick/particles/affectors/content/GreyButton.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 - -Item { - id: container - - property string text: "Button" - property string subText: "" - signal clicked - - width: buttonLabel.width + 20; height: col.height + 12 - - MouseArea { - id: mouseArea; - anchors.fill: parent; - onClicked: container.clicked(); - onPressed: background.color = Qt.darker("lightgrey"); - onReleased: background.color="lightgrey"; - } - - Rectangle { - id: background - anchors.fill: parent - color: "lightgrey" - radius: 4 - border.width: 1 - border.color: Qt.darker(color) - } - - Column { - spacing: 2 - id: col - x: 10 - y: 6 - Text { - id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24 - } - Text { - id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12 - } - } -} diff --git a/examples/quick/particles/affectors/content/age.qml b/examples/quick/particles/affectors/content/age.qml deleted file mode 100644 index ff5114a596..0000000000 --- a/examples/quick/particles/affectors/content/age.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 600 - color: "white" - - ParticleSystem { id: particles } - - ImageParticle { - system: particles - sprites: Sprite { - name: "snow" - source: "../../images/snowflake.png" - frameCount: 51 - frameDuration: 40 - frameDurationVariation: 8 - } - } - - Emitter { - system: particles - emitRate: 20 - lifeSpan: 8000 - velocity: PointDirection { y:80; yVariation: 40; } - acceleration: PointDirection { y: 4 } - size: 36 - endSize: 12 - sizeVariation: 8 - width: parent.width - height: 100 - } - - MouseArea { - id: ma - anchors.fill: parent - hoverEnabled: true - } - - Rectangle { - color: "#803333AA" - border.color: "black" - x: ma.mouseX - 36 - y: ma.mouseY - 36 - width: 72 - height: 72 - //! [0] - Age { - anchors.fill: parent - system: particles - once: true - lifeLeft: 1200 - advancePosition: false - } - //! [0] - } -} diff --git a/examples/quick/particles/affectors/content/attractor.qml b/examples/quick/particles/affectors/content/attractor.qml deleted file mode 100644 index 7fbb6069b2..0000000000 --- a/examples/quick/particles/affectors/content/attractor.qml +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 540 - color: "black" - Image { - source: "../../images/finalfrontier.png" - anchors.centerIn:parent - } - ParticleSystem { - id: particles - anchors.fill: parent - - Emitter { - group: "stars" - emitRate: 40 - lifeSpan: 4000 - enabled: true - size: 30 - sizeVariation: 10 - velocity: PointDirection { x: 220; xVariation: 40 } - height: parent.height - } - Emitter { - group: "roids" - emitRate: 10 - lifeSpan: 4000 - enabled: true - size: 30 - sizeVariation: 10 - velocity: PointDirection { x: 220; xVariation: 40 } - height: parent.height - } - ImageParticle { - id: stars - groups: ["stars"] - source: "qrc:///particleresources/star.png" - color: "white" - colorVariation: 0.1 - alpha: 0 - } - ImageParticle { - id: roids - groups: ["roids"] - sprites: Sprite { - id: spinState - name: "spinning" - source: "../../images/meteor.png" - frameCount: 35 - frameDuration: 60 - } - } - ImageParticle { - id: shot - groups: ["shot"] - source: "qrc:///particleresources/star.png" - - color: "#0FF06600" - colorVariation: 0.3 - } - ImageParticle { - id: engine - groups: ["engine"] - source: "qrc:///particleresources/fuzzydot.png" - - color: "orange" - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { - from: "red" - to: "cyan" - duration: 1000 - } - ColorAnimation { - from: "cyan" - to: "red" - duration: 1000 - } - } - - colorVariation: 0.2 - } - //! [0] - Attractor { - id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; - affectedParameter: Attractor.Acceleration - proportionalToDistance: Attractor.InverseQuadratic - } - //! [0] - Age { - x: gs.pointX - 8; - y: gs.pointY - 8; - width: 16 - height: 16 - } - Rectangle { - color: "black" - width: 8 - height: 8 - radius: 4 - x: gs.pointX - 4 - y: gs.pointY - 4 - } - - Image { - source:"../../images/rocket2.png" - id: ship - width: 45 - height: 22 - //Automatic movement - SequentialAnimation on x { - loops: -1 - NumberAnimation{to: root.width-45; easing.type: Easing.InOutQuad; duration: 2000} - NumberAnimation{to: 0; easing.type: Easing.OutInQuad; duration: 6000} - } - SequentialAnimation on y { - loops: -1 - NumberAnimation{to: root.height-22; easing.type: Easing.OutInQuad; duration: 6000} - NumberAnimation{to: 0; easing.type: Easing.InOutQuad; duration: 2000} - } - } - Emitter { - group: "engine" - emitRate: 200 - lifeSpan: 1000 - size: 10 - endSize: 4 - sizeVariation: 4 - velocity: PointDirection { x: -128; xVariation: 32 } - height: ship.height - y: ship.y - x: ship.x - width: 20 - } - Emitter { - group: "shot" - emitRate: 32 - lifeSpan: 1000 - enabled: true - size: 40 - velocity: PointDirection { x: 256; } - x: ship.x + ship.width - y: ship.y + ship.height/2 - } - } -} - diff --git a/examples/quick/particles/affectors/content/customaffector.qml b/examples/quick/particles/affectors/content/customaffector.qml deleted file mode 100644 index 76fc4dc302..0000000000 --- a/examples/quick/particles/affectors/content/customaffector.qml +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Item { - width: 360 - height: 600 - - Image { - source: "../../images/backgroundLeaves.jpg" - anchors.fill: parent - } - ParticleSystem { - anchors.fill: parent - Emitter { - width: parent.width - emitRate: 4 - lifeSpan: 14000 - size: 80 - velocity: PointDirection { y: 60 } - } - Wander { - anchors.fill: parent - anchors.bottomMargin: 100 - xVariance: 60 - pace: 60 - } - - //! [0] - Affector { - width: parent.width - height: parent.height - 100 - onAffectParticles: (particles, dt) => { - //Wobbly movement - for (var i=0; i { - for (var i=0; i { + //Wobbly movement + for (var i=0; i { + for (var i=0; i { - for (var i=0; i { + for (var i=0; i - + emitters.qml - content/burstandpulse.qml - content/customemitter.qml - content/emitmask.qml - content/maximumemitted.qml - content/shapeanddirection.qml - content/trailemitter.qml - content/velocityfrommotion.qml + burstandpulse.qml + customemitter.qml + emitmask.qml + maximumemitted.qml + shapeanddirection.qml + trailemitter.qml + velocityfrommotion.qml + images/starfish_mask.png + images/portal_bg.png diff --git a/examples/quick/particles/emitters/images/portal_bg.png b/examples/quick/particles/emitters/images/portal_bg.png new file mode 100644 index 0000000000..3c59eeabb9 Binary files /dev/null and b/examples/quick/particles/emitters/images/portal_bg.png differ diff --git a/examples/quick/particles/emitters/images/starfish_mask.png b/examples/quick/particles/emitters/images/starfish_mask.png new file mode 100644 index 0000000000..7ae39b34c5 Binary files /dev/null and b/examples/quick/particles/emitters/images/starfish_mask.png differ diff --git a/examples/quick/particles/emitters/main.cpp b/examples/quick/particles/emitters/main.cpp index e2b3cf2026..1d35645e63 100644 --- a/examples/quick/particles/emitters/main.cpp +++ b/examples/quick/particles/emitters/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(particles/emitters/emitters) +DECLARATIVE_EXAMPLE_MAIN(emitters/emitters) diff --git a/examples/quick/particles/emitters/maximumemitted.qml b/examples/quick/particles/emitters/maximumemitted.qml new file mode 100644 index 0000000000..dd4dfdfbdd --- /dev/null +++ b/examples/quick/particles/emitters/maximumemitted.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 360 + height: 540 + ParticleSystem { + id: sys + anchors.fill: parent + onEmptyChanged: if (empty) sys.pause(); + + ImageParticle { + system: sys + id: cp + source: "qrc:///particleresources/glowdot.png" + colorVariation: 0.4 + color: "#000000FF" + } + + Emitter { + //burst on click + id: bursty + system: sys + enabled: ma.pressed + x: ma.mouseX + y: ma.mouseY + emitRate: 16000 + maximumEmitted: 4000 + acceleration: AngleDirection {angleVariation: 360; magnitude: 360; } + size: 8 + endSize: 16 + sizeVariation: 4 + } + + MouseArea { + anchors.fill: parent + onPressed: sys.resume() + id: ma + } + } +} diff --git a/examples/quick/particles/emitters/shapeanddirection.qml b/examples/quick/particles/emitters/shapeanddirection.qml new file mode 100644 index 0000000000..cffec4196b --- /dev/null +++ b/examples/quick/particles/emitters/shapeanddirection.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + Image { + anchors.fill: parent + source: "images/portal_bg.png" + } + + ParticleSystem { + id: particles + anchors.fill: parent + + ImageParticle { + groups: ["center","edge"] + anchors.fill: parent + source: "qrc:///particleresources/glowdot.png" + colorVariation: 0.1 + color: "#009999FF" + } + + Emitter { + anchors.fill: parent + group: "center" + emitRate: 400 + lifeSpan: 2000 + size: 20 + sizeVariation: 2 + endSize: 0 + //! [0] + shape: EllipseShape {fill: false} + velocity: TargetDirection { + targetX: root.width/2 + targetY: root.height/2 + proportionalMagnitude: true + magnitude: 0.5 + } + //! [0] + } + + Emitter { + anchors.fill: parent + group: "edge" + startTime: 2000 + emitRate: 2000 + lifeSpan: 2000 + size: 28 + sizeVariation: 2 + endSize: 16 + shape: EllipseShape {fill: false} + velocity: TargetDirection { + targetX: root.width/2 + targetY: root.height/2 + proportionalMagnitude: true + magnitude: 0.1 + magnitudeVariation: 0.1 + } + acceleration: TargetDirection { + targetX: root.width/2 + targetY: root.height/2 + targetVariation: 200 + proportionalMagnitude: true + magnitude: 0.1 + magnitudeVariation: 0.1 + } + } + } +} diff --git a/examples/quick/particles/emitters/trailemitter.qml b/examples/quick/particles/emitters/trailemitter.qml new file mode 100644 index 0000000000..fdb6180eb6 --- /dev/null +++ b/examples/quick/particles/emitters/trailemitter.qml @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem { + id: particles + anchors.fill: parent + + ImageParticle { + id: smoke + system: particles + anchors.fill: parent + groups: ["A", "B"] + source: "qrc:///particleresources/glowdot.png" + colorVariation: 0 + color: "#00111111" + } + ImageParticle { + id: flame + anchors.fill: parent + system: particles + groups: ["C", "D"] + source: "qrc:///particleresources/glowdot.png" + colorVariation: 0.1 + color: "#00ff400f" + } + + Emitter { + id: fire + system: particles + group: "C" + + y: parent.height + width: parent.width + + emitRate: 350 + lifeSpan: 3500 + + acceleration: PointDirection { y: -17; xVariation: 3 } + velocity: PointDirection {xVariation: 3} + + size: 24 + sizeVariation: 8 + endSize: 4 + } + + TrailEmitter { + id: fireSmoke + group: "B" + system: particles + follow: "C" + width: root.width + height: root.height - 68 + + emitRatePerParticle: 1 + lifeSpan: 2000 + + velocity: PointDirection {y:-17*6; yVariation: -17; xVariation: 3} + acceleration: PointDirection {xVariation: 3} + + size: 36 + sizeVariation: 8 + endSize: 16 + } + + TrailEmitter { + id: fireballFlame + anchors.fill: parent + system: particles + group: "D" + follow: "E" + + emitRatePerParticle: 120 + lifeSpan: 180 + emitWidth: TrailEmitter.ParticleSize + emitHeight: TrailEmitter.ParticleSize + emitShape: EllipseShape{} + + size: 16 + sizeVariation: 4 + endSize: 4 + } + + TrailEmitter { + id: fireballSmoke + anchors.fill: parent + system: particles + group: "A" + follow: "E" + + emitRatePerParticle: 128 + lifeSpan: 2400 + emitWidth: TrailEmitter.ParticleSize + emitHeight: TrailEmitter.ParticleSize + emitShape: EllipseShape{} + + velocity: PointDirection {yVariation: 16; xVariation: 16} + acceleration: PointDirection {y: -16} + + size: 24 + sizeVariation: 8 + endSize: 8 + } + + Emitter { + id: balls + system: particles + group: "E" + + y: parent.height + width: parent.width + + emitRate: 2 + lifeSpan: 7000 + + velocity: PointDirection {y:-17*4*2; xVariation: 6*6} + acceleration: PointDirection {y: 17*2; xVariation: 6*6} + + size: 8 + sizeVariation: 4 + } + + Turbulence { //A bit of turbulence makes the smoke look better + anchors.fill: parent + groups: ["A","B"] + strength: 32 + system: particles + } + } +} + diff --git a/examples/quick/particles/emitters/velocityfrommotion.qml b/examples/quick/particles/emitters/velocityfrommotion.qml new file mode 100644 index 0000000000..eee533a2fe --- /dev/null +++ b/examples/quick/particles/emitters/velocityfrommotion.qml @@ -0,0 +1,322 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 + +Rectangle { + + id: root + + height: 540 + width: 360 + + gradient: Gradient { + GradientStop { position: 0; color: "#000020" } + GradientStop { position: 1; color: "#000000" } + } + + MouseArea { + id: mouseArea + anchors.fill: root + } + + ParticleSystem { id: sys1 } + ImageParticle { + system: sys1 + source: "qrc:///particleresources/glowdot.png" + color: "cyan" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "cyan" + to: "magenta" + duration: 1000 + } + ColorAnimation { + from: "magenta" + to: "blue" + duration: 2000 + } + ColorAnimation { + from: "blue" + to: "violet" + duration: 2000 + } + ColorAnimation { + from: "violet" + to: "cyan" + duration: 2000 + } + } + colorVariation: 0.3 + } + //! [0] + Emitter { + id: trailsNormal + system: sys1 + + emitRate: 500 + lifeSpan: 2000 + + y: mouseArea.pressed ? mouseArea.mouseY : circle.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle.cx + + velocity: PointDirection {xVariation: 4; yVariation: 4;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + velocityFromMovement: 8 + + size: 8 + sizeVariation: 4 + } + //! [0] + ParticleSystem { id: sys2 } + ImageParticle { + color: "cyan" + system: sys2 + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "magenta" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "magenta" + duration: 2000 + } + } + colorVariation: 0.5 + source: "qrc:///particleresources/star.png" + } + Emitter { + id: trailsStars + system: sys2 + + emitRate: 100 + lifeSpan: 2200 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle.cx + + velocity: PointDirection {xVariation: 4; yVariation: 4;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + velocityFromMovement: 8 + + size: 22 + sizeVariation: 4 + } + ParticleSystem { id: sys3; } + ImageParticle { + source: "qrc:///particleresources/glowdot.png" + system: sys3 + color: "orange" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "green" + duration: 2000 + } + ColorAnimation { + from: "green" + to: "red" + duration: 2000 + } + } + + colorVariation: 0.2 + + } + Emitter { + id: trailsNormal2 + system: sys3 + + emitRate: 300 + lifeSpan: 2000 + + y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx + + velocityFromMovement: 16 + + velocity: PointDirection {xVariation: 4; yVariation: 4;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + + size: 12 + sizeVariation: 4 + } + ParticleSystem { id: sys4; } + ImageParticle { + system: sys4 + source: "qrc:///particleresources/star.png" + color: "green" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "green" + to: "red" + duration: 2000 + } + ColorAnimation { + from: "red" + to: "green" + duration: 2000 + } + } + + colorVariation: 0.5 + } + Emitter { + id: trailsStars2 + system: sys4 + + emitRate: 50 + lifeSpan: 2200 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx + + velocityFromMovement: 16 + velocity: PointDirection {xVariation: 2; yVariation: 2;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + + size: 22 + sizeVariation: 4 + } + + + + color: "white" + + Item { + id: circle + //anchors.fill: parent + property real radius: 0 + property real dx: root.width / 2 + property real dy: root.height / 2 + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 1000 + from: 1 + to: 0 + loops: 8 + } + NumberAnimation { + duration: 1000 + from: 0 + to: 1 + loops: 8 + } + + } + + SequentialAnimation on radius { + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 4000 + from: 0 + to: 100 + } + NumberAnimation { + duration: 4000 + from: 100 + to: 0 + } + } + } + + Item { + id: circle3 + property real radius: 100 + property real dx: root.width / 2 + property real dy: root.height / 2 + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { from: 0.0; to: 1 ; duration: 10000; } + } + } + + Item { + id: circle2 + property real radius: 30 + property real dx: circle3.cx + property real dy: circle3.cy + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { from: 0.0; to: 1 ; duration: 1000; } + } + } + +} diff --git a/examples/quick/particles/imageparticle/CMakeLists.txt b/examples/quick/particles/imageparticle/CMakeLists.txt index 4487e04316..387c5bdd41 100644 --- a/examples/quick/particles/imageparticle/CMakeLists.txt +++ b/examples/quick/particles/imageparticle/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from imageparticle.pro. - cmake_minimum_required(VERSION 3.16) project(imageparticle LANGUAGES CXX) @@ -7,7 +5,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) set(INSTALL_EXAMPLESDIR "examples") @@ -15,115 +12,50 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/imageparticle") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Core Gui Quick Qml) + +add_subdirectory("../../shared" "shared") -qt_add_executable(imageparticle +qt_add_executable(imageparticleexample WIN32 MACOSX_BUNDLE main.cpp ) -set_target_properties(imageparticle PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(imageparticle PUBLIC +target_link_libraries(imageparticleexample PUBLIC Qt::Core Qt::Gui Qt::Qml Qt::Quick ) +add_dependencies(imageparticleexample imageparticle_shared) # Resources: -set(imageparticle_resource_files - "content/allatonce.qml" - "content/colored.qml" - "content/colortable.qml" - "content/deformation.qml" - "content/rotation.qml" - "content/sharing.qml" - "content/sprites.qml" - "imageparticle.qml" -) - -qt6_add_resources(imageparticle "imageparticle" - PREFIX - "/particles/imageparticle" - FILES - ${imageparticle_resource_files} -) -set(images_resource_files - "../images/_explo.png" - "../images/backgroundLeaves.jpg" - "../images/bear_tiles.png" - "../images/candle.png" - "../images/colortable.png" - "../images/finalfrontier.png" - "../images/flower.png" - "../images/matchmask.png" - "../images/meteor.png" - "../images/meteor_explo.png" - "../images/meteors.png" - "../images/nullRock.png" - "../images/particle2.png" - "../images/particle3.png" - "../images/particleA.png" - "../images/portal_bg.png" - "../images/realLeaf1.png" - "../images/realLeaf2.png" - "../images/realLeaf3.png" - "../images/realLeaf4.png" - "../images/rocket.png" - "../images/rocket2.png" - "../images/sizeInOut.png" - "../images/snowflake.png" - "../images/sparkleSize.png" - "../images/starfish_0.png" - "../images/starfish_1.png" - "../images/starfish_2.png" - "../images/starfish_3.png" - "../images/starfish_4.png" - "../images/starfish_mask.png" -) - -qt6_add_resources(imageparticle "images" - PREFIX - "/particles" - BASE - ".." - FILES - ${images_resource_files} -) -set(shared_resource_files - "../../shared/Button.qml" - "../../shared/CheckBox.qml" - "../../shared/FlickrRssModel.qml" - "../../shared/Label.qml" - "../../shared/LauncherList.qml" - "../../shared/SimpleLauncherDelegate.qml" - "../../shared/Slider.qml" - "../../shared/TabSet.qml" - "../../shared/TextField.qml" - "../../shared/images/back.png" - "../../shared/images/checkmark.png" - "../../shared/images/next.png" - "../../shared/images/qt-logo.png" - "../../shared/images/slider_handle.png" - "../../shared/images/tab.png" -) - -qt6_add_resources(imageparticle "shared" - PREFIX - "/shared" - BASE - "../../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS imageparticle +qt_add_qml_module(imageparticleexample + URI imageparticle + VERSION 1.0 + QML_FILES + "allatonce.qml" + "colored.qml" + "colortable.qml" + "deformation.qml" + "imageparticle.qml" + "rotation.qml" + "sharing.qml" + "sprites.qml" + RESOURCES + "images/bear_tiles.png" + "images/colortable.png" + "images/starfish_0.png" + "images/starfish_1.png" + "images/starfish_2.png" + "images/starfish_3.png" + "images/starfish_4.png" + "images/flower.png" +) + +install(TARGETS imageparticleexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) + +bundle_shared(imageparticleexample) diff --git a/examples/quick/particles/imageparticle/allatonce.qml b/examples/quick/particles/imageparticle/allatonce.qml new file mode 100644 index 0000000000..5a250bc79a --- /dev/null +++ b/examples/quick/particles/imageparticle/allatonce.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + color: "white" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + + ImageParticle { + // ![0] + sprites: [ + Sprite { + name: "bear" + source: "images/bear_tiles.png" + frameCount: 13 + frameDuration: 120 + } + ] + colorVariation: 0.5 + rotationVelocityVariation: 360 + colorTable: "images/colortable.png" + // ![0] + system: sys + } + + Friction { + factor: 0.1 + system: sys + } + + Emitter { + system: sys + anchors.centerIn: parent + id: particles + emitRate: 200 + lifeSpan: 6000 + velocity: AngleDirection {angleVariation: 360; magnitude: 80; magnitudeVariation: 40} + size: 60 + endSize: 120 + } + + Text { + x: 16 + y: 16 + text: "QML..." + style: Text.Outline; styleColor: "#AAAAAA" + font.pixelSize: 32 + } + Text { + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: 16 + text: "... can you be trusted with the power?" + style: Text.Outline; styleColor: "#AAAAAA" + font.pixelSize: width > 400 ? 32 : 16 + } +} diff --git a/examples/quick/particles/imageparticle/colored.qml b/examples/quick/particles/imageparticle/colored.qml new file mode 100644 index 0000000000..11c4304457 --- /dev/null +++ b/examples/quick/particles/imageparticle/colored.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + width: 360 + height: 540 + color: "black" + ParticleSystem { + anchors.fill: parent + ImageParticle { + groups: ["stars"] + anchors.fill: parent + source: "qrc:///particleresources/star.png" + } + Emitter { + group: "stars" + emitRate: 800 + lifeSpan: 2400 + size: 24 + sizeVariation: 8 + anchors.fill: parent + } + + // ![0] + ImageParticle { + anchors.fill: parent + source: "qrc:///particleresources/star.png" + alpha: 0 + alphaVariation: 0.2 + colorVariation: 1.0 + } + // ![0] + + Emitter { + anchors.centerIn: parent + emitRate: 400 + lifeSpan: 2400 + size: 48 + sizeVariation: 8 + velocity: AngleDirection {angleVariation: 180; magnitude: 60} + } + + Turbulence { + anchors.fill: parent + strength: 2 + } + } +} diff --git a/examples/quick/particles/imageparticle/colortable.qml b/examples/quick/particles/imageparticle/colortable.qml new file mode 100644 index 0000000000..809ad345f9 --- /dev/null +++ b/examples/quick/particles/imageparticle/colortable.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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.Particles +import QtQuick + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + colorVariation: 0.5 + alpha: 0 + + //! [0] + source: "qrc:///particleresources/glowdot.png" + colorTable: "images/colortable.png" + sizeTable: "images/colortable.png" + //! [0] + } + + Emitter { + system: particles + emitRate: 500 + lifeSpan: 2000 + + y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 + x: root.width / 2 + Math.cos(t) * root.width * 0.3 + property real t; + + NumberAnimation on t { + from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite + } + + velocityFromMovement: 20 + + velocity: PointDirection { xVariation: 5; yVariation: 5;} + acceleration: PointDirection { xVariation: 5; yVariation: 5;} + + size: 16 + //endSize: 8 + //sizeVariation: 8 + } +} diff --git a/examples/quick/particles/imageparticle/content/allatonce.qml b/examples/quick/particles/imageparticle/content/allatonce.qml deleted file mode 100644 index 4b6c9b35cc..0000000000 --- a/examples/quick/particles/imageparticle/content/allatonce.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - color: "white" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - - ImageParticle { - // ![0] - sprites: [ - Sprite { - name: "bear" - source: "../../images/bear_tiles.png" - frameCount: 13 - frameDuration: 120 - } - ] - colorVariation: 0.5 - rotationVelocityVariation: 360 - colorTable: "../../images/colortable.png" - // ![0] - system: sys - } - - Friction { - factor: 0.1 - system: sys - } - - Emitter { - system: sys - anchors.centerIn: parent - id: particles - emitRate: 200 - lifeSpan: 6000 - velocity: AngleDirection {angleVariation: 360; magnitude: 80; magnitudeVariation: 40} - size: 60 - endSize: 120 - } - - Text { - x: 16 - y: 16 - text: "QML..." - style: Text.Outline; styleColor: "#AAAAAA" - font.pixelSize: 32 - } - Text { - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.margins: 16 - text: "... can you be trusted with the power?" - style: Text.Outline; styleColor: "#AAAAAA" - font.pixelSize: width > 400 ? 32 : 16 - } -} diff --git a/examples/quick/particles/imageparticle/content/colored.qml b/examples/quick/particles/imageparticle/content/colored.qml deleted file mode 100644 index 3452cad805..0000000000 --- a/examples/quick/particles/imageparticle/content/colored.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - ParticleSystem { - anchors.fill: parent - ImageParticle { - groups: ["stars"] - anchors.fill: parent - source: "qrc:///particleresources/star.png" - } - Emitter { - group: "stars" - emitRate: 800 - lifeSpan: 2400 - size: 24 - sizeVariation: 8 - anchors.fill: parent - } - - // ![0] - ImageParticle { - anchors.fill: parent - source: "qrc:///particleresources/star.png" - alpha: 0 - alphaVariation: 0.2 - colorVariation: 1.0 - } - // ![0] - - Emitter { - anchors.centerIn: parent - emitRate: 400 - lifeSpan: 2400 - size: 48 - sizeVariation: 8 - velocity: AngleDirection {angleVariation: 180; magnitude: 60} - } - - Turbulence { - anchors.fill: parent - strength: 2 - } - } -} diff --git a/examples/quick/particles/imageparticle/content/colortable.qml b/examples/quick/particles/imageparticle/content/colortable.qml deleted file mode 100644 index 5f88c1a8b3..0000000000 --- a/examples/quick/particles/imageparticle/content/colortable.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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.Particles 2.0 -import QtQuick 2.0 - -Rectangle { - id: root - width: 360 - height: 540 - color: "black" - - ParticleSystem { id: particles } - - ImageParticle { - system: particles - colorVariation: 0.5 - alpha: 0 - - //! [0] - source: "qrc:///particleresources/glowdot.png" - colorTable: "../../images/colortable.png" - sizeTable: "../../images/colortable.png" - //! [0] - } - - Emitter { - system: particles - emitRate: 500 - lifeSpan: 2000 - - y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 - x: root.width / 2 + Math.cos(t) * root.width * 0.3 - property real t; - - NumberAnimation on t { - from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite - } - - velocityFromMovement: 20 - - velocity: PointDirection { xVariation: 5; yVariation: 5;} - acceleration: PointDirection { xVariation: 5; yVariation: 5;} - - size: 16 - //endSize: 8 - //sizeVariation: 8 - } -} diff --git a/examples/quick/particles/imageparticle/content/deformation.qml b/examples/quick/particles/imageparticle/content/deformation.qml deleted file mode 100644 index ce672c8fa3..0000000000 --- a/examples/quick/particles/imageparticle/content/deformation.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 400 - height: 400 - ParticleSystem {id:sys} - - //! [spin] - ImageParticle { - system: sys - groups: ["goingLeft", "goingRight"] - source: "../../images/starfish_4.png" - rotation: 90 - rotationVelocity: 90 - autoRotation: true - } - //! [spin] - //! [deform] - ImageParticle { - system: sys - groups: ["goingDown"] - source: "../../images/starfish_0.png" - rotation: 180 - yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } - } - //! [deform] - - Timer { - running: true - repeat: false - interval: 100 - onTriggered: emitA.enabled = true; - } - Timer { - running: true - repeat: false - interval: 4200 - onTriggered: emitB.enabled = true; - } - Timer { - running: true - repeat: false - interval: 8400 - onTriggered: emitC.enabled = true; - } - - Emitter { - id: emitA - x: 0 - y: 120 - system: sys - enabled: false - group: "goingRight" - velocity: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitB - x: 400 - y: 240 - system: sys - enabled: false - group: "goingLeft" - velocity: PointDirection { x: -100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitC - x: 0 - y: 360 - system: sys - enabled: false - group: "goingDown" - velocity: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } -} diff --git a/examples/quick/particles/imageparticle/content/rotation.qml b/examples/quick/particles/imageparticle/content/rotation.qml deleted file mode 100644 index d118bb1d97..0000000000 --- a/examples/quick/particles/imageparticle/content/rotation.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 2000 - height: 2000 - ParticleSystem {id: sys} - ImageParticle { - id: up - system: sys - source: "../../images/starfish_2.png" - autoRotation: true //leaving these two settings at default allows you to test going up performance levels - rotation: -90 - } - - Emitter { - anchors.centerIn: parent - system: sys - emitRate: 10 - size: 200 - lifeSpan: 10000 - velocity: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} - } - - MouseArea { - anchors.fill: parent - onClicked: { - up.autoRotation = !up.autoRotation - up.rotation = up.autoRotation ? -90 : 0 - } - } -} diff --git a/examples/quick/particles/imageparticle/content/sharing.qml b/examples/quick/particles/imageparticle/content/sharing.qml deleted file mode 100644 index 13b0dadf85..0000000000 --- a/examples/quick/particles/imageparticle/content/sharing.qml +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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$ -** -****************************************************************************/ - -// This example shows how to create your own highlight delegate for a ListView -// that uses a SpringAnimation to provide custom movement when the -// highlight bar is moved between items. - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - - property real delegateHeight: 65 - width: 200; height: 300 - gradient: Gradient { - GradientStop { position: 0.0; color: "#EEEEFF" } - GradientStop { position: 1.0; color: "lightblue" } - } - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - component PetDelegate: Item { - id: pet - width: 200; height: root.delegateHeight - z: 10 - - required property int index - required property string name - required property string type - required property int age - - Column { - Text {color: "white"; text: pet.name; font.pixelSize: 18 } - Text {color: "white"; text: 'Type: ' + pet.type; font.pixelSize: 14 } - Text {color: "white"; text: 'Age: ' + pet.age; font.pixelSize: 14 } - } - MouseArea { anchors.fill: parent; onClicked: listView.currentIndex = pet.index; } - // indent the item if it is the current item - states: State { - name: "Current" - when: pet.ListView.isCurrentItem - PropertyChanges { target: pet; x: 20 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - - // Define a highlight with customized movement between items. - component HighlightBar : Rectangle { - z: 0 - width: 200; height: root.delegateHeight - gradient: Gradient { - GradientStop { position: 0.0; color: "#99FF99" } - GradientStop { position: 1.0; color: "#88FF88" } - } - y: listView.currentItem.y; - Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } - //! [1] - ImageParticle { - anchors.fill: parent - system: particles - source: "../../images/flower.png" - color: "red" - clip: true - alpha: 1.0 - } - //! [1] - } - - ListView { - id: listView - width: 200; height: parent.height - - model: petsModel - delegate: PetDelegate {} - focus: true - - // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem - // to false so the highlight delegate can control how the highlight is moved. - highlight: HighlightBar {} - highlightFollowsCurrentItem: false - - ParticleSystem { id: particles } - Emitter { - system: particles - anchors.fill: parent - emitRate: 0 - lifeSpan: 10000 - size: 24 - sizeVariation: 8 - velocity: AngleDirection { angleVariation: 360; magnitude: 3 } - maximumEmitted: 10 - startTime: 5000 - Timer { running: true; interval: 10; onTriggered: parent.emitRate = 1; } - } - - //! [0] - ImageParticle { - anchors.fill: parent - system: particles - source: "../../images/flower.png" - alpha: 0.1 - color: "white" - rotationVariation: 180 - z: -1 - } - //! [0] - } - - ListModel { - id: petsModel - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } - } - -} diff --git a/examples/quick/particles/imageparticle/content/sprites.qml b/examples/quick/particles/imageparticle/content/sprites.qml deleted file mode 100644 index c8ffe6c0e5..0000000000 --- a/examples/quick/particles/imageparticle/content/sprites.qml +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - color: "lightsteelblue" - width: 800 - height: 800 - id: root - - SpriteSequence { - sprites: Sprite { - name: "bear" - source: "../../images/bear_tiles.png" - frameCount: 13 - frameDuration: 120 - } - width: 250 - height: 250 - x: 20 - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - z:4 - } - - ParticleSystem { id: sys } - - ImageParticle { - anchors.fill: parent - id: particles - system: sys - sprites: [Sprite { - name: "happy" - source: "../../images/starfish_1.png" - frameCount: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "angry" - source: "../../images/starfish_0.png" - frameCount: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "silly" - source: "../../images/starfish_2.png" - frameCount: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "noticedbear": 0} - }, Sprite { - name: "noticedbear" - source: "../../images/starfish_3.png" - frameCount: 1 - frameDuration: 2600 - }] - } - - Emitter { - system: sys - emitRate: 2 - lifeSpan: 10000 - velocity: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} - acceleration: PointDirection { y: 10 } - size: 160 - sizeVariation: 40 - width: parent.width - height: 100 - } - - SpriteGoal { - system: sys - width: root.width; - height: root.height/2; - y: root.height/2; - goalState:"noticedbear" - } -} diff --git a/examples/quick/particles/imageparticle/deformation.qml b/examples/quick/particles/imageparticle/deformation.qml new file mode 100644 index 0000000000..f8f0f31e33 --- /dev/null +++ b/examples/quick/particles/imageparticle/deformation.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + color: "goldenrod" + width: 400 + height: 400 + ParticleSystem {id:sys} + + //! [spin] + ImageParticle { + system: sys + groups: ["goingLeft", "goingRight"] + source: "images/starfish_4.png" + rotation: 90 + rotationVelocity: 90 + autoRotation: true + } + //! [spin] + //! [deform] + ImageParticle { + system: sys + groups: ["goingDown"] + source: "images/starfish_0.png" + rotation: 180 + yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } + } + //! [deform] + + Timer { + running: true + repeat: false + interval: 100 + onTriggered: emitA.enabled = true; + } + Timer { + running: true + repeat: false + interval: 4200 + onTriggered: emitB.enabled = true; + } + Timer { + running: true + repeat: false + interval: 8400 + onTriggered: emitC.enabled = true; + } + + Emitter { + id: emitA + x: 0 + y: 120 + system: sys + enabled: false + group: "goingRight" + velocity: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitB + x: 400 + y: 240 + system: sys + enabled: false + group: "goingLeft" + velocity: PointDirection { x: -100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitC + x: 0 + y: 360 + system: sys + enabled: false + group: "goingDown" + velocity: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } +} diff --git a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc index 6a71e1f5fd..9ef3228126 100644 --- a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc +++ b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc @@ -35,25 +35,25 @@ Each example is a small QML file emphasizing a particular type or feature. All at once shows off several of the features of ImageParticle at the same time. - \snippet particles/imageparticle/content/allatonce.qml 0 + \snippet particles/imageparticle/allatonce.qml 0 Colored shows a simple ImageParticle with some color variation. - \snippet particles/imageparticle/content/colored.qml 0 + \snippet particles/imageparticle/colored.qml 0 Color Table sets the color over life on the particles to provide a fixed rainbow effect. - \snippet particles/imageparticle/content/colortable.qml 0 + \snippet particles/imageparticle/colortable.qml 0 Deformation spins and squishes a starfish particle. - \snippet particles/imageparticle/content/deformation.qml spin - \snippet particles/imageparticle/content/deformation.qml deform + \snippet particles/imageparticle/deformation.qml spin + \snippet particles/imageparticle/deformation.qml deform Rotation demonstrates the autoRotate property, so that particles rotate in the direction that they travel. Sharing demonstrates what happens when multiple ImageParticles try to render the same particle. The following ImageParticle renders the particles inside the ListView: - \snippet particles/imageparticle/content/sharing.qml 0 + \snippet particles/imageparticle/sharing.qml 0 The following ImageParticle is placed inside the list highlight, and renders the particles above the other ImageParticle. - \snippet particles/imageparticle/content/sharing.qml 1 + \snippet particles/imageparticle/sharing.qml 1 Note that because it sets the color and alpha in this ImageParticle, it renders the particles in a different color. Since it doesn't specify anything about the rotation, it shares the rotation with the other ImageParticle so that the flowers are rotated the same way in both. Note that you can undo rotation in another ImageParticle, you just need to explicitly set rotationVariation to 0. diff --git a/examples/quick/particles/imageparticle/imageparticle.pro b/examples/quick/particles/imageparticle/imageparticle.pro index e639c7423a..c9c5e59eb0 100644 --- a/examples/quick/particles/imageparticle/imageparticle.pro +++ b/examples/quick/particles/imageparticle/imageparticle.pro @@ -4,7 +4,6 @@ QT += quick qml SOURCES += main.cpp RESOURCES += \ imageparticle.qrc \ - ../images.qrc \ ../../shared/shared.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/particles/imageparticle diff --git a/examples/quick/particles/imageparticle/imageparticle.qml b/examples/quick/particles/imageparticle/imageparticle.qml index a8dfa6a0c9..0423e72e28 100644 --- a/examples/quick/particles/imageparticle/imageparticle.qml +++ b/examples/quick/particles/imageparticle/imageparticle.qml @@ -48,23 +48,23 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import "../../shared" as Examples +import QtQuick +import shared Item { height: 480 width: 320 - Examples.LauncherList { + LauncherList { id: ll anchors.fill: parent Component.onCompleted: { - addExample("All at once", "Uses all ImageParticle features", Qt.resolvedUrl("content/allatonce.qml")); - addExample("Colored", "Colorized image particles", Qt.resolvedUrl("content/colored.qml")); - addExample("Color Table", "Color-over-life rainbow particles", Qt.resolvedUrl("content/colortable.qml")); - addExample("Deformation", "Deformed particles", Qt.resolvedUrl("content/deformation.qml")); - addExample("Rotation", "Rotated particles", Qt.resolvedUrl("content/rotation.qml")); - addExample("Sharing", "Multiple ImageParticles on the same particles", Qt.resolvedUrl("content/sharing.qml")); - addExample("Sprites", "Particles rendered with sprites", Qt.resolvedUrl("content/sprites.qml")); + addExample("All at once", "Uses all ImageParticle features", Qt.resolvedUrl("allatonce.qml")); + addExample("Colored", "Colorized image particles", Qt.resolvedUrl("colored.qml")); + addExample("Color Table", "Color-over-life rainbow particles", Qt.resolvedUrl("colortable.qml")); + addExample("Deformation", "Deformed particles", Qt.resolvedUrl("deformation.qml")); + addExample("Rotation", "Rotated particles", Qt.resolvedUrl("rotation.qml")); + addExample("Sharing", "Multiple ImageParticles on the same particles", Qt.resolvedUrl("sharing.qml")); + addExample("Sprites", "Particles rendered with sprites", Qt.resolvedUrl("sprites.qml")); } } } diff --git a/examples/quick/particles/imageparticle/imageparticle.qrc b/examples/quick/particles/imageparticle/imageparticle.qrc index d9e4115e3e..ef9bddaaae 100644 --- a/examples/quick/particles/imageparticle/imageparticle.qrc +++ b/examples/quick/particles/imageparticle/imageparticle.qrc @@ -1,12 +1,20 @@ - + imageparticle.qml - content/allatonce.qml - content/colored.qml - content/colortable.qml - content/deformation.qml - content/rotation.qml - content/sharing.qml - content/sprites.qml + allatonce.qml + colored.qml + colortable.qml + deformation.qml + rotation.qml + sharing.qml + sprites.qml + images/bear_tiles.png + images/colortable.png + images/starfish_0.png + images/starfish_1.png + images/starfish_2.png + images/starfish_3.png + images/starfish_4.png + images/flower.png diff --git a/examples/quick/particles/imageparticle/images/bear_tiles.png b/examples/quick/particles/imageparticle/images/bear_tiles.png new file mode 100644 index 0000000000..6bbb2a9b6d Binary files /dev/null and b/examples/quick/particles/imageparticle/images/bear_tiles.png differ diff --git a/examples/quick/particles/imageparticle/images/colortable.png b/examples/quick/particles/imageparticle/images/colortable.png new file mode 100644 index 0000000000..15509ab5b7 Binary files /dev/null and b/examples/quick/particles/imageparticle/images/colortable.png differ diff --git a/examples/quick/particles/imageparticle/images/flower.png b/examples/quick/particles/imageparticle/images/flower.png new file mode 100644 index 0000000000..b5c606210e Binary files /dev/null and b/examples/quick/particles/imageparticle/images/flower.png differ diff --git a/examples/quick/particles/imageparticle/images/starfish_0.png b/examples/quick/particles/imageparticle/images/starfish_0.png new file mode 100644 index 0000000000..8747f0236e Binary files /dev/null and b/examples/quick/particles/imageparticle/images/starfish_0.png differ diff --git a/examples/quick/particles/imageparticle/images/starfish_1.png b/examples/quick/particles/imageparticle/images/starfish_1.png new file mode 100644 index 0000000000..1f3f159d5e Binary files /dev/null and b/examples/quick/particles/imageparticle/images/starfish_1.png differ diff --git a/examples/quick/particles/imageparticle/images/starfish_2.png b/examples/quick/particles/imageparticle/images/starfish_2.png new file mode 100644 index 0000000000..c6c7e5a676 Binary files /dev/null and b/examples/quick/particles/imageparticle/images/starfish_2.png differ diff --git a/examples/quick/particles/imageparticle/images/starfish_3.png b/examples/quick/particles/imageparticle/images/starfish_3.png new file mode 100644 index 0000000000..307a89f815 Binary files /dev/null and b/examples/quick/particles/imageparticle/images/starfish_3.png differ diff --git a/examples/quick/particles/imageparticle/images/starfish_4.png b/examples/quick/particles/imageparticle/images/starfish_4.png new file mode 100644 index 0000000000..d61c26545a Binary files /dev/null and b/examples/quick/particles/imageparticle/images/starfish_4.png differ diff --git a/examples/quick/particles/imageparticle/main.cpp b/examples/quick/particles/imageparticle/main.cpp index ff0764a730..a831728d0b 100644 --- a/examples/quick/particles/imageparticle/main.cpp +++ b/examples/quick/particles/imageparticle/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(particles/imageparticle/imageparticle) +DECLARATIVE_EXAMPLE_MAIN(imageparticle/imageparticle) diff --git a/examples/quick/particles/imageparticle/rotation.qml b/examples/quick/particles/imageparticle/rotation.qml new file mode 100644 index 0000000000..f7b101d0c2 --- /dev/null +++ b/examples/quick/particles/imageparticle/rotation.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + color: "goldenrod" + width: 2000 + height: 2000 + ParticleSystem {id: sys} + ImageParticle { + id: up + system: sys + source: "images/starfish_2.png" + autoRotation: true //leaving these two settings at default allows you to test going up performance levels + rotation: -90 + } + + Emitter { + anchors.centerIn: parent + system: sys + emitRate: 10 + size: 200 + lifeSpan: 10000 + velocity: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} + } + + MouseArea { + anchors.fill: parent + onClicked: { + up.autoRotation = !up.autoRotation + up.rotation = up.autoRotation ? -90 : 0 + } + } +} diff --git a/examples/quick/particles/imageparticle/sharing.qml b/examples/quick/particles/imageparticle/sharing.qml new file mode 100644 index 0000000000..365d2e99fd --- /dev/null +++ b/examples/quick/particles/imageparticle/sharing.qml @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick +import QtQuick.Particles + +Rectangle { + id: root + + property real delegateHeight: 65 + width: 200; height: 300 + gradient: Gradient { + GradientStop { position: 0.0; color: "#EEEEFF" } + GradientStop { position: 1.0; color: "lightblue" } + } + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + component PetDelegate: Item { + id: pet + width: 200; height: root.delegateHeight + z: 10 + + required property int index + required property string name + required property string type + required property int age + + Column { + Text {color: "white"; text: pet.name; font.pixelSize: 18 } + Text {color: "white"; text: 'Type: ' + pet.type; font.pixelSize: 14 } + Text {color: "white"; text: 'Age: ' + pet.age; font.pixelSize: 14 } + } + MouseArea { anchors.fill: parent; onClicked: listView.currentIndex = pet.index; } + // indent the item if it is the current item + states: State { + name: "Current" + when: pet.ListView.isCurrentItem + PropertyChanges { target: pet; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + + // Define a highlight with customized movement between items. + component HighlightBar : Rectangle { + z: 0 + width: 200; height: root.delegateHeight + gradient: Gradient { + GradientStop { position: 0.0; color: "#99FF99" } + GradientStop { position: 1.0; color: "#88FF88" } + } + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } + //! [1] + ImageParticle { + anchors.fill: parent + system: particles + source: "images/flower.png" + color: "red" + clip: true + alpha: 1.0 + } + //! [1] + } + + ListView { + id: listView + width: 200; height: parent.height + + model: petsModel + delegate: PetDelegate {} + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: HighlightBar {} + highlightFollowsCurrentItem: false + + ParticleSystem { id: particles } + Emitter { + system: particles + anchors.fill: parent + emitRate: 0 + lifeSpan: 10000 + size: 24 + sizeVariation: 8 + velocity: AngleDirection { angleVariation: 360; magnitude: 3 } + maximumEmitted: 10 + startTime: 5000 + Timer { running: true; interval: 10; onTriggered: parent.emitRate = 1; } + } + + //! [0] + ImageParticle { + anchors.fill: parent + system: particles + source: "images/flower.png" + alpha: 0.1 + color: "white" + rotationVariation: 180 + z: -1 + } + //! [0] + } + + ListModel { + id: petsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } + } + +} diff --git a/examples/quick/particles/imageparticle/sprites.qml b/examples/quick/particles/imageparticle/sprites.qml new file mode 100644 index 0000000000..3e7d09bdde --- /dev/null +++ b/examples/quick/particles/imageparticle/sprites.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + color: "lightsteelblue" + width: 800 + height: 800 + id: root + + SpriteSequence { + sprites: Sprite { + name: "bear" + source: "images/bear_tiles.png" + frameCount: 13 + frameDuration: 120 + } + width: 250 + height: 250 + x: 20 + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 + z:4 + } + + ParticleSystem { id: sys } + + ImageParticle { + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite { + name: "happy" + source: "images/starfish_1.png" + frameCount: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "angry" + source: "images/starfish_0.png" + frameCount: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "silly" + source: "images/starfish_2.png" + frameCount: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "noticedbear": 0} + }, Sprite { + name: "noticedbear" + source: "images/starfish_3.png" + frameCount: 1 + frameDuration: 2600 + }] + } + + Emitter { + system: sys + emitRate: 2 + lifeSpan: 10000 + velocity: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} + acceleration: PointDirection { y: 10 } + size: 160 + sizeVariation: 40 + width: parent.width + height: 100 + } + + SpriteGoal { + system: sys + width: root.width; + height: root.height/2; + y: root.height/2; + goalState:"noticedbear" + } +} diff --git a/examples/quick/particles/images.qrc b/examples/quick/particles/images.qrc deleted file mode 100644 index 1f754838a8..0000000000 --- a/examples/quick/particles/images.qrc +++ /dev/null @@ -1,35 +0,0 @@ - - - images/_explo.png - images/backgroundLeaves.jpg - images/bear_tiles.png - images/candle.png - images/colortable.png - images/finalfrontier.png - images/flower.png - images/matchmask.png - images/meteor_explo.png - images/meteor.png - images/meteors.png - images/nullRock.png - images/particle2.png - images/particle3.png - images/particleA.png - images/portal_bg.png - images/realLeaf1.png - images/realLeaf2.png - images/realLeaf3.png - images/realLeaf4.png - images/rocket.png - images/rocket2.png - images/sizeInOut.png - images/snowflake.png - images/sparkleSize.png - images/starfish_0.png - images/starfish_1.png - images/starfish_2.png - images/starfish_3.png - images/starfish_4.png - images/starfish_mask.png - - diff --git a/examples/quick/particles/images/_explo.png b/examples/quick/particles/images/_explo.png deleted file mode 100644 index 4297245d49..0000000000 Binary files a/examples/quick/particles/images/_explo.png and /dev/null differ diff --git a/examples/quick/particles/images/backgroundLeaves.jpg b/examples/quick/particles/images/backgroundLeaves.jpg deleted file mode 100644 index 08be16751d..0000000000 Binary files a/examples/quick/particles/images/backgroundLeaves.jpg and /dev/null differ diff --git a/examples/quick/particles/images/bear_tiles.png b/examples/quick/particles/images/bear_tiles.png deleted file mode 100644 index 6bbb2a9b6d..0000000000 Binary files a/examples/quick/particles/images/bear_tiles.png and /dev/null differ diff --git a/examples/quick/particles/images/candle.png b/examples/quick/particles/images/candle.png deleted file mode 100644 index 8fa3193719..0000000000 Binary files a/examples/quick/particles/images/candle.png and /dev/null differ diff --git a/examples/quick/particles/images/colortable.png b/examples/quick/particles/images/colortable.png deleted file mode 100644 index 15509ab5b7..0000000000 Binary files a/examples/quick/particles/images/colortable.png and /dev/null differ diff --git a/examples/quick/particles/images/finalfrontier.png b/examples/quick/particles/images/finalfrontier.png deleted file mode 100644 index 2ba1815230..0000000000 Binary files a/examples/quick/particles/images/finalfrontier.png and /dev/null differ diff --git a/examples/quick/particles/images/flower.png b/examples/quick/particles/images/flower.png deleted file mode 100644 index b5c606210e..0000000000 Binary files a/examples/quick/particles/images/flower.png and /dev/null differ diff --git a/examples/quick/particles/images/matchmask.png b/examples/quick/particles/images/matchmask.png deleted file mode 100644 index e575875c55..0000000000 Binary files a/examples/quick/particles/images/matchmask.png and /dev/null differ diff --git a/examples/quick/particles/images/meteor.png b/examples/quick/particles/images/meteor.png deleted file mode 100644 index e8c368aea7..0000000000 Binary files a/examples/quick/particles/images/meteor.png and /dev/null differ diff --git a/examples/quick/particles/images/meteor_explo.png b/examples/quick/particles/images/meteor_explo.png deleted file mode 100644 index e659bfe2cf..0000000000 Binary files a/examples/quick/particles/images/meteor_explo.png and /dev/null differ diff --git a/examples/quick/particles/images/meteors.png b/examples/quick/particles/images/meteors.png deleted file mode 100644 index bada8a1407..0000000000 Binary files a/examples/quick/particles/images/meteors.png and /dev/null differ diff --git a/examples/quick/particles/images/nullRock.png b/examples/quick/particles/images/nullRock.png deleted file mode 100644 index 4076327a1a..0000000000 Binary files a/examples/quick/particles/images/nullRock.png and /dev/null differ diff --git a/examples/quick/particles/images/particle2.png b/examples/quick/particles/images/particle2.png deleted file mode 100644 index 4f3372cd07..0000000000 Binary files a/examples/quick/particles/images/particle2.png and /dev/null differ diff --git a/examples/quick/particles/images/particle3.png b/examples/quick/particles/images/particle3.png deleted file mode 100644 index 2b04601403..0000000000 Binary files a/examples/quick/particles/images/particle3.png and /dev/null differ diff --git a/examples/quick/particles/images/particleA.png b/examples/quick/particles/images/particleA.png deleted file mode 100644 index d86fc9696b..0000000000 Binary files a/examples/quick/particles/images/particleA.png and /dev/null differ diff --git a/examples/quick/particles/images/portal_bg.png b/examples/quick/particles/images/portal_bg.png deleted file mode 100644 index 3c59eeabb9..0000000000 Binary files a/examples/quick/particles/images/portal_bg.png and /dev/null differ diff --git a/examples/quick/particles/images/realLeaf1.png b/examples/quick/particles/images/realLeaf1.png deleted file mode 100644 index 6cabf29efd..0000000000 Binary files a/examples/quick/particles/images/realLeaf1.png and /dev/null differ diff --git a/examples/quick/particles/images/realLeaf2.png b/examples/quick/particles/images/realLeaf2.png deleted file mode 100644 index bfeca861d5..0000000000 Binary files a/examples/quick/particles/images/realLeaf2.png and /dev/null differ diff --git a/examples/quick/particles/images/realLeaf3.png b/examples/quick/particles/images/realLeaf3.png deleted file mode 100644 index b1071e862b..0000000000 Binary files a/examples/quick/particles/images/realLeaf3.png and /dev/null differ diff --git a/examples/quick/particles/images/realLeaf4.png b/examples/quick/particles/images/realLeaf4.png deleted file mode 100644 index d61d53d10e..0000000000 Binary files a/examples/quick/particles/images/realLeaf4.png and /dev/null differ diff --git a/examples/quick/particles/images/rocket.png b/examples/quick/particles/images/rocket.png deleted file mode 100644 index a171610b03..0000000000 Binary files a/examples/quick/particles/images/rocket.png and /dev/null differ diff --git a/examples/quick/particles/images/rocket2.png b/examples/quick/particles/images/rocket2.png deleted file mode 100644 index 7110f8fdc6..0000000000 Binary files a/examples/quick/particles/images/rocket2.png and /dev/null differ diff --git a/examples/quick/particles/images/sizeInOut.png b/examples/quick/particles/images/sizeInOut.png deleted file mode 100644 index 43d8862dbe..0000000000 Binary files a/examples/quick/particles/images/sizeInOut.png and /dev/null differ diff --git a/examples/quick/particles/images/snowflake.png b/examples/quick/particles/images/snowflake.png deleted file mode 100644 index 490887a82f..0000000000 Binary files a/examples/quick/particles/images/snowflake.png and /dev/null differ diff --git a/examples/quick/particles/images/sparkleSize.png b/examples/quick/particles/images/sparkleSize.png deleted file mode 100644 index 752056541b..0000000000 Binary files a/examples/quick/particles/images/sparkleSize.png and /dev/null differ diff --git a/examples/quick/particles/images/starfish_0.png b/examples/quick/particles/images/starfish_0.png deleted file mode 100644 index 8747f0236e..0000000000 Binary files a/examples/quick/particles/images/starfish_0.png and /dev/null differ diff --git a/examples/quick/particles/images/starfish_1.png b/examples/quick/particles/images/starfish_1.png deleted file mode 100644 index 1f3f159d5e..0000000000 Binary files a/examples/quick/particles/images/starfish_1.png and /dev/null differ diff --git a/examples/quick/particles/images/starfish_2.png b/examples/quick/particles/images/starfish_2.png deleted file mode 100644 index c6c7e5a676..0000000000 Binary files a/examples/quick/particles/images/starfish_2.png and /dev/null differ diff --git a/examples/quick/particles/images/starfish_3.png b/examples/quick/particles/images/starfish_3.png deleted file mode 100644 index 307a89f815..0000000000 Binary files a/examples/quick/particles/images/starfish_3.png and /dev/null differ diff --git a/examples/quick/particles/images/starfish_4.png b/examples/quick/particles/images/starfish_4.png deleted file mode 100644 index d61c26545a..0000000000 Binary files a/examples/quick/particles/images/starfish_4.png and /dev/null differ diff --git a/examples/quick/particles/images/starfish_mask.png b/examples/quick/particles/images/starfish_mask.png deleted file mode 100644 index 7ae39b34c5..0000000000 Binary files a/examples/quick/particles/images/starfish_mask.png and /dev/null differ diff --git a/examples/quick/particles/itemparticle/CMakeLists.txt b/examples/quick/particles/itemparticle/CMakeLists.txt index 1c435c3c1b..6df338e00e 100644 --- a/examples/quick/particles/itemparticle/CMakeLists.txt +++ b/examples/quick/particles/itemparticle/CMakeLists.txt @@ -1,13 +1,9 @@ -# Generated from itemparticle.pro. - cmake_minimum_required(VERSION 3.16) project(itemparticle LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) set(INSTALL_EXAMPLESDIR "examples") @@ -15,119 +11,38 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/itemparticle") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Core Gui Quick Qml) + +add_subdirectory("../../shared" "shared") -qt_add_executable(itemparticle +qt_add_executable(itemparticleexample WIN32 MACOSX_BUNDLE main.cpp ) -set_target_properties(itemparticle PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(itemparticle PUBLIC +target_link_libraries(itemparticleexample PUBLIC Qt::Core Qt::Gui Qt::Qml Qt::Quick ) - -file(GLOB resource_glob_0 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "content/*") -foreach(file IN LISTS resource_glob_0) - set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}") -endforeach() - -file(GLOB resource_glob_1 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*qml") -foreach(file IN LISTS resource_glob_1) - set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}") -endforeach() +add_dependencies(itemparticleexample itemparticle_shared) # Resources: -set(images_resource_files - "../images/_explo.png" - "../images/backgroundLeaves.jpg" - "../images/bear_tiles.png" - "../images/candle.png" - "../images/colortable.png" - "../images/finalfrontier.png" - "../images/flower.png" - "../images/matchmask.png" - "../images/meteor.png" - "../images/meteor_explo.png" - "../images/meteors.png" - "../images/nullRock.png" - "../images/particle2.png" - "../images/particle3.png" - "../images/particleA.png" - "../images/portal_bg.png" - "../images/realLeaf1.png" - "../images/realLeaf2.png" - "../images/realLeaf3.png" - "../images/realLeaf4.png" - "../images/rocket.png" - "../images/rocket2.png" - "../images/sizeInOut.png" - "../images/snowflake.png" - "../images/sparkleSize.png" - "../images/starfish_0.png" - "../images/starfish_1.png" - "../images/starfish_2.png" - "../images/starfish_3.png" - "../images/starfish_4.png" - "../images/starfish_mask.png" -) - -qt6_add_resources(itemparticle "images" - PREFIX - "/particles" - BASE - ".." - FILES - ${images_resource_files} -) -set(shared_resource_files - "../../shared/Button.qml" - "../../shared/CheckBox.qml" - "../../shared/FlickrRssModel.qml" - "../../shared/Label.qml" - "../../shared/LauncherList.qml" - "../../shared/SimpleLauncherDelegate.qml" - "../../shared/Slider.qml" - "../../shared/TabSet.qml" - "../../shared/TextField.qml" - "../../shared/images/back.png" - "../../shared/images/checkmark.png" - "../../shared/images/next.png" - "../../shared/images/qt-logo.png" - "../../shared/images/slider_handle.png" - "../../shared/images/tab.png" -) - -qt6_add_resources(itemparticle "shared" - PREFIX - "/shared" - BASE - "../../shared" - FILES - ${shared_resource_files} -) -set(qmake_immediate_resource_files - ${resource_glob_0} - ${resource_glob_1} -) - -qt6_add_resources(itemparticle "qmake_immediate" - PREFIX - "/" - FILES - ${qmake_immediate_resource_files} -) - -install(TARGETS itemparticle +qt_add_qml_module(itemparticleexample + URI itemparticle + VERSION 1.0 + QML_FILES + "itemparticle.qml" + "delegates.qml" + "script.js" + RESOURCES + "images/rocket.png" +) + +install(TARGETS itemparticleexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) + +bundle_shared(itemparticleexample) diff --git a/examples/quick/particles/itemparticle/content/Delegate.qml b/examples/quick/particles/itemparticle/content/Delegate.qml deleted file mode 100644 index 946b7b8748..0000000000 --- a/examples/quick/particles/itemparticle/content/Delegate.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 - -//![0] -Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: 200; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//![0] diff --git a/examples/quick/particles/itemparticle/content/Delegate2.qml b/examples/quick/particles/itemparticle/content/Delegate2.qml deleted file mode 100644 index 03465609d9..0000000000 --- a/examples/quick/particles/itemparticle/content/Delegate2.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 - -//![0] -Package { - Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } - Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' - - Rectangle { - id: wrapper - width: w; height: h; - color: col - rotation: Math.random()*360 - Behavior on rotation {RotationAnimation {}} - - states: State { - name: "gridded" - when: root.inGrid - PropertyChanges { - target: wrapper - rotation: 0 - } - ParentChange { - target: wrapper - parent: gridDelegate - x:0 - y:0 - } - } - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } - } -} -//![0] diff --git a/examples/quick/particles/itemparticle/content/ExpandingDelegate.qml b/examples/quick/particles/itemparticle/content/ExpandingDelegate.qml deleted file mode 100644 index 9ffbc7f350..0000000000 --- a/examples/quick/particles/itemparticle/content/ExpandingDelegate.qml +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "../../../modelviews/listview/content" - -// This example illustrates expanding a list item to show a more detailed view. - - // Delegate for the recipes. This delegate has two modes: - // 1. List mode (default), which just shows the picture and title of the recipe. - // 2. Details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: recipe - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - //this bit changed for aesthetics - width: 70 - height: 70 - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 - color: "ivory" - border.color: "orange" - radius: 5 - antialiasing: true - } - Image { - anchors.fill:parent - anchors.margins: -32 - source: "bubble.png" - } - - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - anchors.fill: parent - onClicked: recipe.state = 'Details'; - } - - // Lay out the page: picture, title and ingredients at the top, and method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to recipe.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipeImage.height; width: parent.width - spacing: 10 - - Image { - id: recipeImage - width: 50; height: 50 - source: "../../modelviews/listview/" + picture - } - - Column { - width: background.width - recipeImage.width - 20; height: recipeImage.height - spacing: 5 - - Text { - text: title - font.bold: true; font.pointSize: 16 - } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: recipe.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: recipe.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width - 20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: recipe.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height - clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "../../modelviews/listview/" + "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "../../modelviews/listview/" + "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - TextButton { - y: 10 - anchors { right: background.right; rightMargin: 10 } - opacity: recipe.detailsOpacity - text: "Close" - - onClicked: recipe.state = ''; - } - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger - PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible - PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } - - // Disallow flicking while we're in detailed view - //PropertyChanges { target: recipe.ListView.view; interactive: false } - } - - transitions: Transition { - //The only strictly necessary particle specific lines - to: "Details" - reversible: true - ScriptAction {script: { - if(state == "Details") - mp.freeze(index); - else - mp.unfreeze(index); - } - } - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } - } - } - } - } diff --git a/examples/quick/particles/itemparticle/content/bubble.png b/examples/quick/particles/itemparticle/content/bubble.png deleted file mode 100644 index f26ed1d3f2..0000000000 Binary files a/examples/quick/particles/itemparticle/content/bubble.png and /dev/null differ diff --git a/examples/quick/particles/itemparticle/content/script.js b/examples/quick/particles/itemparticle/content/script.js deleted file mode 100644 index e8ef93a847..0000000000 --- a/examples/quick/particles/itemparticle/content/script.js +++ /dev/null @@ -1,27 +0,0 @@ -.pragma library - -function getWidth(string) { - return (string.match(/width=\"([0-9]+)\"/))[1] -} - -function getHeight(string) { - return (string.match(/height=\"([0-9]+)\"/))[1] -} - -function getImagePath(string) { - var pattern = /src=\"http:\/\/(\S+)\"/ - return (string.match(pattern))[1] -} - -function calculateScale(width, height, cellSize) { - var widthScale = (cellSize * 1.0) / width - var heightScale = (cellSize * 1.0) / height - var scale = 0 - - if (widthScale <= heightScale) { - scale = widthScale; - } else if (heightScale < widthScale) { - scale = heightScale; - } - return scale; -} diff --git a/examples/quick/particles/itemparticle/delegates.qml b/examples/quick/particles/itemparticle/delegates.qml index 0e9267214f..a53c719828 100644 --- a/examples/quick/particles/itemparticle/delegates.qml +++ b/examples/quick/particles/itemparticle/delegates.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles Rectangle { id: root; diff --git a/examples/quick/particles/itemparticle/images/rocket.png b/examples/quick/particles/itemparticle/images/rocket.png new file mode 100644 index 0000000000..a171610b03 Binary files /dev/null and b/examples/quick/particles/itemparticle/images/rocket.png differ diff --git a/examples/quick/particles/itemparticle/itemparticle.pro b/examples/quick/particles/itemparticle/itemparticle.pro index f5c0576b4a..c0426cd032 100644 --- a/examples/quick/particles/itemparticle/itemparticle.pro +++ b/examples/quick/particles/itemparticle/itemparticle.pro @@ -3,10 +3,8 @@ TEMPLATE = app QT += quick qml SOURCES += main.cpp RESOURCES += \ - ../images.qrc \ - ../../shared/shared.qrc \ - $$files("content/*") \ - $$files("*qml") + itemparticle.qrc \ + ../../shared/shared.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/particles/itemparticle INSTALLS += target diff --git a/examples/quick/particles/itemparticle/itemparticle.qml b/examples/quick/particles/itemparticle/itemparticle.qml new file mode 100644 index 0000000000..ad2038fdbf --- /dev/null +++ b/examples/quick/particles/itemparticle/itemparticle.qml @@ -0,0 +1,309 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles +import shared +import "script.js" as Script + +Item { + id: root + width: 640 + height: 480 + Rectangle { + anchors.fill: parent + color: "black" + z: -1 + } + Item { + id: loading + Behavior on opacity {NumberAnimation {}} + anchors.fill: parent + Text { + anchors.centerIn: parent + text: "Loading" + color: "white" + } + } + ParticleSystem { + id: sys; + running: true + } + Emitter { + id: emitter + system: sys + height: parent.height - 132/2 + x: -132/2 + y: 132/2 + velocity: PointDirection { x: 32; xVariation: 8 } + emitRate: 0.5 + lifeSpan: Emitter.InfiniteLife + group: "photos" + } + Age { + system: sys + x: parent.width + 132/2 + height: parent.height + width: 1000 + } + ImageParticle { + system: sys + groups: ["fireworks"] + source: "qrc:///particleresources/star.png" + color: "lightsteelblue" + alpha: 0 + colorVariation: 0 + z: 1000 + } + ItemParticle { + id: mp + z: 0 + system: sys + fade: false + groups: ["photos"] + } + Component { + id: alertDelegate + Rectangle { + color: "DarkSlateGray" + border.width: 1 + border.color: "LightSteelBlue" + width: 144 + height: 132 + antialiasing: true + radius: 3 + NumberAnimation on scale { + running: true + loops: 1 + from: 0.2 + to: 1 + } + Image { + source: "images/rocket.png" + anchors.centerIn: parent + } + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: "A new ship has arrived!" + color: "LightSteelBlue" + } + } + } + property Item alertItem; + function alert() { + force.enabled = true; + alertItem = alertDelegate.createObject(root); + alertItem.x = root.width/2 - alertItem.width/2 + alertItem.y = root.height/2 - alertItem.height/2 + spawnFireworks.pulse(200); + stopAlert.start(); + } + focus: true + Keys.onSpacePressed: alert(); + Timer { + id: stopAlert + running: false + repeat: false + interval: 800 + onTriggered: { + force.enabled = false; + mp.take(root.alertItem, true); + centerEmitter.burst(1); + } + } + Attractor { + id: force + system: sys + pointX: root.width/2 + pointY: root.height/2 + strength: -10000 + enabled: false + anchors.centerIn: parent + width: parent.width/2 + height: parent.height/2 + groups:["photos"] + affectedParameter: Attractor.Position + } + Emitter { + id: centerEmitter + velocity: PointDirection { x: 32; xVariation: 8;} + emitRate: 0.5 + lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) + maximumEmitted: 20 + group: "photos" + system: sys + anchors.centerIn: parent + enabled: false + + //TODO: Zoom in effect + } + Emitter { + id: spawnFireworks + group: "fireworks" + system: sys + maximumEmitted: 400 + emitRate: 400 + lifeSpan: 2800 + x: parent.width/2 + y: parent.height/2 - 64 + width: 8 + height: 8 + enabled: false + size: 32 + endSize: 8 + velocity: AngleDirection { 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 + model: flickrModel + delegate: theDelegate + } + } + FlickrRssModel { + id: flickrModel + tags: "particle,particles" + } + Component { + id: theDelegate + Image { + required property int index + required property string title + required property string media + required property string thumbnail + + id: image + antialiasing: true; + source: thumbnail + cache: true + property real depth: Math.random() + property real darken: 0.75 + z: Math.floor(depth * 100) + scale: (depth + 1) / 2 + sourceSize { + width: root.width + height: root.height + } + width: 132 + height: 132 + fillMode: Image.PreserveAspectFit + Rectangle { + // Darken based on depth + anchors.centerIn: parent + width: parent.paintedWidth + 1 + height: parent.paintedHeight + 1 + color: "black" + opacity: image.darken * (1 - image.depth) + antialiasing: true; + } + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottomMargin: Math.max(parent.paintedWidth, parent.paintedHeight) - Math.min(parent.width, parent.height) + width: parent.paintedWidth - 4 + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + text: image.title + color: "black" + } + ItemParticle.onDetached: mp.take(image); // respawns + onStatusChanged: if (image.status == Image.Ready) { + loading.opacity = 0; + mp.take(image); + } + function manage() + { + if (state == "selected") { + console.log("Taking " + index); + mp.freeze(image); + } else { + console.log("Returning " +index); + mp.unfreeze(image); + } + } + TapHandler { + gesturePolicy: TapHandler.ReleaseWithinBounds + onTapped: image.state = (image.state == "" ? "selected" : "") + } + states: State { + name: "selected" + ParentChange { + target: image + parent: root + } + PropertyChanges { + image { + source: image.media + x: 0 + y: 0 + width: root.width + height: root.height + z: 101 + opacity: 1 + rotation: 0 + darken: 0 + } + } + } + transitions: Transition { + to: "selected" + reversible: true + SequentialAnimation { + ScriptAction { script: image.manage() } + ParallelAnimation { + ParentAnimation {NumberAnimation { properties: "x,y" }} + PropertyAnimation { properties: "width, height, z, rotation, darken"; easing.type: Easing.InOutQuad } + } + } + } + } + } +} diff --git a/examples/quick/particles/itemparticle/itemparticle.qrc b/examples/quick/particles/itemparticle/itemparticle.qrc new file mode 100644 index 0000000000..f951ba6366 --- /dev/null +++ b/examples/quick/particles/itemparticle/itemparticle.qrc @@ -0,0 +1,8 @@ + + + itemparticle.qml + delegates.qml + script.js + images/rocket.png + + diff --git a/examples/quick/particles/itemparticle/main.cpp b/examples/quick/particles/itemparticle/main.cpp index da21f15be3..5c7f7d5f3c 100644 --- a/examples/quick/particles/itemparticle/main.cpp +++ b/examples/quick/particles/itemparticle/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(particleview) +DECLARATIVE_EXAMPLE_MAIN(itemparticle/itemparticle) diff --git a/examples/quick/particles/itemparticle/particleview.qml b/examples/quick/particles/itemparticle/particleview.qml deleted file mode 100644 index 8eb18dc283..0000000000 --- a/examples/quick/particles/itemparticle/particleview.qml +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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.12 -import QtQuick.Particles 2.12 -import "shared" as Shared -import "content/script.js" as Script -import "content" - -Item { - id: root - width: 640 - height: 480 - Rectangle { - anchors.fill: parent - color: "black" - z: -1 - } - Item { - id: loading - Behavior on opacity {NumberAnimation {}} - anchors.fill: parent - Text { - anchors.centerIn: parent - text: "Loading" - color: "white" - } - } - ParticleSystem { - id: sys; - running: true - } - Emitter { - id: emitter - system: sys - height: parent.height - 132/2 - x: -132/2 - y: 132/2 - velocity: PointDirection { x: 32; xVariation: 8 } - emitRate: 0.5 - lifeSpan: Emitter.InfiniteLife - group: "photos" - } - Age { - system: sys - x: parent.width + 132/2 - height: parent.height - width: 1000 - } - ImageParticle { - system: sys - groups: ["fireworks"] - source: "qrc:///particleresources/star.png" - color: "lightsteelblue" - alpha: 0 - colorVariation: 0 - z: 1000 - } - ItemParticle { - id: mp - z: 0 - system: sys - fade: false - groups: ["photos"] - } - Component { - id: alertDelegate - Rectangle { - color: "DarkSlateGray" - border.width: 1 - border.color: "LightSteelBlue" - width: 144 - height: 132 - antialiasing: true - radius: 3 - NumberAnimation on scale { - running: true - loops: 1 - from: 0.2 - to: 1 - } - Image { - source: "qrc:///particles/images/rocket.png" - anchors.centerIn: parent - } - Text { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - text: "A new ship has arrived!" - color: "LightSteelBlue" - } - } - } - property Item alertItem; - function alert() { - force.enabled = true; - alertItem = alertDelegate.createObject(root); - alertItem.x = root.width/2 - alertItem.width/2 - alertItem.y = root.height/2 - alertItem.height/2 - spawnFireworks.pulse(200); - stopAlert.start(); - } - focus: true - Keys.onSpacePressed: alert(); - Timer { - id: stopAlert - running: false - repeat: false - interval: 800 - onTriggered: { - force.enabled = false; - mp.take(root.alertItem, true); - centerEmitter.burst(1); - } - } - Attractor { - id: force - system: sys - pointX: root.width/2 - pointY: root.height/2 - strength: -10000 - enabled: false - anchors.centerIn: parent - width: parent.width/2 - height: parent.height/2 - groups:["photos"] - affectedParameter: Attractor.Position - } - Emitter { - id: centerEmitter - velocity: PointDirection { x: 32; xVariation: 8;} - emitRate: 0.5 - lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) - maximumEmitted: 20 - group: "photos" - system: sys - anchors.centerIn: parent - enabled: false - - //TODO: Zoom in effect - } - Emitter { - id: spawnFireworks - group: "fireworks" - system: sys - maximumEmitted: 400 - emitRate: 400 - lifeSpan: 2800 - x: parent.width/2 - y: parent.height/2 - 64 - width: 8 - height: 8 - enabled: false - size: 32 - endSize: 8 - velocity: AngleDirection { 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 - model: flickrModel - delegate: theDelegate - } - } - Shared.FlickrRssModel { - id: flickrModel - tags: "particle,particles" - } - Component { - id: theDelegate - Image { - required property int index - required property string title - required property string media - required property string thumbnail - - id: image - antialiasing: true; - source: thumbnail - cache: true - property real depth: Math.random() - property real darken: 0.75 - z: Math.floor(depth * 100) - scale: (depth + 1) / 2 - sourceSize { - width: root.width - height: root.height - } - width: 132 - height: 132 - fillMode: Image.PreserveAspectFit - Rectangle { - // Darken based on depth - anchors.centerIn: parent - width: parent.paintedWidth + 1 - height: parent.paintedHeight + 1 - color: "black" - opacity: image.darken * (1 - image.depth) - antialiasing: true; - } - Text { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottomMargin: Math.max(parent.paintedWidth, parent.paintedHeight) - Math.min(parent.width, parent.height) - width: parent.paintedWidth - 4 - horizontalAlignment: Text.AlignHCenter - elide: Text.ElideRight - text: image.title - color: "black" - } - ItemParticle.onDetached: mp.take(image); // respawns - onStatusChanged: if (image.status == Image.Ready) { - loading.opacity = 0; - mp.take(image); - } - function manage() - { - if (state == "selected") { - console.log("Taking " + index); - mp.freeze(image); - } else { - console.log("Returning " +index); - mp.unfreeze(image); - } - } - TapHandler { - gesturePolicy: TapHandler.ReleaseWithinBounds - onTapped: image.state = (image.state == "" ? "selected" : "") - } - states: State { - name: "selected" - ParentChange { - target: image - parent: root - } - PropertyChanges { - target: image - source: image.media - x: 0 - y: 0 - width: root.width - height: root.height - z: 101 - opacity: 1 - rotation: 0 - darken: 0 - } - } - transitions: Transition { - to: "selected" - reversible: true - SequentialAnimation { - ScriptAction { script: image.manage() } - ParallelAnimation { - ParentAnimation {NumberAnimation { properties: "x,y" }} - PropertyAnimation { properties: "width, height, z, rotation, darken"; easing.type: Easing.InOutQuad } - } - } - } - } - } -} diff --git a/examples/quick/particles/itemparticle/script.js b/examples/quick/particles/itemparticle/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/quick/particles/itemparticle/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/quick/particles/particles.pro b/examples/quick/particles/particles.pro index 5343fa00f1..7ef86618d5 100644 --- a/examples/quick/particles/particles.pro +++ b/examples/quick/particles/particles.pro @@ -5,9 +5,6 @@ SUBDIRS += affectors \ itemparticle \ system -EXAMPLE_FILES = \ - images.qrc - #Install shared images too qml.files = images qml.path = $$[QT_INSTALL_EXAMPLES]/quick/particles diff --git a/examples/quick/particles/system/CMakeLists.txt b/examples/quick/particles/system/CMakeLists.txt index 6570678a2b..c8ab118550 100644 --- a/examples/quick/particles/system/CMakeLists.txt +++ b/examples/quick/particles/system/CMakeLists.txt @@ -7,7 +7,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) set(INSTALL_EXAMPLESDIR "examples") @@ -15,113 +14,43 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/system") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Core Gui Quick Qml) -qt_add_executable(system +add_subdirectory("../../shared" "shared") + +qt_add_executable(systemexample WIN32 MACOSX_BUNDLE main.cpp ) -set_target_properties(system PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(system PUBLIC +target_link_libraries(systemexample PUBLIC Qt::Core Qt::Gui Qt::Qml Qt::Quick ) +add_dependencies(systemexample system_shared) # Resources: -set(system_resource_files - "content/dynamiccomparison.qml" - "content/dynamicemitters.qml" - "content/multiplepainters.qml" - "content/startstop.qml" - "content/timedgroupchanges.qml" - "system.qml" -) - -qt6_add_resources(system "system" - PREFIX - "/particles/system" - FILES - ${system_resource_files} -) -set(images_resource_files - "../images/_explo.png" - "../images/backgroundLeaves.jpg" - "../images/bear_tiles.png" - "../images/candle.png" - "../images/colortable.png" - "../images/finalfrontier.png" - "../images/flower.png" - "../images/matchmask.png" - "../images/meteor.png" - "../images/meteor_explo.png" - "../images/meteors.png" - "../images/nullRock.png" - "../images/particle2.png" - "../images/particle3.png" - "../images/particleA.png" - "../images/portal_bg.png" - "../images/realLeaf1.png" - "../images/realLeaf2.png" - "../images/realLeaf3.png" - "../images/realLeaf4.png" - "../images/rocket.png" - "../images/rocket2.png" - "../images/sizeInOut.png" - "../images/snowflake.png" - "../images/sparkleSize.png" - "../images/starfish_0.png" - "../images/starfish_1.png" - "../images/starfish_2.png" - "../images/starfish_3.png" - "../images/starfish_4.png" - "../images/starfish_mask.png" -) - -qt6_add_resources(system "images" - PREFIX - "/particles" - BASE - ".." - FILES - ${images_resource_files} -) -set(shared_resource_files - "../../shared/Button.qml" - "../../shared/CheckBox.qml" - "../../shared/FlickrRssModel.qml" - "../../shared/Label.qml" - "../../shared/LauncherList.qml" - "../../shared/SimpleLauncherDelegate.qml" - "../../shared/Slider.qml" - "../../shared/TabSet.qml" - "../../shared/TextField.qml" - "../../shared/images/back.png" - "../../shared/images/checkmark.png" - "../../shared/images/next.png" - "../../shared/images/qt-logo.png" - "../../shared/images/slider_handle.png" - "../../shared/images/tab.png" -) - -qt6_add_resources(system "shared" - PREFIX - "/shared" - BASE - "../../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS system +qt_add_qml_module(systemexample + URI system + VERSION 1.0 + QML_FILES + "dynamiccomparison.qml" + "dynamicemitters.qml" + "multiplepainters.qml" + "timedgroupchanges.qml" + "startstop.qml" + "system.qml" + RESOURCES + "images/sparkleSize.png" + "images/particle2.png" + "images/particle3.png" +) + +install(TARGETS systemexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) + +bundle_shared(systemexample) diff --git a/examples/quick/particles/system/content/dynamiccomparison.qml b/examples/quick/particles/system/content/dynamiccomparison.qml deleted file mode 100644 index c1d42863ee..0000000000 --- a/examples/quick/particles/system/content/dynamiccomparison.qml +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - - ImageParticle { - system: sys - source: "qrc:///particleresources/glowdot.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - entryEffect: ImageParticle.None - } - - Emitter { - id: emitter - system: sys - width: parent.width/2 - velocity: PointDirection {y: 72; yVariation: 24} - lifeSpan: 10000 - emitRate: 1000 - enabled: false - size: 32 - } - - //! [fake] - Item { - id: fakeEmitter - function burst(number) { - while (number > 0) { - var item = fakeParticle.createObject(root); - item.lifeSpan = Math.random() * 5000 + 5000; - item.x = Math.random() * (root.width/2) + (root.width/2); - item.y = 0; - number--; - } - } - - Component { - id: fakeParticle - Image { - id: container - property int lifeSpan: 10000 - width: 32 - height: 32 - source: "qrc:///particleresources/glowdot.png" - y: 0 - PropertyAnimation on y {from: -16; to: root.height-16; duration: container.lifeSpan; running: true} - SequentialAnimation on opacity { - running: true - NumberAnimation { from:0; to: 1; duration: 500} - PauseAnimation { duration: container.lifeSpan - 1000} - NumberAnimation { from:1; to: 0; duration: 500} - ScriptAction { script: container.destroy(); } - } - } - } - } - //! [fake] - - //Hooked to a timer, but click for extra bursts that really stress performance - Timer { - interval: 10000 - triggeredOnStart: true - repeat: true - running: true - onTriggered: { - emitter.burst(1000); - fakeEmitter.burst(1000); - } - } - Text { - anchors.left: parent.left - anchors.bottom: parent.bottom - text: "1000 particles" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: emitter.burst(1000); - } - } - Text { - anchors.right: parent.right - anchors.bottom: parent.bottom - text: "1000 items" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: fakeEmitter.burst(1000); - } - } -} diff --git a/examples/quick/particles/system/content/dynamicemitters.qml b/examples/quick/particles/system/content/dynamicemitters.qml deleted file mode 100644 index 8eb87d2baa..0000000000 --- a/examples/quick/particles/system/content/dynamicemitters.qml +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - ImageParticle { - system: sys - source: "qrc:///particleresources/glowdot.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - } - - Component { - id: emitterComp - Emitter { - id: container - Emitter { - id: emitMore - system: sys - emitRate: 128 - lifeSpan: 600 - size: 16 - endSize: 8 - velocity: AngleDirection {angleVariation:360; magnitude: 60} - } - - property int life: 2600 - property real targetX: 0 - property real targetY: 0 - function go() { - xAnim.start(); - yAnim.start(); - container.enabled = true - } - system: sys - emitRate: 32 - lifeSpan: 600 - size: 24 - endSize: 8 - NumberAnimation on x { - id: xAnim; - to: targetX - duration: life - running: false - } - NumberAnimation on y { - id: yAnim; - to: targetY - duration: life - running: false - } - Timer { - interval: life - running: true - onTriggered: container.destroy(); - } - } - } - - function customEmit(x,y) { - //! [0] - for (var i=0; i<8; i++) { - var obj = emitterComp.createObject(root); - obj.x = x - obj.y = y - obj.targetX = Math.random() * 240 - 120 + obj.x - obj.targetY = Math.random() * 240 - 120 + obj.y - obj.life = Math.round(Math.random() * 2400) + 200 - obj.emitRate = Math.round(Math.random() * 32) + 32 - obj.go(); - } - //! [0] - } - - Timer { - interval: 10000 - triggeredOnStart: true - running: true - repeat: true - onTriggered: customEmit(Math.random() * 320, Math.random() * 480) - } - MouseArea { - anchors.fill: parent - onClicked: (mouse)=> customEmit(mouse.x, mouse.y); - } - - Text { - anchors.horizontalCenter: parent.horizontalCenter - text: "Click Somewhere" - color: "white" - font.pixelSize: 24 - } -} diff --git a/examples/quick/particles/system/content/multiplepainters.qml b/examples/quick/particles/system/content/multiplepainters.qml deleted file mode 100644 index 1f2dcb6214..0000000000 --- a/examples/quick/particles/system/content/multiplepainters.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 600 - color: "darkblue" - property bool cloneMode: false - ParticleSystem { - id: sys - } - MouseArea { - anchors.fill: parent - onClicked: cloneMode = !cloneMode; - } - Text { - anchors.horizontalCenter: parent.horizontalCenter - text: "Click to Toggle" - color: "white" - font.pixelSize: 24 - } - Emitter { - system: sys - y:root.height + 20 - width: root.width - emitRate: 200 - lifeSpan: 4000 - startTime: 4000 - velocity: PointDirection { y: -120; } - } - - ImageParticle { - system: sys - visible: !cloneMode - source: "../../images/particle2.png" - } - - ImageParticle { - system: sys - visible: cloneMode - z: 0 - source: "../../images/particle3.png" - } - - ImageParticle { - system: sys - clip: true - visible: cloneMode - y: 120 - height: 240 - width: root.width - z: 1 - source: "qrc:///particleresources/glowdot.png" - } -} diff --git a/examples/quick/particles/system/content/startstop.qml b/examples/quick/particles/system/content/startstop.qml deleted file mode 100644 index a9ef7285aa..0000000000 --- a/examples/quick/particles/system/content/startstop.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - Text { - text: "Left click to start/stop\nRight click to pause/unpause" - color: "white" - font.pixelSize: 24 - } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: (mouse) => { - if (mouse.button == Qt.LeftButton) - particles.running = !particles.running - else - particles.paused = !particles.paused; - } - } - - ParticleSystem { - id: particles - running: false - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "qrc:///particleresources/star.png" - sizeTable: "../../images/sparkleSize.png" - alpha: 0 - colorVariation: 0.6 - } - - Emitter { - anchors.fill: parent - system: particles - emitRate: 2000 - lifeSpan: 2000 - size: 30 - sizeVariation: 10 - } -} diff --git a/examples/quick/particles/system/content/timedgroupchanges.qml b/examples/quick/particles/system/content/timedgroupchanges.qml deleted file mode 100644 index cab992f898..0000000000 --- a/examples/quick/particles/system/content/timedgroupchanges.qml +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 600 - color: "black" - ParticleSystem { - anchors.fill: parent - id: syssy - //! [0] - ParticleGroup { - name: "fire" - duration: 2000 - durationVariation: 2000 - to: {"splode":1} - } - //! [0] - //! [1] - ParticleGroup { - name: "splode" - duration: 400 - to: {"dead":1} - TrailEmitter { - group: "works" - emitRatePerParticle: 100 - lifeSpan: 1000 - maximumEmitted: 1200 - size: 8 - velocity: AngleDirection {angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;} - acceleration: PointDirection {y:100; yVariation: 20} - } - } - //! [1] - //! [2] - ParticleGroup { - name: "dead" - duration: 1000 - Affector { - once: true - onAffected: (x, y)=> worksEmitter.burst(400,x,y) - } - } - //! [2] - - Timer { - interval: 6000 - running: true - triggeredOnStart: true - repeat: true - onTriggered:startingEmitter.pulse(100); - } - Emitter { - id: startingEmitter - group: "fire" - width: parent.width - y: parent.height - enabled: false - emitRate: 80 - lifeSpan: 6000 - velocity: PointDirection {y:-100;} - size: 32 - } - - Emitter { - id: worksEmitter - group: "works" - enabled: false - emitRate: 100 - lifeSpan: 1600 - maximumEmitted: 6400 - size: 8 - velocity: CumulativeDirection { - PointDirection {y:-100} - AngleDirection {angleVariation: 360; magnitudeVariation: 80;} - } - acceleration: PointDirection {y:100; yVariation: 20} - } - - ImageParticle { - groups: ["works", "fire", "splode"] - source: "qrc:///particleresources/glowdot.png" - entryEffect: ImageParticle.Scale - } - } -} - diff --git a/examples/quick/particles/system/doc/src/system.qdoc b/examples/quick/particles/system/doc/src/system.qdoc index 22382190d3..6b795070fd 100644 --- a/examples/quick/particles/system/doc/src/system.qdoc +++ b/examples/quick/particles/system/doc/src/system.qdoc @@ -35,7 +35,7 @@ Each example is a small QML file emphasizing a particular type or feature. Dynamic comparison compares using the particle system to getting a similar effect with the following code that dynamically instantiates Image types. - \snippet particles/system/content/dynamiccomparison.qml fake + \snippet particles/system/dynamiccomparison.qml fake Note how the Image objects are not able to be randomly colorized. Start and Stop simply sets the running and paused states of a ParticleSystem. While the system does not perform any simulation when stopped or paused, a restart restarts the simulation from the beginning, while unpausing resumes the simulation from where it was. @@ -43,14 +43,14 @@ Timed group changes is an example that highlights the ParticleGroup type. While normally referring to groups with a string name is sufficient, additional effects can be done by setting properties on groups. The first group has a variable duration on it, but always transitions to the second group. - \snippet particles/system/content/timedgroupchanges.qml 0 + \snippet particles/system/timedgroupchanges.qml 0 The second group has a TrailEmitter on it, and a fixed duration for emitting into the third group. By placing the TrailEmitter as a direct child of the ParticleGroup, it automatically selects that group to follow. - \snippet particles/system/content/timedgroupchanges.qml 1 + \snippet particles/system/timedgroupchanges.qml 1 The third group has an Affector as a direct child, which makes the affector automatically target this group. The affector means that as soon as particles enter this group, a burst function can be called on another emitter, using the x,y positions of this particle. - \snippet particles/system/content/timedgroupchanges.qml 2 + \snippet particles/system/timedgroupchanges.qml 2 If TrailEmitter does not suit your needs for multiple emitters, you can also dynamically create Emitters while still using the same ParticleSystem and image particle - \snippet particles/system/content/dynamicemitters.qml 0 + \snippet particles/system/dynamicemitters.qml 0 Note that this effect, a flurry of flying rainbow spears, would be better served with TrailEmitter. It is only done with dynamic emitters in this example to show the concept more simply. Multiple Painters shows how to control paint ordering of individual particles. While the paint ordering of particles within one ImagePainter is not strictly defined, ImageParticle objects follow the normal Z-ordering rules for \l {Qt Quick} items. This example allow you to paint the inside of the particles above the black borders using a pair of ImageParticles each painting different parts of the same logical particle. diff --git a/examples/quick/particles/system/dynamiccomparison.qml b/examples/quick/particles/system/dynamiccomparison.qml new file mode 100644 index 0000000000..ad529a2041 --- /dev/null +++ b/examples/quick/particles/system/dynamiccomparison.qml @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + + ImageParticle { + system: sys + source: "qrc:///particleresources/glowdot.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + entryEffect: ImageParticle.None + } + + Emitter { + id: emitter + system: sys + width: parent.width/2 + velocity: PointDirection {y: 72; yVariation: 24} + lifeSpan: 10000 + emitRate: 1000 + enabled: false + size: 32 + } + + //! [fake] + Item { + id: fakeEmitter + function burst(number) { + while (number > 0) { + var item = fakeParticle.createObject(root); + item.lifeSpan = Math.random() * 5000 + 5000; + item.x = Math.random() * (root.width/2) + (root.width/2); + item.y = 0; + number--; + } + } + + Component { + id: fakeParticle + Image { + id: container + property int lifeSpan: 10000 + width: 32 + height: 32 + source: "qrc:///particleresources/glowdot.png" + y: 0 + PropertyAnimation on y {from: -16; to: root.height-16; duration: container.lifeSpan; running: true} + SequentialAnimation on opacity { + running: true + NumberAnimation { from:0; to: 1; duration: 500} + PauseAnimation { duration: container.lifeSpan - 1000} + NumberAnimation { from:1; to: 0; duration: 500} + ScriptAction { script: container.destroy(); } + } + } + } + } + //! [fake] + + //Hooked to a timer, but click for extra bursts that really stress performance + Timer { + interval: 10000 + triggeredOnStart: true + repeat: true + running: true + onTriggered: { + emitter.burst(1000); + fakeEmitter.burst(1000); + } + } + Text { + anchors.left: parent.left + anchors.bottom: parent.bottom + text: "1000 particles" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(1000); + } + } + Text { + anchors.right: parent.right + anchors.bottom: parent.bottom + text: "1000 items" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: fakeEmitter.burst(1000); + } + } +} diff --git a/examples/quick/particles/system/dynamicemitters.qml b/examples/quick/particles/system/dynamicemitters.qml new file mode 100644 index 0000000000..2b1ca0885e --- /dev/null +++ b/examples/quick/particles/system/dynamicemitters.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + ImageParticle { + system: sys + source: "qrc:///particleresources/glowdot.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + } + + Component { + id: emitterComp + Emitter { + id: container + Emitter { + id: emitMore + system: sys + emitRate: 128 + lifeSpan: 600 + size: 16 + endSize: 8 + velocity: AngleDirection {angleVariation:360; magnitude: 60} + } + + property int life: 2600 + property real targetX: 0 + property real targetY: 0 + function go() { + xAnim.start(); + yAnim.start(); + container.enabled = true + } + system: sys + emitRate: 32 + lifeSpan: 600 + size: 24 + endSize: 8 + NumberAnimation on x { + id: xAnim; + to: targetX + duration: life + running: false + } + NumberAnimation on y { + id: yAnim; + to: targetY + duration: life + running: false + } + Timer { + interval: life + running: true + onTriggered: container.destroy(); + } + } + } + + function customEmit(x,y) { + //! [0] + for (var i=0; i<8; i++) { + var obj = emitterComp.createObject(root); + obj.x = x + obj.y = y + obj.targetX = Math.random() * 240 - 120 + obj.x + obj.targetY = Math.random() * 240 - 120 + obj.y + obj.life = Math.round(Math.random() * 2400) + 200 + obj.emitRate = Math.round(Math.random() * 32) + 32 + obj.go(); + } + //! [0] + } + + Timer { + interval: 10000 + triggeredOnStart: true + running: true + repeat: true + onTriggered: customEmit(Math.random() * 320, Math.random() * 480) + } + MouseArea { + anchors.fill: parent + onClicked: (mouse)=> customEmit(mouse.x, mouse.y); + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: "Click Somewhere" + color: "white" + font.pixelSize: 24 + } +} diff --git a/examples/quick/particles/system/images/particle2.png b/examples/quick/particles/system/images/particle2.png new file mode 100644 index 0000000000..4f3372cd07 Binary files /dev/null and b/examples/quick/particles/system/images/particle2.png differ diff --git a/examples/quick/particles/system/images/particle3.png b/examples/quick/particles/system/images/particle3.png new file mode 100644 index 0000000000..2b04601403 Binary files /dev/null and b/examples/quick/particles/system/images/particle3.png differ diff --git a/examples/quick/particles/system/images/sparkleSize.png b/examples/quick/particles/system/images/sparkleSize.png new file mode 100644 index 0000000000..752056541b Binary files /dev/null and b/examples/quick/particles/system/images/sparkleSize.png differ diff --git a/examples/quick/particles/system/main.cpp b/examples/quick/particles/system/main.cpp index 63a88412f5..cc77f3a62d 100644 --- a/examples/quick/particles/system/main.cpp +++ b/examples/quick/particles/system/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(particles/system/system) +DECLARATIVE_EXAMPLE_MAIN(system/system) diff --git a/examples/quick/particles/system/multiplepainters.qml b/examples/quick/particles/system/multiplepainters.qml new file mode 100644 index 0000000000..62ca583e2e --- /dev/null +++ b/examples/quick/particles/system/multiplepainters.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + id: root + width: 360 + height: 600 + color: "darkblue" + property bool cloneMode: false + ParticleSystem { + id: sys + } + MouseArea { + anchors.fill: parent + onClicked: cloneMode = !cloneMode; + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: "Click to Toggle" + color: "white" + font.pixelSize: 24 + } + Emitter { + system: sys + y:root.height + 20 + width: root.width + emitRate: 200 + lifeSpan: 4000 + startTime: 4000 + velocity: PointDirection { y: -120; } + } + + ImageParticle { + system: sys + visible: !cloneMode + source: "images/particle2.png" + } + + ImageParticle { + system: sys + visible: cloneMode + z: 0 + source: "images/particle3.png" + } + + ImageParticle { + system: sys + clip: true + visible: cloneMode + y: 120 + height: 240 + width: root.width + z: 1 + source: "qrc:///particleresources/glowdot.png" + } +} diff --git a/examples/quick/particles/system/startstop.qml b/examples/quick/particles/system/startstop.qml new file mode 100644 index 0000000000..1eff8e962e --- /dev/null +++ b/examples/quick/particles/system/startstop.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + width: 360 + height: 540 + color: "black" + Text { + text: "Left click to start/stop\nRight click to pause/unpause" + color: "white" + font.pixelSize: 24 + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: (mouse) => { + if (mouse.button == Qt.LeftButton) + particles.running = !particles.running + else + particles.paused = !particles.paused; + } + } + + ParticleSystem { + id: particles + running: false + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "qrc:///particleresources/star.png" + sizeTable: "images/sparkleSize.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + anchors.fill: parent + system: particles + emitRate: 2000 + lifeSpan: 2000 + size: 30 + sizeVariation: 10 + } +} diff --git a/examples/quick/particles/system/system.pro b/examples/quick/particles/system/system.pro index df143f10a3..ea620f687a 100644 --- a/examples/quick/particles/system/system.pro +++ b/examples/quick/particles/system/system.pro @@ -4,7 +4,6 @@ QT += quick qml SOURCES += main.cpp RESOURCES += \ system.qrc \ - ../images.qrc \ ../../shared/shared.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/particles/system diff --git a/examples/quick/particles/system/system.qml b/examples/quick/particles/system/system.qml index 569676d424..9f3af98744 100644 --- a/examples/quick/particles/system/system.qml +++ b/examples/quick/particles/system/system.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,21 +48,21 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import "../../shared" as Examples +import QtQuick +import shared Item { height: 480 width: 320 - Examples.LauncherList { + LauncherList { id: ll anchors.fill: parent Component.onCompleted: { - addExample("Dynamic Comparison", "Compares with dynamically created elements", Qt.resolvedUrl("content/dynamiccomparison.qml")); - addExample("StartStop", "Start and stop the simulation", Qt.resolvedUrl("content/startstop.qml")); - addExample("Timed group changes", "Emit into managed groups", Qt.resolvedUrl("content/timedgroupchanges.qml")); - addExample("Dynamic Emitters", "Dynamically instantiated emitters with a single system", Qt.resolvedUrl("content/dynamicemitters.qml")); - addExample("Multiple Painters", "Several ParticlePainters on the same logical particles", Qt.resolvedUrl("content/multiplepainters.qml")); + addExample("Dynamic Comparison", "Compares with dynamically created elements", Qt.resolvedUrl("dynamiccomparison.qml")); + addExample("StartStop", "Start and stop the simulation", Qt.resolvedUrl("startstop.qml")); + addExample("Timed group changes", "Emit into managed groups", Qt.resolvedUrl("timedgroupchanges.qml")); + addExample("Dynamic Emitters", "Dynamically instantiated emitters with a single system", Qt.resolvedUrl("dynamicemitters.qml")); + addExample("Multiple Painters", "Several ParticlePainters on the same logical particles", Qt.resolvedUrl("multiplepainters.qml")); } } } diff --git a/examples/quick/particles/system/system.qrc b/examples/quick/particles/system/system.qrc index 3fb8221fb1..e86bc19e68 100644 --- a/examples/quick/particles/system/system.qrc +++ b/examples/quick/particles/system/system.qrc @@ -1,10 +1,13 @@ - + system.qml - content/dynamiccomparison.qml - content/dynamicemitters.qml - content/multiplepainters.qml - content/startstop.qml - content/timedgroupchanges.qml + dynamiccomparison.qml + dynamicemitters.qml + multiplepainters.qml + startstop.qml + timedgroupchanges.qml + images/sparkleSize.png + images/particle2.png + images/particle3.png diff --git a/examples/quick/particles/system/timedgroupchanges.qml b/examples/quick/particles/system/timedgroupchanges.qml new file mode 100644 index 0000000000..e3eb0c3d08 --- /dev/null +++ b/examples/quick/particles/system/timedgroupchanges.qml @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Particles + +Rectangle { + width: 360 + height: 600 + color: "black" + ParticleSystem { + anchors.fill: parent + id: syssy + //! [0] + ParticleGroup { + name: "fire" + duration: 2000 + durationVariation: 2000 + to: {"splode":1} + } + //! [0] + //! [1] + ParticleGroup { + name: "splode" + duration: 400 + to: {"dead":1} + TrailEmitter { + group: "works" + emitRatePerParticle: 100 + lifeSpan: 1000 + maximumEmitted: 1200 + size: 8 + velocity: AngleDirection {angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;} + acceleration: PointDirection {y:100; yVariation: 20} + } + } + //! [1] + //! [2] + ParticleGroup { + name: "dead" + duration: 1000 + Affector { + once: true + onAffected: (x, y)=> worksEmitter.burst(400,x,y) + } + } + //! [2] + + Timer { + interval: 6000 + running: true + triggeredOnStart: true + repeat: true + onTriggered:startingEmitter.pulse(100); + } + Emitter { + id: startingEmitter + group: "fire" + width: parent.width + y: parent.height + enabled: false + emitRate: 80 + lifeSpan: 6000 + velocity: PointDirection {y:-100;} + size: 32 + } + + Emitter { + id: worksEmitter + group: "works" + enabled: false + emitRate: 100 + lifeSpan: 1600 + maximumEmitted: 6400 + size: 8 + velocity: CumulativeDirection { + PointDirection {y:-100} + AngleDirection {angleVariation: 360; magnitudeVariation: 80;} + } + acceleration: PointDirection {y:100; yVariation: 20} + } + + ImageParticle { + groups: ["works", "fire", "splode"] + source: "qrc:///particleresources/glowdot.png" + entryEffect: ImageParticle.Scale + } + } +} + -- cgit v1.2.3