Skip to content

Commit 11c8dea

Browse files
committed
allow arrays in visitor definition #112
1 parent ca55be2 commit 11c8dea

File tree

241 files changed

+11283
-10702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+11283
-10702
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- [x] make streaming optional #109
66
- [x] patch at-rule syntax for @font-feature-value #110
7+
- [x] support percentage in transform() and scale() #111
8+
- [x] allow arrays in visitor definition #112
79

810
## v1.3.3
911

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# css-parser
66

7-
CSS parser and minifier for node and the browser
7+
CSS parser, minifier and validator for node and the browser
88

99
## Installation
1010

@@ -101,7 +101,7 @@ Javascript module from cdn
101101

102102
<script type="module">
103103
104-
import {transform} from 'https://esm.sh/@tbela99/css-parser@1.3.3/web';
104+
import {transform} from 'https://esm.sh/@tbela99/css-parser@1.3.4/web';
105105
106106
const css = `
107107
.s {
@@ -126,7 +126,7 @@ Javascript umd module from cdn
126126

127127
```html
128128

129-
<script src="https://unpkg.com/@tbela99/css-parser@1.3.2/dist/index-umd-web.js"></script>
129+
<script src="https://unpkg.com/@tbela99/css-parser@1.3.4/dist/index-umd-web.js"></script>
130130
<script>
131131
132132
(async () => {

dist/index-umd-web.js

Lines changed: 203 additions & 122 deletions
Large diffs are not rendered by default.

dist/index.cjs

Lines changed: 203 additions & 122 deletions
Large diffs are not rendered by default.

dist/index.d.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ declare enum WalkerOptionEnum {
669669
/**
670670
* event types for the walkValues function
671671
*/
672-
declare enum WalkerValueEvent {
672+
declare enum WalkerEvent {
673673
/**
674674
* enter node
675675
*/
@@ -777,7 +777,7 @@ declare function walk(node: AstNode$1, filter?: WalkerFilter | null, reverse?: b
777777
*
778778
*/
779779
declare function walkValues(values: Token$1[], root?: AstNode$1 | Token$1 | null, filter?: WalkerValueFilter | null | {
780-
event?: WalkerValueEvent;
780+
event?: WalkerEvent;
781781
fn?: WalkerValueFilter;
782782
type?: EnumToken$1 | EnumToken$1[] | ((token: Token$1) => boolean);
783783
}, reverse?: boolean): Generator<WalkAttributesResult>;
@@ -2182,13 +2182,12 @@ export declare type AstNode$1 =
21822182
| AstInvalidRule
21832183
| AstInvalidDeclaration;
21842184

2185-
export declare type VisitorEventType = 'Enter' | 'Leave' ;
21862185
export declare type GenericVisitorResult<T> = T | T[] | Promise<T> | Promise<T[]> | null | Promise<null>;
21872186
export declare type GenericVisitorHandler<T> = ((node: T, parent?: AstNode | Token, root?: AstNode | Token) => GenericVisitorResult<T>);
21882187
export declare type GenericVisitorAstNodeHandlerMap<T> =
21892188
Record<string, GenericVisitorHandler<T>>
21902189
| GenericVisitorHandler<T>
2191-
| { type: VisitorEventType, handler: Record<string, GenericVisitorHandler<T>> | GenericVisitorHandler<T> };
2190+
| { type: WalkerEvent, handler: Record<string, GenericVisitorHandler<T>> };
21922191

21932192
export declare type ValueVisitorHandler = GenericVisitorHandler<Token>;
21942193

@@ -2254,7 +2253,7 @@ export declare interface VisitorNodeMap {
22542253
* // @media tv,screen{.foo{height:calc(40px/3)}}
22552254
* ```
22562255
*/
2257-
AtRule?: GenericVisitorAstNodeHandlerMap<AstAtRule>;
2256+
AtRule?: GenericVisitorAstNodeHandlerMap<AstAtRule> | Array<GenericVisitorAstNodeHandlerMap<AstAtRule>>;
22582257
/**
22592258
* declaration visitor
22602259
*
@@ -2356,7 +2355,7 @@ export declare interface VisitorNodeMap {
23562355
* // .foo{width:calc(40px/3);padding:10px}.selector{padding:20px}
23572356
* ```
23582357
*/
2359-
Declaration?: GenericVisitorAstNodeHandlerMap<AstDeclaration>;
2358+
Declaration?: GenericVisitorAstNodeHandlerMap<AstDeclaration> | Array<GenericVisitorAstNodeHandlerMap<AstDeclaration>>;
23602359

23612360
/**
23622361
* rule visitor
@@ -2398,19 +2397,22 @@ export declare interface VisitorNodeMap {
23982397
* // .foo{width:3px;.foo{width:3px}}
23992398
* ```
24002399
*/
2401-
Rule?: GenericVisitorAstNodeHandlerMap<AstRule>;
2400+
Rule?: GenericVisitorAstNodeHandlerMap<AstRule> | Array<GenericVisitorAstNodeHandlerMap<AstRule>>;
24022401

2403-
KeyframesRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesRule>;
2402+
KeyframesRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesRule> | Array<GenericVisitorAstNodeHandlerMap<AstKeyframesRule>>;
24042403

2405-
KeyframesAtRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule> | Record<string, GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule>>;
2404+
KeyframesAtRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule> | Record<string, GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule>> | Array<GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule> | Record<string, GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule>>>;
24062405

24072406
/**
24082407
* value visitor
24092408
*/
24102409
Value?: GenericVisitorHandler<Token> | Record<keyof EnumToken, GenericVisitorHandler<Token>> | {
2411-
type: VisitorEventType,
2410+
type: WalkerEvent,
24122411
handler: GenericVisitorHandler<Token> | Record<keyof EnumToken, GenericVisitorHandler<Token>>
2413-
};
2412+
} | Array<GenericVisitorHandler<Token> | Record<keyof EnumToken, GenericVisitorHandler<Token>> | {
2413+
type: WalkerEvent,
2414+
handler: GenericVisitorHandler<Token> | Record<keyof EnumToken, GenericVisitorHandler<Token>>
2415+
}>;
24142416

24152417
/**
24162418
* generic token visitor. the key name is of type keyof EnumToken.
@@ -2460,9 +2462,12 @@ export declare interface VisitorNodeMap {
24602462
* ```
24612463
*/
24622464
[key: keyof EnumToken]: GenericVisitorHandler<Token> | {
2463-
type: VisitorEventType,
2465+
type: WalkerEvent,
24642466
handler: GenericVisitorHandler<Token>
2465-
};
2467+
} | Array<GenericVisitorHandler<Token> | {
2468+
type: WalkerEvent,
2469+
handler: GenericVisitorHandler<Token>
2470+
}>;
24662471
}
24672472

24682473
export declare interface PropertyListOptions {
@@ -3019,7 +3024,7 @@ export declare type WalkerFilter = (node: AstNode$1) => WalkerOption;
30193024
/**
30203025
* filter nod
30213026
*/
3022-
export declare type WalkerValueFilter = (node: AstNode$1 | Token$1, parent?: AstNode$1 | Token$1 | null, event?: WalkerValueEvent) => WalkerOption | null;
3027+
export declare type WalkerValueFilter = (node: AstNode$1 | Token$1, parent?: AstNode$1 | Token$1 | null, event?: WalkerEvent) => WalkerOption | null;
30233028

30243029
export declare interface WalkResult {
30253030
node: AstNode$1;
@@ -3275,9 +3280,9 @@ export declare interface ParserOptions extends MinifyOptions, MinifyFeatureOptio
32753280

32763281
/**
32773282
* node visitor
3278-
* {@link VisitorNodeMap}
3283+
* {@link VisitorNodeMap | VisitorNodeMap[]}
32793284
*/
3280-
visitor?: VisitorNodeMap;
3285+
visitor?: VisitorNodeMap | VisitorNodeMap[];
32813286
/**
32823287
* abort signal
32833288
*
@@ -3900,5 +3905,5 @@ declare function transformFile(file: string, options?: TransformOptions, asStrea
39003905
*/
39013906
declare function transform(css: string | ReadableStream<Uint8Array>, options?: TransformOptions): Promise<TransformResult>;
39023907

3903-
export { ColorType, EnumToken$1 as EnumToken, FeatureWalkMode, SourceMap, ValidationLevel, WalkerOptionEnum, WalkerValueEvent, convertColor, dirname, expand, isOkLabClose, load, mathFuncs, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseTokens, render, renderToken, resolve, transform, transformFile, transformFunctions, walk, walkValues };
3904-
export type { AddToken, AngleToken, AstAtRule, AstComment, AstDeclaration, AstInvalidAtRule, AstInvalidDeclaration, AstInvalidRule, AstKeyFrameRule, AstKeyframesAtRule, AstKeyframesRule, AstNode$1 as AstNode, AstRule, AstRuleList, AstStyleSheet, AtRuleToken, AtRuleVisitorHandler, AttrEndToken, AttrStartToken, AttrToken, Background, BackgroundAttachmentMapping, BackgroundPosition, BackgroundPositionClass, BackgroundPositionConstraints, BackgroundPositionMapping, BackgroundProperties, BackgroundRepeat, BackgroundRepeatMapping, BackgroundSize, BackgroundSizeMapping, BadCDOCommentToken, BadCommentToken, BadStringToken, BadUrlToken, BaseToken, BinaryExpressionNode, BinaryExpressionToken, BlockEndToken, BlockStartToken, Border, BorderColor, BorderColorClass, BorderProperties, BorderRadius, CDOCommentToken, ChildCombinatorToken, ClassSelectorToken, ColonToken, ColorToken, ColumnCombinatorToken, CommaToken, CommentToken, ConstraintsMapping, ContainMatchToken, Context, DashMatchToken, DashedIdentToken, DeclarationVisitorHandler, DelimToken, DescendantCombinatorToken, DimensionToken, DivToken, EOFToken, EndMatchToken, EqualMatchToken, ErrorDescription, FlexToken, Font, FontFamily, FontProperties, FontWeight, FontWeightConstraints, FontWeightMapping, FractionToken, FrequencyToken, FunctionImageToken, FunctionToken, FunctionURLToken, GenericVisitorAstNodeHandlerMap, GenericVisitorHandler, GenericVisitorResult, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, ImportantToken, IncludeMatchToken, InvalidAttrToken, InvalidClassSelectorToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, LoadResult, Location, Map$1 as Map, MatchExpressionToken, MatchedSelector, MediaFeatureAndToken, MediaFeatureNotToken, MediaFeatureOnlyToken, MediaFeatureOrToken, MediaFeatureToken, MediaQueryConditionToken, MinifyFeature, MinifyFeatureOptions, MinifyOptions, MulToken, NameSpaceAttributeToken, NestingSelectorToken, NextSiblingCombinatorToken, NumberToken, OptimizedSelector, OptimizedSelectorToken, Outline, OutlineProperties, ParensEndToken, ParensStartToken, ParensToken, ParseInfo, ParseResult, ParseResultStats, ParseTokenOptions, ParserOptions, PercentageToken, Position, Prefix, PropertiesConfig, PropertiesConfigProperties, PropertyListOptions, PropertyMapType, PropertySetType, PropertyType, PseudoClassFunctionToken, PseudoClassToken, PseudoElementToken, PseudoPageToken, PurpleBackgroundAttachment, RawSelectorTokens, RenderOptions, RenderResult, ResolutionToken, ResolvedPath, RuleVisitorHandler, SemiColonToken, Separator, ShorthandDef, ShorthandMapType, ShorthandProperties, ShorthandPropertyType, ShorthandType, SourceMapObject, StartMatchToken, StringToken, SubToken, SubsequentCombinatorToken, TimeToken, TimelineFunctionToken, TimingFunctionToken, Token$1 as Token, TokenizeResult, TransformOptions, TransformResult, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, Value, ValueVisitorHandler, VariableScopeInfo, VisitorEventType, VisitorNodeMap, WalkAttributesResult, WalkResult, WalkerFilter, WalkerOption, WalkerValueFilter, WhitespaceToken };
3908+
export { ColorType, EnumToken$1 as EnumToken, FeatureWalkMode, SourceMap, ValidationLevel, WalkerEvent, WalkerOptionEnum, convertColor, dirname, expand, isOkLabClose, load, mathFuncs, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseTokens, render, renderToken, resolve, transform, transformFile, transformFunctions, walk, walkValues };
3909+
export type { AddToken, AngleToken, AstAtRule, AstComment, AstDeclaration, AstInvalidAtRule, AstInvalidDeclaration, AstInvalidRule, AstKeyFrameRule, AstKeyframesAtRule, AstKeyframesRule, AstNode$1 as AstNode, AstRule, AstRuleList, AstStyleSheet, AtRuleToken, AtRuleVisitorHandler, AttrEndToken, AttrStartToken, AttrToken, Background, BackgroundAttachmentMapping, BackgroundPosition, BackgroundPositionClass, BackgroundPositionConstraints, BackgroundPositionMapping, BackgroundProperties, BackgroundRepeat, BackgroundRepeatMapping, BackgroundSize, BackgroundSizeMapping, BadCDOCommentToken, BadCommentToken, BadStringToken, BadUrlToken, BaseToken, BinaryExpressionNode, BinaryExpressionToken, BlockEndToken, BlockStartToken, Border, BorderColor, BorderColorClass, BorderProperties, BorderRadius, CDOCommentToken, ChildCombinatorToken, ClassSelectorToken, ColonToken, ColorToken, ColumnCombinatorToken, CommaToken, CommentToken, ConstraintsMapping, ContainMatchToken, Context, DashMatchToken, DashedIdentToken, DeclarationVisitorHandler, DelimToken, DescendantCombinatorToken, DimensionToken, DivToken, EOFToken, EndMatchToken, EqualMatchToken, ErrorDescription, FlexToken, Font, FontFamily, FontProperties, FontWeight, FontWeightConstraints, FontWeightMapping, FractionToken, FrequencyToken, FunctionImageToken, FunctionToken, FunctionURLToken, GenericVisitorAstNodeHandlerMap, GenericVisitorHandler, GenericVisitorResult, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, ImportantToken, IncludeMatchToken, InvalidAttrToken, InvalidClassSelectorToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, LoadResult, Location, Map$1 as Map, MatchExpressionToken, MatchedSelector, MediaFeatureAndToken, MediaFeatureNotToken, MediaFeatureOnlyToken, MediaFeatureOrToken, MediaFeatureToken, MediaQueryConditionToken, MinifyFeature, MinifyFeatureOptions, MinifyOptions, MulToken, NameSpaceAttributeToken, NestingSelectorToken, NextSiblingCombinatorToken, NumberToken, OptimizedSelector, OptimizedSelectorToken, Outline, OutlineProperties, ParensEndToken, ParensStartToken, ParensToken, ParseInfo, ParseResult, ParseResultStats, ParseTokenOptions, ParserOptions, PercentageToken, Position, Prefix, PropertiesConfig, PropertiesConfigProperties, PropertyListOptions, PropertyMapType, PropertySetType, PropertyType, PseudoClassFunctionToken, PseudoClassToken, PseudoElementToken, PseudoPageToken, PurpleBackgroundAttachment, RawSelectorTokens, RenderOptions, RenderResult, ResolutionToken, ResolvedPath, RuleVisitorHandler, SemiColonToken, Separator, ShorthandDef, ShorthandMapType, ShorthandProperties, ShorthandPropertyType, ShorthandType, SourceMapObject, StartMatchToken, StringToken, SubToken, SubsequentCombinatorToken, TimeToken, TimelineFunctionToken, TimingFunctionToken, Token$1 as Token, TokenizeResult, TransformOptions, TransformResult, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, Value, ValueVisitorHandler, VariableScopeInfo, VisitorNodeMap, WalkAttributesResult, WalkResult, WalkerFilter, WalkerOption, WalkerValueFilter, WhitespaceToken };

dist/lib/ast/features/calc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EnumToken } from '../types.js';
2-
import { walkValues, WalkerValueEvent, WalkerOptionEnum } from '../walk.js';
2+
import { walkValues, WalkerEvent, WalkerOptionEnum } from '../walk.js';
33
import { evaluate } from '../math/expression.js';
44
import { renderToken } from '../../renderer/render.js';
55
import '../../renderer/sourcemap/lib/encode.js';
@@ -34,7 +34,7 @@ class ComputeCalcExpressionFeature {
3434
}
3535
const set = new Set;
3636
for (const { value, parent } of walkValues(node.val, node, {
37-
event: WalkerValueEvent.Enter,
37+
event: WalkerEvent.Enter,
3838
// @ts-ignore
3939
fn(node, parent) {
4040
if (parent != null &&

dist/lib/ast/features/inlinecssvariables.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ class InlineCssVariablesFeature {
6666
}
6767
}
6868
run(ast, options = {}, parent, context) {
69-
if (!('chi' in ast)) {
70-
return null;
71-
}
69+
// if (!('chi' in ast)) {
70+
//
71+
// return null;
72+
// }
7273
if (!('variableScope' in context)) {
7374
context.variableScope = new Map;
7475
}

dist/lib/ast/transform/matrix.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ function parseMatrix(mat) {
3030
function matrix(values) {
3131
const matrix = identity();
3232
if (values.length === 6) {
33-
matrix[0 * 4 + 0] = values[0];
34-
matrix[0 * 4 + 1] = values[1];
35-
matrix[1 * 4 + 0] = values[2];
36-
matrix[1 * 4 + 1] = values[3];
37-
matrix[3 * 4 + 0] = values[4];
33+
matrix[0] = values[0];
34+
matrix[1] = values[1];
35+
matrix[4] = values[2];
36+
matrix[4 + 1] = values[3];
37+
matrix[3 * 4] = values[4];
3838
matrix[3 * 4 + 1] = values[5];
3939
}
4040
else if (values.length === 16) {
41-
matrix[0 * 4 + 0] = values[0];
42-
matrix[0 * 4 + 1] = values[1];
43-
matrix[0 * 4 + 2] = values[2];
44-
matrix[0 * 4 + 3] = values[3];
45-
matrix[1 * 4 + 0] = values[4];
46-
matrix[1 * 4 + 1] = values[5];
47-
matrix[1 * 4 + 2] = values[6];
48-
matrix[1 * 4 + 3] = values[7];
49-
matrix[2 * 4 + 0] = values[8];
41+
matrix[0] = values[0];
42+
matrix[1] = values[1];
43+
matrix[2] = values[2];
44+
matrix[3] = values[3];
45+
matrix[4] = values[4];
46+
matrix[4 + 1] = values[5];
47+
matrix[4 + 2] = values[6];
48+
matrix[4 + 3] = values[7];
49+
matrix[2 * 4] = values[8];
5050
matrix[2 * 4 + 1] = values[9];
5151
matrix[2 * 4 + 2] = values[10];
5252
matrix[2 * 4 + 3] = values[11];
53-
matrix[3 * 4 + 0] = values[12];
53+
matrix[3 * 4] = values[12];
5454
matrix[3 * 4 + 1] = values[13];
5555
matrix[3 * 4 + 2] = values[14];
5656
matrix[3 * 4 + 3] = values[15];
@@ -75,11 +75,11 @@ function serialize(matrix) {
7575
typ: EnumToken.FunctionTokenType,
7676
val: 'matrix',
7777
chi: [
78-
matrix[0 * 4 + 0],
79-
matrix[0 * 4 + 1],
80-
matrix[1 * 4 + 0],
81-
matrix[1 * 4 + 1],
82-
matrix[3 * 4 + 0],
78+
matrix[0],
79+
matrix[1],
80+
matrix[4],
81+
matrix[4 + 1],
82+
matrix[3 * 4],
8383
matrix[3 * 4 + 1]
8484
].reduce((acc, t) => {
8585
if (acc.length > 0) {

dist/lib/ast/transform/rotate.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ function rotate3D(angle, x, y, z, from) {
1717
x *= unit;
1818
y *= unit;
1919
z *= unit;
20-
matrix[0 * 4 + 0] = 1 - 2 * (y * y + z * z) * sq;
21-
matrix[0 * 4 + 1] = 2 * (x * y * sq + z * sc);
22-
matrix[0 * 4 + 2] = 2 * (x * z * sq - y * sc);
23-
matrix[1 * 4 + 0] = 2 * (x * y * sq - z * sc);
24-
matrix[1 * 4 + 1] = 1 - 2 * (x * x + z * z) * sq;
25-
matrix[1 * 4 + 2] = 2 * (y * z * sq + x * sc);
26-
matrix[2 * 4 + 0] = 2 * (x * z * sq + y * sc);
20+
matrix[0] = 1 - 2 * (y * y + z * z) * sq;
21+
matrix[1] = 2 * (x * y * sq + z * sc);
22+
matrix[2] = 2 * (x * z * sq - y * sc);
23+
matrix[4] = 2 * (x * y * sq - z * sc);
24+
matrix[4 + 1] = 1 - 2 * (x * x + z * z) * sq;
25+
matrix[4 + 2] = 2 * (y * z * sq + x * sc);
26+
matrix[2 * 4] = 2 * (x * z * sq + y * sc);
2727
matrix[2 * 4 + 1] = 2 * (y * z * sq - x * sc);
2828
matrix[2 * 4 + 2] = 1 - 2 * (x * x + y * y) * sq;
2929
return multiply(from, matrix);
3030
}
3131
function rotate(angle, from) {
3232
const matrix = identity();
33-
matrix[0 * 4 + 0] = Math.cos(angle);
34-
matrix[0 * 4 + 1] = Math.sin(angle);
35-
matrix[1 * 4 + 0] = -Math.sin(angle);
36-
matrix[1 * 4 + 1] = Math.cos(angle);
33+
matrix[0] = Math.cos(angle);
34+
matrix[1] = Math.sin(angle);
35+
matrix[4] = -Math.sin(angle);
36+
matrix[4 + 1] = Math.cos(angle);
3737
return multiply(from, matrix);
3838
}
3939

dist/lib/ast/transform/scale.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { identity, multiply } from './utils.js';
22

33
function scaleX(x, from) {
44
const matrix = identity();
5-
matrix[0 * 4 + 0] = x;
5+
matrix[0] = x;
66
return multiply(from, matrix);
77
}
88
function scaleY(y, from) {
99
const matrix = identity();
10-
matrix[1 * 4 + 1] = y;
10+
matrix[4 + 1] = y;
1111
return multiply(from, matrix);
1212
}
1313
function scaleZ(z, from) {
@@ -17,14 +17,14 @@ function scaleZ(z, from) {
1717
}
1818
function scale(x, y, from) {
1919
const matrix = identity();
20-
matrix[0 * 4 + 0] = x;
21-
matrix[1 * 4 + 1] = y;
20+
matrix[0] = x;
21+
matrix[4 + 1] = y;
2222
return multiply(from, matrix);
2323
}
2424
function scale3d(x, y, z, from) {
2525
const matrix = identity();
26-
matrix[0 * 4 + 0] = x;
27-
matrix[1 * 4 + 1] = y;
26+
matrix[0] = x;
27+
matrix[4 + 1] = y;
2828
matrix[2 * 4 + 2] = z;
2929
return multiply(from, matrix);
3030
}

0 commit comments

Comments
 (0)