Made with by @jlmakes
jlmakes / rematrix Goto Github PK
View Code? Open in Web Editor NEWMatrix transformations made easy.
Home Page: https://rematrix.now.sh/
License: MIT License
Matrix transformations made easy.
Home Page: https://rematrix.now.sh/
License: MIT License
Made with by @jlmakes
Animating transforms requires computing intermediary states at arbitrary intervals between two transforms.
I propose the addition of a interpolate(from, to, progress)
I want to change transform-origin
, then apply scale...
But Rematrix still uses the old transform-origin
.
First of all, this is so good ๐ My linear algebra is dead in the water, what do you think of adding some methods or examples on how to:
Is it possible to reshape 3dmatrix[16] to a 2dmatrix[9]?
First of all, great job with this library - the code is well-documented and clear. I was up late last night looking for a good library for manipulating CSS transforms, and was very happy to find this one!
I was wondering if you would be open to the following (small) features? I can definitely help with some of them, let me know if you are willing to accept PRs on any of these.
b45c121 โ Rematrix.toString([...])
for converting a matrix array to a CSS string.
574e24e โ Rematrix.rotate(...)
that defaults to Rematrix.rotateZ(...)
(re: CSS spec)
Something that allows you to specify the unit for rotation, e.g. (Moved to #2)Rematrix.rotate(0.5, 'rad')
perhaps?
Decomposition: probably a bigger feature ask, but a way to decompose a matrix and grab specific values such as translateX
, skewY
, rotateZ
, scaleY
, etc. from it?
0817c2d โ Typescript definition file
Thanks so much for this library!
It's not hard to do such a function (and I will do one for my personnal usage), but why is there no function to apply the matrix to a point ? (would be convenient convert coordinate page to element coordinate ?)
...Or at least a column vector (just to set z to 0 and w to 1)
Something that allows you to specify the unit for rotation, such as rad or turn
Rematrix.rotate(0.5, 'rad')
perhaps?โ @davidkpiano
Source: https://drafts.csswg.org/css-values-3/#angles
Re: #1
import * as Rematrix from 'rematrix';
const r1 = Rematrix.rotate(50);
const r2 = Rematrix.rotate(40);
const product = Rematrix.multiply(r1, r2);
Now:
const css = 'transform: matrix3d(' + product.join(', ') + ')';
Proposed:
A:
const css = 'transform: ' + Rematrix.toString(product);
B:
const css = Rematrix.toString(product);
Note: Also here I think
toString()
should prefix output (e.g. with-webkit-
) when necessary.
Re: #1
Lovely library you made, seems like you know a lot about matrix transforms and math.
Do you know if it's possible to use matrix/matrix3d to lock a coordinate in place.
I am trying to essentially create a sticky component inside a overflow scroll container, but I don't understand the math (or if it's even possible) to do that.
I know it's possible to use matrix3d to make a very cheap scrollbar based on this article, which applies a matrix3d that flips the direction of the y movement (plus some scaling fixes). See demo
I was thinking, why not use the same idea to create a sticky item, but lock y to 0, so that it never moves at all (i.e sticky to top of its container)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.