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. Circle scale animation from center

Circle scale animation from center

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 2.1k Views 1 Watching
  • 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.
  • JoeBermejalesJ Offline
    JoeBermejalesJ Offline
    JoeBermejales
    wrote on last edited by
    #1

    Hi,

    I'd like to scale a circle in a map, but I don't know how to scale from the center of the circle, not the top left.

    This is my current code:

            //Animation under vehicle icon
            MapQuickItem {
                id: animationScan
                antialiasing: true
                sourceItem: Rectangle {
                    id: scanner
                    width: 100
                    height: 100
                    color: "#08b3e5"
                    radius: 50
                    border.width: 0
                    z: map.z + 3
                    OpacityAnimator on opacity{
                        loops: Animation.Infinite
                        from: 0.80
                        to: 0.00
                        duration: 1500
                    }
                    ScaleAnimator on scale {
                        loops: Animation.Infinite
                        from: 0;
                        to: 1;
                        duration: 1500
    
                    }
                }
                anchorPoint.x: scanner.width / 2
                anchorPoint.y: scanner.height / 2
                z: bus3d.z - 1
                coordinate: bus3d.coordinate
                zoomLevel: bus3d.zoomLevel
            }
    

    This is how it scales now:
    0_1553690083382_a4818141-6972-4040-938e-d1a60538e096-image.png

    and this is what I'd like to achieve:
    0_1553690564974_8f9afc96-9641-4711-94cb-bd4c175d8ab8-image.png

    Thanks in advance

    http://reparacionplotter.com

    Gojir4G 1 Reply Last reply
    0
    • KroMignonK KroMignon

      @JoeBermejales A stupide solution may be to add a parent, like this:

      MapQuickItem {
          id: animationScan
          antialiasing: true
          sourceItem: Item {
              id: scanner
              width: 100
              height: 100
              z: map.z + 3
              Rectangle {
                  width: 100
                  height: 100
                  anchors.centerIn: parent
                  color: "#08b3e5"
                  radius: 50
                  border.width: 0
                  OpacityAnimator on opacity{
                      loops: Animation.Infinite
                      from: 0.80
                      to: 0.00
                      duration: 1500
                  }
                  ScaleAnimator on scale {
                      loops: Animation.Infinite
                      from: 0;
                      to: 1;
                      duration: 1500
      
                  }
              }
          }
          anchorPoint.x: scanner.width / 2
          anchorPoint.y: scanner.height / 2
          z: bus3d.z - 1
          coordinate: bus3d.coordinate
          zoomLevel: bus3d.zoomLevel
      }
      
      JoeBermejalesJ Offline
      JoeBermejalesJ Offline
      JoeBermejales
      wrote on last edited by
      #7

      @KroMignon

      THANK YOU!! It works!!

      This is how it appears now:

              //Animation under vehicle icon
              MapQuickItem {
                  id: animationScan
                  antialiasing: true
                  width: 100
                  height: 100
                  sourceItem:
                      Item{
                      id: scanner
                      width: 140
                      height: 140
                      Rectangle {
                          width: 140
                          height: 140
                          color: "#08b3e5"
                          radius: 75
                          border.width: 0
                          z: map.z + 3
                          anchors.centerIn: parent
                          OpacityAnimator on opacity{
                              loops: Animation.Infinite
                              from: 0.90
                              to: 0.00
                              duration: 1500
                          }
      
                          ScaleAnimator on scale {
                              loops: Animation.Infinite
                              from: 0;
                              to: 1;
                              duration: 1500
                          }
                      }
                  }
                  anchorPoint.x: scanner.width / 2
                  anchorPoint.y: scanner.height / 2
                  z: 4
                  coordinate: bus3d.coordinate
                  zoomLevel: bus3d.zoomLevel
              }
      
              //Lidar animation
              MapQuickItem {
                  sourceItem:
                      Item{
                      id: lidarimg
                      width: 80
                      height: 80
                      Image {
                          source: "qrc:/img/lidar.png"
                          width: 80
                          height: 80
                          enabled: false
                          antialiasing: true
                          anchors.centerIn: parent
                          RotationAnimator on rotation {
                              loops: Animation.Infinite
                              from: 0;
                              to: 360;
                              duration: 1500
                          }
                      }
                  }
                  z: 4
                  coordinate: bus3d.coordinate
                  anchorPoint.x: lidarimg.width / 2
                  anchorPoint.y: lidarimg.height / 2
                  zoomLevel: bus3d.zoomLevel
                  opacity: 0.4
              }
      

      http://reparacionplotter.com

      1 Reply Last reply
      0
      • JoeBermejalesJ JoeBermejales

        Hi,

        I'd like to scale a circle in a map, but I don't know how to scale from the center of the circle, not the top left.

        This is my current code:

                //Animation under vehicle icon
                MapQuickItem {
                    id: animationScan
                    antialiasing: true
                    sourceItem: Rectangle {
                        id: scanner
                        width: 100
                        height: 100
                        color: "#08b3e5"
                        radius: 50
                        border.width: 0
                        z: map.z + 3
                        OpacityAnimator on opacity{
                            loops: Animation.Infinite
                            from: 0.80
                            to: 0.00
                            duration: 1500
                        }
                        ScaleAnimator on scale {
                            loops: Animation.Infinite
                            from: 0;
                            to: 1;
                            duration: 1500
        
                        }
                    }
                    anchorPoint.x: scanner.width / 2
                    anchorPoint.y: scanner.height / 2
                    z: bus3d.z - 1
                    coordinate: bus3d.coordinate
                    zoomLevel: bus3d.zoomLevel
                }
        

        This is how it scales now:
        0_1553690083382_a4818141-6972-4040-938e-d1a60538e096-image.png

        and this is what I'd like to achieve:
        0_1553690564974_8f9afc96-9641-4711-94cb-bd4c175d8ab8-image.png

        Thanks in advance

        Gojir4G Offline
        Gojir4G Offline
        Gojir4
        wrote on last edited by
        #2

        @JoeBermejales Hi,

        I guess you need to set anchor points to fixed coordinates:
        Example:

        anchorPoint.x: animationScan.width / 2
        anchorPoint.y: animationScan.height / 2
        
        JoeBermejalesJ 1 Reply Last reply
        0
        • Gojir4G Gojir4

          @JoeBermejales Hi,

          I guess you need to set anchor points to fixed coordinates:
          Example:

          anchorPoint.x: animationScan.width / 2
          anchorPoint.y: animationScan.height / 2
          
          JoeBermejalesJ Offline
          JoeBermejalesJ Offline
          JoeBermejales
          wrote on last edited by
          #3

          @Gojir4 thanks for your answer!

          The rectangle object is correctly centered to the coordinate, the problem is with the scale animation.

          If I add the anchorPoint to the Rectangle, I get the following:

          0_1553692446383_e71eed28-ee1f-4237-b2e1-d7cf6072bae6-image.png

          (horizontalCenter and verticalCenter don't seem to work neither)

          http://reparacionplotter.com

          KroMignonK 1 Reply Last reply
          0
          • JoeBermejalesJ JoeBermejales

            @Gojir4 thanks for your answer!

            The rectangle object is correctly centered to the coordinate, the problem is with the scale animation.

            If I add the anchorPoint to the Rectangle, I get the following:

            0_1553692446383_e71eed28-ee1f-4237-b2e1-d7cf6072bae6-image.png

            (horizontalCenter and verticalCenter don't seem to work neither)

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by KroMignon
            #4

            @JoeBermejales Do you have tried using anchors.centerIn?
            Like this:

            MapQuickItem {
                id: animationScan
                antialiasing: true
                sourceItem: Rectangle {
                    id: scanner
                    width: 100
                    height: 100
                    anchors.centerIn: animationScan
                     ...
                }
            }
            

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            JoeBermejalesJ 1 Reply Last reply
            3
            • KroMignonK KroMignon

              @JoeBermejales Do you have tried using anchors.centerIn?
              Like this:

              MapQuickItem {
                  id: animationScan
                  antialiasing: true
                  sourceItem: Rectangle {
                      id: scanner
                      width: 100
                      height: 100
                      anchors.centerIn: animationScan
                       ...
                  }
              }
              
              JoeBermejalesJ Offline
              JoeBermejalesJ Offline
              JoeBermejales
              wrote on last edited by JoeBermejales
              #5

              @KroMignon thanks

              Same behavior, I tried with another image, and another animation (rotation) and it seems that it also takes the top-left corner as a central point.

              Could it be because the object rectangle is inside a MapQuickItem ? I can't find a logical sense to this

              I need the animations centered in a coordinate and I can't do it, but what I have now is the following:

              0_1553784135022_346c58bf-80d9-4791-a0fe-8828c51573b9-image.png

              http://reparacionplotter.com

              KroMignonK 1 Reply Last reply
              0
              • JoeBermejalesJ JoeBermejales

                @KroMignon thanks

                Same behavior, I tried with another image, and another animation (rotation) and it seems that it also takes the top-left corner as a central point.

                Could it be because the object rectangle is inside a MapQuickItem ? I can't find a logical sense to this

                I need the animations centered in a coordinate and I can't do it, but what I have now is the following:

                0_1553784135022_346c58bf-80d9-4791-a0fe-8828c51573b9-image.png

                KroMignonK Offline
                KroMignonK Offline
                KroMignon
                wrote on last edited by KroMignon
                #6

                @JoeBermejales A stupide solution may be to add a parent, like this:

                MapQuickItem {
                    id: animationScan
                    antialiasing: true
                    sourceItem: Item {
                        id: scanner
                        width: 100
                        height: 100
                        z: map.z + 3
                        Rectangle {
                            width: 100
                            height: 100
                            anchors.centerIn: parent
                            color: "#08b3e5"
                            radius: 50
                            border.width: 0
                            OpacityAnimator on opacity{
                                loops: Animation.Infinite
                                from: 0.80
                                to: 0.00
                                duration: 1500
                            }
                            ScaleAnimator on scale {
                                loops: Animation.Infinite
                                from: 0;
                                to: 1;
                                duration: 1500
                
                            }
                        }
                    }
                    anchorPoint.x: scanner.width / 2
                    anchorPoint.y: scanner.height / 2
                    z: bus3d.z - 1
                    coordinate: bus3d.coordinate
                    zoomLevel: bus3d.zoomLevel
                }
                

                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                JoeBermejalesJ 1 Reply Last reply
                0
                • KroMignonK KroMignon

                  @JoeBermejales A stupide solution may be to add a parent, like this:

                  MapQuickItem {
                      id: animationScan
                      antialiasing: true
                      sourceItem: Item {
                          id: scanner
                          width: 100
                          height: 100
                          z: map.z + 3
                          Rectangle {
                              width: 100
                              height: 100
                              anchors.centerIn: parent
                              color: "#08b3e5"
                              radius: 50
                              border.width: 0
                              OpacityAnimator on opacity{
                                  loops: Animation.Infinite
                                  from: 0.80
                                  to: 0.00
                                  duration: 1500
                              }
                              ScaleAnimator on scale {
                                  loops: Animation.Infinite
                                  from: 0;
                                  to: 1;
                                  duration: 1500
                  
                              }
                          }
                      }
                      anchorPoint.x: scanner.width / 2
                      anchorPoint.y: scanner.height / 2
                      z: bus3d.z - 1
                      coordinate: bus3d.coordinate
                      zoomLevel: bus3d.zoomLevel
                  }
                  
                  JoeBermejalesJ Offline
                  JoeBermejalesJ Offline
                  JoeBermejales
                  wrote on last edited by
                  #7

                  @KroMignon

                  THANK YOU!! It works!!

                  This is how it appears now:

                          //Animation under vehicle icon
                          MapQuickItem {
                              id: animationScan
                              antialiasing: true
                              width: 100
                              height: 100
                              sourceItem:
                                  Item{
                                  id: scanner
                                  width: 140
                                  height: 140
                                  Rectangle {
                                      width: 140
                                      height: 140
                                      color: "#08b3e5"
                                      radius: 75
                                      border.width: 0
                                      z: map.z + 3
                                      anchors.centerIn: parent
                                      OpacityAnimator on opacity{
                                          loops: Animation.Infinite
                                          from: 0.90
                                          to: 0.00
                                          duration: 1500
                                      }
                  
                                      ScaleAnimator on scale {
                                          loops: Animation.Infinite
                                          from: 0;
                                          to: 1;
                                          duration: 1500
                                      }
                                  }
                              }
                              anchorPoint.x: scanner.width / 2
                              anchorPoint.y: scanner.height / 2
                              z: 4
                              coordinate: bus3d.coordinate
                              zoomLevel: bus3d.zoomLevel
                          }
                  
                          //Lidar animation
                          MapQuickItem {
                              sourceItem:
                                  Item{
                                  id: lidarimg
                                  width: 80
                                  height: 80
                                  Image {
                                      source: "qrc:/img/lidar.png"
                                      width: 80
                                      height: 80
                                      enabled: false
                                      antialiasing: true
                                      anchors.centerIn: parent
                                      RotationAnimator on rotation {
                                          loops: Animation.Infinite
                                          from: 0;
                                          to: 360;
                                          duration: 1500
                                      }
                                  }
                              }
                              z: 4
                              coordinate: bus3d.coordinate
                              anchorPoint.x: lidarimg.width / 2
                              anchorPoint.y: lidarimg.height / 2
                              zoomLevel: bus3d.zoomLevel
                              opacity: 0.4
                          }
                  

                  http://reparacionplotter.com

                  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