Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
pointergeometry
Advanced tools
Readme
A simple little utility that makes it easy to work with values calculated from the pointer's location relative to one or multiple defined points. 🙋🏼
🍒 VISIT THE PROJECT (MINI DEMO) WEBSITE
I experiment a lot with interactive graphics and interaction in general, and have found that I often have to calculate this
and that
, particularly the distance and angle from (a) specific point(s). I decided to make this little utility so I can just plop it in and start trying things out.
While the output is very 'basic', I found that what can be done with them when used to manipulate things
are endless. I hope you find this stirring your creativity and imagination. Lots of possibilities!
💅🏾 THE PROJECT SITE IS A MINI DEMO
More demos coming soon (mocking 3d, AppleTV rotating cards, etc)
Simply call PointerGeometry3000. This will create a global variable PointerGeometry
which contains points
. Values are updated onMouseMove by default (see available settings below).
// Initialize
PointerGeometry();
If initialised without arguments it will simply register the center of the viewport as its one and only reference point. The default name of this auto-created point is pointA
. If you do a console.log(PointerGeometry('pointA')
after initialisation, you will find that a point object contains the following data:
// Sample data
pointA: {
cx: 640, // (centerX, reference)
cy: 333, // (centerY, reference)
deg: 43.42633594589745, // (degrees),
hyp: 426.8480408763756 // (distance from reference)
rad: 0.7579325443330766, // (radians)
x: 187 // (positionX),
y: 177 // (positionY)
}
But you probably want to define specific points of reference, have multiple and even name them for convenience, so you'd want to initialize it like so:
// We initialize with multiple points
PointerGeometry({
points: {
aNicelyNamedPoint: {
cx: 200, // coordinate in pixels relative to viewport
cy: 200
},
anotherPoint: {
cx: 'center', // you can just pass 'center' for center of viewport
cy: 'center' // you can just pass 'center' for center of viewport
},
goCrazy: {
cx: 450
cy: 620
}
},
initialPos: { pageX: 200, pageY: 200 }, // (optional) registered 'mouse position' immediately on init. defaults to center
listener: 'mousemove', // (optional, default: mousemove) event to listen to when updating values
console: true // (optional) set to true if you want a console with values to be shown
});
So how do you get a specific point's particular value? You just do: PointerGeometry(pointName).propertyKey
// Get a specific point's value
var distanceFromReference = PointerGeometry('aNicelyNamedPoint').hyp;
var angleInDegrees = PointerGeometry('aNicelyNamedPoint').deg;
// ... so on
You can also access all
points via PointerGeometry.points
.
console: true
or having inspector open (as you already know) will reduce performance as it will be updating values, recording timelines, highlighting updated DOM elements what have you.Please do. If you have any comments or suggestions, i'd love to hear them. This utility is completely free but if you have used it for something cool please do let me know, let me see what you've made! Drop me a line at ezekielaquino@gmail.com or via @the_ezekiel on Twitter!
P.S. Follow me on twitter!
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
✨ A little utility that makes it easy to work with trig values calculated from the pointer's location relative to reference points
The npm package pointergeometry receives a total of 0 weekly downloads. As such, pointergeometry popularity was classified as not popular.
We found that pointergeometry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.