Function for making a scale transform
This commit is contained in:
@@ -162,6 +162,16 @@ export function scale(transform, x, y) {
|
|||||||
return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));
|
return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a scale transform.
|
||||||
|
* @param {!Transform} target Transform to overwrite.
|
||||||
|
* @param {number} x Scale factor x.
|
||||||
|
* @param {number} y Scale factor y.
|
||||||
|
* @return {!Transform} The scale transform.
|
||||||
|
*/
|
||||||
|
export function makeScale(target, x, y) {
|
||||||
|
return set(target, x, 0, 0, y, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies translation to the given transform.
|
* Applies translation to the given transform.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
setFromArray,
|
setFromArray,
|
||||||
translate,
|
translate,
|
||||||
scale,
|
scale,
|
||||||
|
makeScale,
|
||||||
rotate,
|
rotate,
|
||||||
multiply,
|
multiply,
|
||||||
compose,
|
compose,
|
||||||
@@ -69,6 +70,20 @@ describe('ol.transform', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('makeScale()', function() {
|
||||||
|
it('creates a scale transform', function() {
|
||||||
|
const target = create();
|
||||||
|
makeScale(target, 2, 3);
|
||||||
|
expect(target).to.eql([2, 0, 0, 3, 0, 0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the target', function() {
|
||||||
|
const target = create();
|
||||||
|
const transform = makeScale(target, 2, 3);
|
||||||
|
expect(transform).to.be(target);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('rotate()', function() {
|
describe('rotate()', function() {
|
||||||
it('applies rotation to a transform', function() {
|
it('applies rotation to a transform', function() {
|
||||||
const transform = create();
|
const transform = create();
|
||||||
|
|||||||
Reference in New Issue
Block a user