Named exports from ol/transform
This commit is contained in:
@@ -9,7 +9,7 @@ import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
||||
import {getInteriorPointOfArray, getInteriorPointsOfMultiArray} from '../geom/flat/interiorpoint.js';
|
||||
import {interpolatePoint} from '../geom/flat/interpolate.js';
|
||||
import {transform2D} from '../geom/flat/transform.js';
|
||||
import _ol_transform_ from '../transform.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../transform.js';
|
||||
|
||||
/**
|
||||
* Lightweight, read-only, {@link ol.Feature} and {@link ol.geom.Geometry} like
|
||||
@@ -78,7 +78,7 @@ const RenderFeature = function(type, flatCoordinates, ends, properties, id) {
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.tmpTransform_ = _ol_transform_.create();
|
||||
this.tmpTransform_ = createTransform();
|
||||
};
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ RenderFeature.prototype.transform = function(source, destination) {
|
||||
const projectedExtent = source.getWorldExtent();
|
||||
const scale = getHeight(projectedExtent) / getHeight(pixelExtent);
|
||||
const transform = this.tmpTransform_;
|
||||
_ol_transform_.compose(transform,
|
||||
composeTransform(transform,
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getFontFamilies} from '../css.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import {clear} from '../obj.js';
|
||||
import LRUCache from '../structs/LRUCache.js';
|
||||
import _ol_transform_ from '../transform.js';
|
||||
import {create as createTransform} from '../transform.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -257,7 +257,7 @@ export function rotateAtOffset(context, rotation, offsetX, offsetY) {
|
||||
}
|
||||
|
||||
|
||||
export const resetTransform = _ol_transform_.create();
|
||||
export const resetTransform = createTransform();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ import {transform2D} from '../../geom/flat/transform.js';
|
||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||
import VectorContext from '../VectorContext.js';
|
||||
import {defaultTextAlign, defaultFillStyle, defaultLineCap, defaultLineDash, defaultLineDashOffset, defaultLineJoin, defaultLineWidth, defaultMiterLimit, defaultStrokeStyle, defaultTextBaseline, defaultFont} from '../canvas.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../../transform.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -234,7 +234,7 @@ const CanvasImmediateRenderer = function(context, pixelRatio, extent, transform,
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.tmpLocalTransform_ = _ol_transform_.create();
|
||||
this.tmpLocalTransform_ = createTransform();
|
||||
|
||||
};
|
||||
|
||||
@@ -275,7 +275,7 @@ CanvasImmediateRenderer.prototype.drawImages_ = function(flatCoordinates, offset
|
||||
if (rotation !== 0 || this.imageScale_ != 1) {
|
||||
const centerX = x + this.imageAnchorX_;
|
||||
const centerY = y + this.imageAnchorY_;
|
||||
_ol_transform_.compose(localTransform,
|
||||
composeTransform(localTransform,
|
||||
centerX, centerY,
|
||||
this.imageScale_, this.imageScale_,
|
||||
rotation,
|
||||
@@ -325,7 +325,7 @@ CanvasImmediateRenderer.prototype.drawText_ = function(flatCoordinates, offset,
|
||||
const x = pixelCoordinates[offset] + this.textOffsetX_;
|
||||
const y = pixelCoordinates[offset + 1] + this.textOffsetY_;
|
||||
if (rotation !== 0 || this.textScale_ != 1) {
|
||||
const localTransform = _ol_transform_.compose(this.tmpLocalTransform_,
|
||||
const localTransform = composeTransform(this.tmpLocalTransform_,
|
||||
x, y,
|
||||
this.textScale_, this.textScale_,
|
||||
rotation,
|
||||
|
||||
@@ -18,7 +18,12 @@ import VectorContext from '../VectorContext.js';
|
||||
import {drawImage, resetTransform, defaultPadding, defaultFillStyle, defaultStrokeStyle, defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset, defaultLineDash, defaultLineCap} from '../canvas.js';
|
||||
import CanvasInstruction from '../canvas/Instruction.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
compose as composeTransform,
|
||||
apply as applyTransform,
|
||||
setFromArray as transformSetFromArray
|
||||
} from '../../transform.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -129,7 +134,7 @@ const CanvasReplay = function(tolerance, maxExtent, resolution, pixelRatio, over
|
||||
* @private
|
||||
* @type {!ol.Transform}
|
||||
*/
|
||||
this.renderedTransform_ = _ol_transform_.create();
|
||||
this.renderedTransform_ = createTransform();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -159,13 +164,13 @@ const CanvasReplay = function(tolerance, maxExtent, resolution, pixelRatio, over
|
||||
* @private
|
||||
* @type {!ol.Transform}
|
||||
*/
|
||||
this.tmpLocalTransform_ = _ol_transform_.create();
|
||||
this.tmpLocalTransform_ = createTransform();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!ol.Transform}
|
||||
*/
|
||||
this.resetTransform = _ol_transform_.create();
|
||||
this.resetTransform = createTransform();
|
||||
};
|
||||
|
||||
inherits(CanvasReplay, VectorContext);
|
||||
@@ -256,14 +261,14 @@ CanvasReplay.prototype.replayImage_ = function(context, x, y, image,
|
||||
if (rotation !== 0) {
|
||||
const centerX = x + anchorX;
|
||||
const centerY = y + anchorY;
|
||||
transform = _ol_transform_.compose(localTransform,
|
||||
transform = composeTransform(localTransform,
|
||||
centerX, centerY, 1, 1, rotation, -centerX, -centerY);
|
||||
|
||||
createOrUpdateEmpty(box);
|
||||
extendCoordinate(box, _ol_transform_.apply(localTransform, p1));
|
||||
extendCoordinate(box, _ol_transform_.apply(localTransform, p2));
|
||||
extendCoordinate(box, _ol_transform_.apply(localTransform, p3));
|
||||
extendCoordinate(box, _ol_transform_.apply(localTransform, p4));
|
||||
extendCoordinate(box, applyTransform(localTransform, p1));
|
||||
extendCoordinate(box, applyTransform(localTransform, p2));
|
||||
extendCoordinate(box, applyTransform(localTransform, p3));
|
||||
extendCoordinate(box, applyTransform(localTransform, p4));
|
||||
} else {
|
||||
createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box);
|
||||
}
|
||||
@@ -457,7 +462,7 @@ CanvasReplay.prototype.beginGeometry = function(geometry, feature) {
|
||||
*/
|
||||
CanvasReplay.prototype.fill_ = function(context) {
|
||||
if (this.fillOrigin_) {
|
||||
const origin = _ol_transform_.apply(this.renderedTransform_, this.fillOrigin_.slice());
|
||||
const origin = applyTransform(this.renderedTransform_, this.fillOrigin_.slice());
|
||||
context.translate(origin[0], origin[1]);
|
||||
context.rotate(this.viewRotation_);
|
||||
}
|
||||
@@ -551,7 +556,7 @@ CanvasReplay.prototype.replay_ = function(
|
||||
pixelCoordinates = transform2D(
|
||||
this.coordinates, 0, this.coordinates.length, 2,
|
||||
transform, this.pixelCoordinates_);
|
||||
_ol_transform_.setFromArray(this.renderedTransform_, transform);
|
||||
transformSetFromArray(this.renderedTransform_, transform);
|
||||
}
|
||||
const skipFeatures = !isEmpty(skippedFeaturesHash);
|
||||
let i = 0; // instruction index
|
||||
|
||||
@@ -15,7 +15,7 @@ import CanvasLineStringReplay from '../canvas/LineStringReplay.js';
|
||||
import CanvasPolygonReplay from '../canvas/PolygonReplay.js';
|
||||
import CanvasTextReplay from '../canvas/TextReplay.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../../transform.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ const CanvasReplayGroup = function(
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.hitDetectionTransform_ = _ol_transform_.create();
|
||||
this.hitDetectionTransform_ = createTransform();
|
||||
};
|
||||
|
||||
inherits(CanvasReplayGroup, ReplayGroup);
|
||||
@@ -301,7 +301,7 @@ CanvasReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
|
||||
hitTolerance = Math.round(hitTolerance);
|
||||
const contextSize = hitTolerance * 2 + 1;
|
||||
const transform = _ol_transform_.compose(this.hitDetectionTransform_,
|
||||
const transform = composeTransform(this.hitDetectionTransform_,
|
||||
hitTolerance + 0.5, hitTolerance + 0.5,
|
||||
1 / resolution, -1 / resolution,
|
||||
-rotation,
|
||||
|
||||
@@ -4,7 +4,13 @@
|
||||
import {inherits} from '../../index.js';
|
||||
import {getCenter} from '../../extent.js';
|
||||
import VectorContext from '../VectorContext.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
reset as resetTransform,
|
||||
rotate as rotateTransform,
|
||||
scale as scaleTransform,
|
||||
translate as translateTransform
|
||||
} from '../../transform.js';
|
||||
import {create, fromTransform} from '../../vec/mat4.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
|
||||
@@ -46,19 +52,19 @@ const WebGLReplay = function(tolerance, maxExtent) {
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.projectionMatrix_ = _ol_transform_.create();
|
||||
this.projectionMatrix_ = createTransform();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.offsetRotateMatrix_ = _ol_transform_.create();
|
||||
this.offsetRotateMatrix_ = createTransform();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.offsetScaleMatrix_ = _ol_transform_.create();
|
||||
this.offsetScaleMatrix_ = createTransform();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -294,17 +300,17 @@ WebGLReplay.prototype.replay = function(context,
|
||||
const locations = this.setUpProgram(gl, context, size, pixelRatio);
|
||||
|
||||
// set the "uniform" values
|
||||
const projectionMatrix = _ol_transform_.reset(this.projectionMatrix_);
|
||||
_ol_transform_.scale(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1]));
|
||||
_ol_transform_.rotate(projectionMatrix, -rotation);
|
||||
_ol_transform_.translate(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1]));
|
||||
const projectionMatrix = resetTransform(this.projectionMatrix_);
|
||||
scaleTransform(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1]));
|
||||
rotateTransform(projectionMatrix, -rotation);
|
||||
translateTransform(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1]));
|
||||
|
||||
const offsetScaleMatrix = _ol_transform_.reset(this.offsetScaleMatrix_);
|
||||
_ol_transform_.scale(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
const offsetScaleMatrix = resetTransform(this.offsetScaleMatrix_);
|
||||
scaleTransform(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
|
||||
const offsetRotateMatrix = _ol_transform_.reset(this.offsetRotateMatrix_);
|
||||
const offsetRotateMatrix = resetTransform(this.offsetRotateMatrix_);
|
||||
if (rotation !== 0) {
|
||||
_ol_transform_.rotate(offsetRotateMatrix, -rotation);
|
||||
rotateTransform(offsetRotateMatrix, -rotation);
|
||||
}
|
||||
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||
|
||||
Reference in New Issue
Block a user