@@ -35,7 +35,7 @@ window.onload = async () => {
35
35
'viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no' ,
36
36
) ;
37
37
await loadScript ( 'https://unpkg.com/vconsole@latest/dist/vconsole.min.js' ) ;
38
- new window . VConsole ( ) ;
38
+ const vconsole = new window . VConsole ( ) ;
39
39
canvasElementSize = 320 ;
40
40
const canvas = document . getElementById ( 'pag' ) as HTMLCanvasElement ;
41
41
canvas . width = canvasElementSize ;
@@ -56,7 +56,7 @@ window.onload = async () => {
56
56
} ) ;
57
57
document . getElementById ( 'upload-font' ) . addEventListener ( 'change' , async ( event ) => {
58
58
const file = ( event . target as HTMLInputElement ) . files [ 0 ] ;
59
- document . getElementById ( 'upload-font-text' ) . innerText = `已加载${ file . name } ` ;
59
+ document . getElementById ( 'upload-font-text' ) . innerText = `已加载${ file . name } ` ;
60
60
await PAG . PAGFont . registerFont ( 'test' , file ) ;
61
61
} ) ;
62
62
// 加载测试字体
@@ -256,8 +256,8 @@ window.onload = async () => {
256
256
} ) ;
257
257
} ;
258
258
259
- const existsLayer = ( pagLayerWasm : object ) => {
260
- if ( pagLayerWasm ) return true ;
259
+ const existsLayer = ( pagLayer : object ) => {
260
+ if ( pagLayer ) return true ;
261
261
console . log ( 'no Layer' ) ;
262
262
return false ;
263
263
} ;
@@ -275,15 +275,13 @@ const testPAGComposition = {
275
275
console . log ( `test numChildren: ${ pagComposition . numChildren ( ) } ` ) ;
276
276
} ,
277
277
getLayerAt : ( ) => {
278
- const pagLayerWasm = pagComposition . getLayerAt ( 0 ) ;
279
- if ( ! existsLayer ( pagLayerWasm ) ) return ;
280
- const pagLayer = new PAG . PAGLayer ( pagLayerWasm ) ;
278
+ const pagLayer = pagComposition . getLayerAt ( 0 ) ;
279
+ if ( ! existsLayer ( pagLayer ) ) return ;
281
280
console . log ( `test getLayerAt index 0, layerName: ${ pagLayer . layerName ( ) } ` ) ;
282
281
} ,
283
282
getLayersByName : ( ) => {
284
- const pagLayerWasm = pagComposition . getLayerAt ( 0 ) ;
285
- if ( ! existsLayer ( pagLayerWasm ) ) return ;
286
- const pagLayer = new PAG . PAGLayer ( pagLayerWasm ) ;
283
+ const pagLayer = pagComposition . getLayerAt ( 0 ) ;
284
+ if ( ! existsLayer ( pagLayer ) ) return ;
287
285
const layerName = pagLayer . layerName ( ) ;
288
286
const vectorPagLayer = pagComposition . getLayersByName ( layerName ) ;
289
287
for ( let j = 0 ; j < vectorPagLayer . size ( ) ; j ++ ) {
@@ -316,17 +314,17 @@ const testPAGComposition = {
316
314
swapLayer ( 'swapLayer' ) ;
317
315
} ,
318
316
contains : ( ) => {
319
- const pagLayerWasm = pagComposition . getLayerAt ( 0 ) ;
320
- const isContains = pagComposition . contains ( pagLayerWasm ) ;
317
+ const pagLayer = pagComposition . getLayerAt ( 0 ) ;
318
+ const isContains = pagComposition . contains ( pagLayer ) ;
321
319
if ( isContains ) {
322
320
console . log ( 'test contains' ) ;
323
321
}
324
322
} ,
325
323
addLayer : ( ) => {
326
- const pagLayerWasm = pagComposition . getLayerAt ( 0 ) ;
324
+ const pagLayer = pagComposition . getLayerAt ( 0 ) ;
327
325
pagComposition . removeLayerAt ( 0 ) ;
328
326
const oldNum = pagComposition . numChildren ( ) ;
329
- const isSuccess : boolean = pagComposition . addLayer ( pagLayerWasm ) ;
327
+ const isSuccess : boolean = pagComposition . addLayer ( pagLayer ) ;
330
328
if ( isSuccess ) {
331
329
console . log ( `test addLayer success: old num ${ oldNum } current num ${ pagComposition . numChildren ( ) } ` ) ;
332
330
}
@@ -357,23 +355,23 @@ const testPAGCompositionAPi = () => {
357
355
} ;
358
356
359
357
const swapLayer = ( type : string ) => {
360
- const pagLayerWasm_0 = pagComposition . getLayerAt ( 0 ) ;
361
- const pagLayerWasm_1 = pagComposition . getLayerAt ( 1 ) ;
362
- if ( ! pagLayerWasm_0 || ! pagLayerWasm_1 ) {
358
+ const pagLayer_0 = pagComposition . getLayerAt ( 0 ) ;
359
+ const pagLayer_1 = pagComposition . getLayerAt ( 1 ) ;
360
+ if ( ! pagLayer_0 || ! pagLayer_1 ) {
363
361
console . log ( 'No layer switching' ) ;
364
362
return ;
365
363
}
366
- const pagLayer_name_0 = new PAG . PAGLayer ( pagLayerWasm_0 ) . layerName ( ) ;
367
- const pagLayer_name_1 = new PAG . PAGLayer ( pagLayerWasm_1 ) . layerName ( ) ;
364
+ const pagLayer_name_0 = pagLayer_0 . layerName ( ) ;
365
+ const pagLayer_name_1 = pagLayer_1 . layerName ( ) ;
368
366
if ( type === 'swapLayer' ) {
369
- pagComposition . swapLayer ( pagLayerWasm_0 , pagLayerWasm_1 ) ;
367
+ pagComposition . swapLayer ( pagLayer_0 , pagLayer_1 ) ;
370
368
} else {
371
369
pagComposition . swapLayerAt ( 0 , 1 ) ;
372
370
}
373
- const pagLayerWasm_exch_0 = pagComposition . getLayerAt ( 0 ) ;
374
- const pagLayerWasm_exch_1 = pagComposition . getLayerAt ( 1 ) ;
375
- const pagLayer__exch_0 = new PAG . PAGLayer ( pagLayerWasm_exch_0 ) . layerName ( ) ;
376
- const pagLayer__exch_1 = new PAG . PAGLayer ( pagLayerWasm_exch_1 ) . layerName ( ) ;
371
+ const pagLayer_exch_0 = pagComposition . getLayerAt ( 0 ) ;
372
+ const pagLayer_exch_1 = pagComposition . getLayerAt ( 1 ) ;
373
+ const pagLayer__exch_0 = pagLayer_exch_0 . layerName ( ) ;
374
+ const pagLayer__exch_1 = pagLayer_exch_1 . layerName ( ) ;
377
375
console . log (
378
376
`test ${ type } : oldLayerName_0=${ pagLayer_name_0 } , oldLayerName_1=${ pagLayer_name_1 } exchange LayerName_0=${ pagLayer__exch_0 } , LayerName_1=${ pagLayer__exch_1 } ` ,
379
377
) ;
@@ -533,8 +531,8 @@ const loadScript = (url) => {
533
531
scriptEl . onload = ( ) => {
534
532
resolve ( true ) ;
535
533
} ;
536
- scriptEl . onerror = ( ) => {
537
- reject ( false ) ;
534
+ scriptEl . onerror = ( e ) => {
535
+ reject ( e ) ;
538
536
} ;
539
537
scriptEl . src = url ;
540
538
document . body . appendChild ( scriptEl ) ;
0 commit comments