ol/geom/flat/textpath export

This commit is contained in:
raiyni
2018-02-12 23:34:21 -06:00
parent 05a648d4f3
commit 2550ab1691
3 changed files with 17 additions and 19 deletions

View File

@@ -2,7 +2,6 @@
* @module ol/geom/flat/textpath
*/
import {lerp} from '../../math.js';
const _ol_geom_flat_textpath_ = {};
/**
@@ -18,7 +17,7 @@ const _ol_geom_flat_textpath_ = {};
* @return {Array.<Array.<*>>} The result array of null if `maxAngle` was
* exceeded. Entries of the array are x, y, anchorX, angle, chunk.
*/
_ol_geom_flat_textpath_.lineString = function(
export function drawTextOnPath(
flatCoordinates, offset, end, stride, text, measure, startM, maxAngle) {
const result = [];
@@ -90,5 +89,4 @@ _ol_geom_flat_textpath_.lineString = function(
startM += charLength;
}
return result;
};
export default _ol_geom_flat_textpath_;
}

View File

@@ -10,7 +10,7 @@ import Relationship from '../../extent/Relationship.js';
import GeometryType from '../../geom/GeometryType.js';
import {inflateCoordinates, inflateCoordinatesArray, inflateMultiCoordinatesArray} from '../../geom/flat/inflate.js';
import {lineStringLength} from '../../geom/flat/length.js';
import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js';
import {drawTextOnPath} from '../../geom/flat/textpath.js';
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
import {CANVAS_LINE_DASH} from '../../has.js';
import {isEmpty} from '../../obj.js';
@@ -715,7 +715,7 @@ CanvasReplay.prototype.replay_ = function(
if (overflow || textLength <= pathLength) {
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
const startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
const parts = _ol_geom_flat_textpath_.lineString(
const parts = drawTextOnPath(
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
if (parts) {
let c, cc, chars, label, part;