Code Monkey home page Code Monkey logo

rematrix's Introduction

rematrix's People

Contributors

casamia918 avatar jlmakes avatar ts1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rematrix's Issues

Can some common usage examples be added ?

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:

  1. Pan with a pivot
  2. Zoom with a pivot
  3. Adding constraints such as limiting transform to parent bounding box

Decomposing a 3D matrix

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. Rematrix.rotate(0.5, 'rad') perhaps? (Moved to #2)

  • 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!

Apply Transforms to Vectors

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)

Add unit type to rotation and skew methods

Something that allows you to specify the unit for rotation, such as rad or turn Rematrix.rotate(0.5, 'rad') perhaps?

โ€” @davidkpiano

Units

  • deg โ€” Degrees. There are 360 degrees in a full circle.
  • grad โ€” Gradians, also known as "gons" or "grades". There are 400 gradians in a full circle.
  • rad โ€” Radians. There are 2ฯ€ radians in a full circle.
  • turn โ€” Turns. There is 1 turn in a full circle.

Source: https://drafts.csswg.org/css-values-3/#angles

Re: #1

Rematrix.toString(matrix)

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

Quick question around matrix/matrix3d transforms

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)

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.