Giter Site home page Giter Site logo

Comments (3)

jeffchannell avatar jeffchannell commented on August 27, 2024

It really depends on the cursor icon and the "xhot/yhot" values that can be read from the shell...

https://github.com/jeffchannell/jiggle/blob/master/effects/ScalingEffect.js#L80

from jiggle.

HifeFish avatar HifeFish commented on August 27, 2024

Unfortunately, I do not completely understand the code, but if it helps, here are some calculations that might save you at least a little bit of time:

Original cursor:
(x0,y0) = position of top left corner
(xhot,yhot) = coordinates of tip counted from top left corner

Scaled cursor:
(x0',y0') = position of top left corner
(xhot',yhot') = coordinates of tip counted from top left corner

Then for the tips to coincide, we need:
x0'+xhot' = x0+xhot

So we should take:
x0' = x0+xhot-xhot'

If our scaling factor is r, then:
x0' = x0+ (1-r)*xhot

(Same for y0.)

There seems to be some conversion between center and corner position in your code, but I did not quite understand when you need which, but the conversion should follow from:
w,h = width, height
(xc,yc) = (x0+w/2,y0+h/2) = center of cursor image

from jiggle.

jeffchannell avatar jeffchannell commented on August 27, 2024

I've made some adjustments in the master branch for cursor positioning as I was revamping the animations to remove Tweener. Adding some modifiers to the X and Y offsets seems to get the fake cursor incredibly close for each supported size.

Feel free to make local and test the changes!

from jiggle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.