Forum
    • Categories
    • Register
    • Login

    Rotation around center of mass is weird.

    Scheduled Pinned Locked Moved Unsolved Scripting
    1 Posts 1 Posters 6 Views
    Loading More Posts
    • 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.
    • ChazroxC
      Chazrox
      last edited by

      Im drawing a star and trying to rotate it around its center of mass without including the gradient in the rotation. At lower point counts its alot more obvious whats going on. For some reason at higher point counts its stable. hmmmm 🤔

      If anyone else wants to give it a go.. Thank you!

      MyKnobLaf.registerFunction("drawRotarySlider", function(g, obj)
      {
          var a = obj.area;
          var range = obj.max - obj.min;
          var stableSize = a[2] * (1.0 - 2.0 * 0.15);
          var ox = a[0] + (a[2] - stableSize) / 2;
          var oy = a[1] + (a[2] - stableSize) / 2;
          var cx = ox + stableSize / 2;
          var cy = oy + stableSize / 2;
          var sw = stableSize / 200.0;
          var startOffset = 2.5;
          var totalSweep = 2.0 * startOffset;
          var endOffset = -startOffset + totalSweep * (obj.value - obj.min) / range;
      
          // ============ COLOUR CONTROL ============
          // -- Star Body 3 --
          var cStarBody3Top = 0xff888888;
          var cStarBody3Bot = 0xff333333;
      
          // -- starBody3 --
          var starBody3Size = stableSize * 0.8;
          var starBody3Star = Content.createPath();
          starBody3Star.addStar(
              [0.5, 0.5],
              3,
              0.42,
              0.5,
              endOffset
          );
          starBody3Star.roundCorners(1);
          var starBody3Area = [cx - starBody3Size * 0.5, cy - starBody3Size * 0.5, starBody3Size, starBody3Size];
          g.setGradientFill([cStarBody3Top, cx, cy - starBody3Size * 0.5 + starBody3Size * 0.5 - starBody3Size * 0.5, cStarBody3Bot, cx, cy + starBody3Size * 0.5 + starBody3Size * 0.5 - starBody3Size * 0.5, false]);
          g.fillPath(starBody3Star, starBody3Area);
      
      });
      

      I Cant figure out why the shape warbles when

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      13

      Online

      2.4k

      Users

      13.8k

      Topics

      120.2k

      Posts