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
QtWS25 Last Chance

Circle scale animation from center

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 1.9k 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.
  • J Offline
    J Offline
    JoeBermejales
    wrote on 27 Mar 2019, 12:43 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

    G 1 Reply Last reply 27 Mar 2019, 13:05
    0
    • K KroMignon
      28 Mar 2019, 14:43

      @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
      }
      
      J Offline
      J Offline
      JoeBermejales
      wrote on 28 Mar 2019, 15:29 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
      • J JoeBermejales
        27 Mar 2019, 12:43

        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

        G Offline
        G Offline
        Gojir4
        wrote on 27 Mar 2019, 13:05 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
        
        J 1 Reply Last reply 27 Mar 2019, 13:14
        0
        • G Gojir4
          27 Mar 2019, 13:05

          @JoeBermejales Hi,

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

          anchorPoint.x: animationScan.width / 2
          anchorPoint.y: animationScan.height / 2
          
          J Offline
          J Offline
          JoeBermejales
          wrote on 27 Mar 2019, 13:14 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

          K 1 Reply Last reply 27 Mar 2019, 13:23
          0
          • J JoeBermejales
            27 Mar 2019, 13:14

            @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)

            K Offline
            K Offline
            KroMignon
            wrote on 27 Mar 2019, 13:23 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)

            J 1 Reply Last reply 28 Mar 2019, 14:37
            3
            • K KroMignon
              27 Mar 2019, 13:23

              @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
                       ...
                  }
              }
              
              J Offline
              J Offline
              JoeBermejales
              wrote on 28 Mar 2019, 14:37 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

              K 1 Reply Last reply 28 Mar 2019, 14:43
              0
              • J JoeBermejales
                28 Mar 2019, 14:37

                @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

                K Offline
                K Offline
                KroMignon
                wrote on 28 Mar 2019, 14:43 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)

                J 1 Reply Last reply 28 Mar 2019, 15:29
                0
                • K KroMignon
                  28 Mar 2019, 14:43

                  @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
                  }
                  
                  J Offline
                  J Offline
                  JoeBermejales
                  wrote on 28 Mar 2019, 15:29 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

                  1/7

                  27 Mar 2019, 12:43

                  • Login

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