Skip to content

Commit

Permalink
Website updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed May 18, 2024
1 parent f2c630e commit 8d71302
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 34 deletions.
4 changes: 2 additions & 2 deletions dist/en/main/apidoc/module-ol_expr_expression.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ <h4 class="name">

<div class="tag-source">
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/expr/expression.js">expr/expression.js</a>,
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/expr/expression.js#L650">line 650</a>
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/expr/expression.js#L659">line 659</a>
</div>

</div>
Expand Down Expand Up @@ -581,7 +581,7 @@ <h4 class="name">

<div class="tag-source">
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/expr/expression.js">expr/expression.js</a>,
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/expr/expression.js#L385">line 385</a>
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/expr/expression.js#L392">line 392</a>
</div>

</div>
Expand Down
4 changes: 2 additions & 2 deletions dist/en/main/examples/common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/en/main/examples/common.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/en/main/examples/offscreen-canvas.worker.worker.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions dist/en/main/ol/dist/ol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ declare namespace ol {
export { _ol_expr_expression$NumberArrayType as NumberArrayType };
export { _ol_expr_expression$NumberType as NumberType };
export { _ol_expr_expression$Ops as Ops };
export { _ol_expr_expression$SizeType as SizeType };
export { _ol_expr_expression$StringType as StringType };
export { _ol_expr_expression$computeGeometryType as computeGeometryType };
export { _ol_expr_expression$includesType as includesType };
Expand All @@ -187,6 +188,7 @@ declare namespace ol {
export { _ol_expr_gpu$getStringNumberEquivalent as getStringNumberEquivalent };
export { _ol_expr_gpu$newCompilationContext as newCompilationContext };
export { _ol_expr_gpu$numberToGlsl as numberToGlsl };
export { _ol_expr_gpu$sizeToGlsl as sizeToGlsl };
export { _ol_expr_gpu$stringToGlsl as stringToGlsl };
export { _ol_expr_gpu$uniformNameForVariable as uniformNameForVariable };
}
Expand Down Expand Up @@ -1121,6 +1123,7 @@ import { NoneType as _ol_expr_expression$NoneType } from '../../ol/expr/expressi
import { NumberArrayType as _ol_expr_expression$NumberArrayType } from '../../ol/expr/expression.js';
import { NumberType as _ol_expr_expression$NumberType } from '../../ol/expr/expression.js';
import { Ops as _ol_expr_expression$Ops } from '../../ol/expr/expression.js';
import { SizeType as _ol_expr_expression$SizeType } from '../../ol/expr/expression.js';
import { StringType as _ol_expr_expression$StringType } from '../../ol/expr/expression.js';
import { computeGeometryType as _ol_expr_expression$computeGeometryType } from '../../ol/expr/expression.js';
import { includesType as _ol_expr_expression$includesType } from '../../ol/expr/expression.js';
Expand All @@ -1136,6 +1139,7 @@ import { colorToGlsl as _ol_expr_gpu$colorToGlsl } from '../../ol/expr/gpu.js';
import { getStringNumberEquivalent as _ol_expr_gpu$getStringNumberEquivalent } from '../../ol/expr/gpu.js';
import { newCompilationContext as _ol_expr_gpu$newCompilationContext } from '../../ol/expr/gpu.js';
import { numberToGlsl as _ol_expr_gpu$numberToGlsl } from '../../ol/expr/gpu.js';
import { sizeToGlsl as _ol_expr_gpu$sizeToGlsl } from '../../ol/expr/gpu.js';
import { stringToGlsl as _ol_expr_gpu$stringToGlsl } from '../../ol/expr/gpu.js';
import { uniformNameForVariable as _ol_expr_gpu$uniformNameForVariable } from '../../ol/expr/gpu.js';
import { applyTransform as _ol_extent$applyTransform } from '../../ol/extent.js';
Expand Down
2 changes: 1 addition & 1 deletion dist/en/main/ol/dist/ol.d.ts.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/en/main/ol/dist/ol.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/en/main/ol/dist/ol.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/en/main/ol/expr/expression.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const NumberType: number;
export const StringType: number;
export const ColorType: number;
export const NumberArrayType: number;
export const SizeType: number;
export const AnyType: number;
/**
* @typedef {boolean|number|string|Array<number>} LiteralValue
Expand Down
2 changes: 1 addition & 1 deletion dist/en/main/ol/expr/expression.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions dist/en/main/ol/expr/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const NumberType = 1 << numTypes++;
export const StringType = 1 << numTypes++;
export const ColorType = 1 << numTypes++;
export const NumberArrayType = 1 << numTypes++;
export const SizeType = 1 << numTypes++;
export const AnyType = Math.pow(2, numTypes) - 1;

const typeNames = {
Expand All @@ -142,6 +143,7 @@ const typeNames = {
[StringType]: 'string',
[ColorType]: 'color',
[NumberArrayType]: 'number[]',
[SizeType]: 'size',
};

const namedTypes = Object.keys(typeNames).map(Number).sort(ascending);
Expand Down Expand Up @@ -285,7 +287,10 @@ export function parse(encoded, context, typeHint) {
return new LiteralExpression(BooleanType, encoded);
}
case 'number': {
return new LiteralExpression(NumberType, encoded);
return new LiteralExpression(
typeHint === SizeType ? SizeType : NumberType,
encoded,
);
}
case 'string': {
let type = StringType;
Expand Down Expand Up @@ -322,7 +327,9 @@ export function parse(encoded, context, typeHint) {
}

let type = NumberArrayType;
if (encoded.length === 3 || encoded.length === 4) {
if (encoded.length === 2) {
type |= SizeType;
} else if (encoded.length === 3 || encoded.length === 4) {
type |= ColorType;
}
if (typeHint) {
Expand Down Expand Up @@ -622,9 +629,11 @@ const parsers = {
),
[Ops.Array]: createParser(
(parsedArgs) => {
return parsedArgs.length === 3 || parsedArgs.length === 4
? NumberArrayType | ColorType
: NumberArrayType;
return parsedArgs.length === 2
? NumberArrayType | SizeType
: parsedArgs.length === 3 || parsedArgs.length === 4
? NumberArrayType | ColorType
: NumberArrayType;
},
withArgsCount(1, Infinity),
parseArgsOfType(NumberType),
Expand Down
6 changes: 6 additions & 0 deletions dist/en/main/ol/expr/gpu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export function arrayToGlsl(array: Array<number>): string;
* @return {string} The color expressed in the `vec4(1.0, 1.0, 1.0, 1.0)` form.
*/
export function colorToGlsl(color: string | import("../color.js").Color): string;
/**
* Normalizes and converts a number or array toa `vec2` array compatible with GLSL.
* @param {number|import('../size.js').Size} size Size.
* @return {string} The color expressed in the `vec4(1.0, 1.0, 1.0, 1.0)` form.
*/
export function sizeToGlsl(size: number | import('../size.js').Size): string;
/**
* Returns a stable equivalent number for the string literal.
* @param {string} string String literal value
Expand Down
2 changes: 1 addition & 1 deletion dist/en/main/ol/expr/gpu.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions dist/en/main/ol/expr/gpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
NumberArrayType,
NumberType,
Ops,
SizeType,
StringType,
computeGeometryType,
isType,
Expand All @@ -19,6 +20,7 @@ import {
} from './expression.js';
import {Uniforms} from '../renderer/webgl/TileLayer.js';
import {asArray} from '../color.js';
import {toSize} from '../size.js';

/**
* @param {string} operator Operator
Expand Down Expand Up @@ -72,6 +74,16 @@ export function colorToGlsl(color) {
]);
}

/**
* Normalizes and converts a number or array toa `vec2` array compatible with GLSL.
* @param {number|import('../size.js').Size} size Size.
* @return {string} The color expressed in the `vec4(1.0, 1.0, 1.0, 1.0)` form.
*/
export function sizeToGlsl(size) {
const array = toSize(size);
return arrayToGlsl(array);
}

/** @type {Object<string, number>} */
const stringToFloatMap = {};
let stringToFloatCounter = 0;
Expand Down Expand Up @@ -485,6 +497,12 @@ function compile(expression, returnType, context) {
return arrayToGlsl(/** @type {Array<number>} */ (expression.value));
}

if ((expression.type & SizeType) > 0) {
return sizeToGlsl(
/** @type {number|import('../size.js').Size} */ (expression.value),
);
}

throw new Error(
`Unexpected expression ${expression.value} (expected type ${typeName(
returnType,
Expand Down
2 changes: 1 addition & 1 deletion dist/en/main/ol/webgl/styleparser.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions dist/en/main/ol/webgl/styleparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ColorType,
NumberArrayType,
NumberType,
SizeType,
StringType,
newParsingContext,
} from '../expr/expression.js';
Expand Down Expand Up @@ -67,7 +68,7 @@ const UNPACK_COLOR_FN = `vec4 unpackColor(vec2 packedColor) {
* @return {1|2|3|4} The amount of components for this value
*/
function getGlslSizeFromType(type) {
if (type === ColorType) {
if (type === ColorType || type === SizeType) {
return 2;
}
if (type === NumberArrayType) {
Expand Down Expand Up @@ -134,7 +135,7 @@ function parseCommonSymbolProperties(style, builder, vertContext, prefix) {
const scale = expressionToGlsl(
vertContext,
style[`${prefix}scale`],
NumberType | NumberArrayType,
SizeType,
);
builder.setSymbolSizeExpression(
`${builder.getSymbolSizeExpression()} * ${scale}`,
Expand Down Expand Up @@ -301,7 +302,7 @@ function parseCircleProperties(
const scale = expressionToGlsl(
fragContext,
style['circle-scale'],
NumberType | NumberArrayType,
SizeType,
);
currentPoint = `coordsPx / ${scale}`;
}
Expand Down Expand Up @@ -420,11 +421,7 @@ function parseShapeProperties(
// SCALE
let currentPoint = 'coordsPx';
if ('shape-scale' in style) {
const scale = expressionToGlsl(
fragContext,
style['shape-scale'],
NumberType | NumberArrayType,
);
const scale = expressionToGlsl(fragContext, style['shape-scale'], SizeType);
currentPoint = `coordsPx / ${scale}`;
}

Expand Down Expand Up @@ -584,11 +581,7 @@ function parseIconProperties(
);
let scale = `1.0`;
if (`icon-scale` in style) {
scale = expressionToGlsl(
vertContext,
style[`icon-scale`],
NumberType | NumberArrayType,
);
scale = expressionToGlsl(vertContext, style[`icon-scale`], SizeType);
}
let shiftPx;
if (
Expand Down
4 changes: 2 additions & 2 deletions dist/main.js

Large diffs are not rendered by default.

0 comments on commit 8d71302

Please sign in to comment.