Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Put a gradient on all the particles?
Forum Updated to NodeBB v4.3 + New Features

Put a gradient on all the particles?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 191 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kris Revi
    wrote on last edited by
    #1

    so this is my entire code

    import QtQuick 2.12
    import QtQuick.Particles 2.12
    import QtQuick.Controls 2.5
    import QtGraphicalEffects 1.0
    
    Rectangle {
        id: root
        width: 1280
        height: 720
        property bool tracer: false
        property color imageParticleColor1: Qt.rgba(255, 0, 0, 100)
        property int emitterParticleLife1: 5000
        property int emitterParticleEmitRate1: 500
        property int emitterParticleAngleVar1: 180
        property int emitterParticleMagnitudeVar1: 10
        gradient: Gradient {
            id: bgGradient
            GradientStop {
                position: 0.0
                color: "#141414"
            }
            GradientStop {
                position: 0.5
                color: "#000000"
            }
            GradientStop {
                position: 1.0
                color: "#141414"
            }
        }
    
        ParticleSystem {
            id: particleSystem1
        }
    
        ImageParticle {
            id: particlePainter1
            system: particleSystem1
            source: "image/particle.png"
        }
    
        Emitter {
            id: particleEmitter1
            anchors.fill: parent
            lifeSpan: emitterParticleLife1
            sizeVariation: 0.01
            size: 1
            endSize: 0.1
            emitRate: emitterParticleEmitRate1
            system: particleSystem1
            velocity: CumulativeDirection {
                AngleDirection {
                    angleVariation: emitterParticleAngleVar1
                    magnitudeVariation: emitterParticleMagnitudeVar1
                }
            }
        }
    }
    

    my question is: is it possible to make a gradient that is reflected in each particle?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kris Revi
      wrote on last edited by
      #2

      Would this not work?

      Rectangle {
          id: gradientRoot
          width: 1280
          height: 720
      
          OpacityMask {
              source: mask
              maskSource: gradientRoot
          }
      
          LinearGradient {
              id: mask
              anchors.fill: parent
              gradient: Gradient {
                  GradientStop { position: 0.2; color: "red"}
                  GradientStop { position: 0.5; color: "white" }
              }
          }
      

      make another Rect and set a gradient over it and use OpacityMask?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved