Comments (5)
Yes this is expected. You should use the transfrom()
method instead:
el.transform('matrix', '1,0,0,-1,0,0')
Transform values are numerically stored in order to be able to animate them. Or rather, not having to parse them over and over again. That is why all transformation should be applied through the transform()
method.
The example above can also be achieved like this:
el.transform({ d: -1 })
As in matrix(a,b,c,d,e,f)
.
from svg.js.
Right. So if I want to apply a scaleY
of -1
and then later move the element 100px to the right I should to something like:
el.transform({ d: -1 });
//Other stuff happens, time passes
el.transform({ e: el.transform().x + 100 });
(e meaning the x
component of the matrix, I assume that it could also be x
instead of e
). Please correct me if I'm wrong.
from svg.js.
Well, not exactly. Translations and matrices are applied separately. In other words, transformations are not combined into a matrix. If you move an element with:
rect.transform({ x: 100, y: 50 })
The value of the transform attribute will be translate(100,50)
.
If you add a matrix transformation afterwards, let's say:
rect.transform({ d: -1 })
The value of the transform attribute will be translate(100,50) matrix(1,0,0,-1,0,0)
.
Transformations are combined in svg. Recalculating transformations into a singular matrix would remove that.
To be honest, I have been thinking about going that way (one matrix to rule them all). But I decided to stay as close as possible to SVG's native behaviour.
from svg.js.
Are you with me on this?
from svg.js.
Yeah. Perhaps adding extra utility methods that translate, scale, etc.
using matrix transformations is not a bad idea though (I am doing all with
matrix operations now). You could prefix them and keep the svg-standard
methods for users that prefer 1:1 mapping with the generated svg .
On the other hand, I would always expect that svg.js takes the most
performing path, regardless of the methods I use. For example, if I do
obj.x = 10
I would expect that a matrix transformation is applied behind
the scenes, if that's more performing.
On Friday, May 24, 2013, Wout Fierens wrote:
Are you with me on this?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-18420057
.
from svg.js.
Related Issues (20)
- Update website on node package README HOT 1
- It would be nice if we can destroy timeline gracefully. HOT 3
- Error: Unbound namespace prefix: "svgjs" HOT 8
- How to judge the <g> container exist the child element <rect>?
- npm install for nodejs HOT 1
- how to move while rotating
- Text alignment differs between 3.0 and 3.1 HOT 1
- (documentation) animating shapes along a path example needs rewrite HOT 5
- Moving a text with an inside title element fails HOT 4
- Migrating SVG window events HOT 6
- Incomplete typings - measurements should accept percentages HOT 3
- No Fragment declaration in svg.js.d.ts HOT 2
- Custom Bezier Function HOT 2
- Negative scale value in animation do not work properly. HOT 4
- TypeError: Cannot read properties of undefined (reading 'call') for PATHs in NodeJS HOT 8
- svgjs.com redirect to 'gacor.poker' scammy site HOT 1
- Image SVG size is zero sometimes HOT 4
- How can I draw a Polyline from a svg => g => svg => rect (responsive) to an Dom Element on the right side? HOT 1
- Testing overloaded methods is hard HOT 1
- Issues with rolling a timeline backwards with non-animating functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg.js.