@@ -99,16 +99,16 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
9999 return ;
100100 }
101101
102- const paint = new CanvasKit . SkPaint ( ) ;
102+ const paint = new CanvasKit . Paint ( ) ;
103103
104- const fontMgr = CanvasKit . SkFontMgr . RefDefault ( ) ;
104+ const fontMgr = CanvasKit . FontMgr . RefDefault ( ) ;
105105 const roboto = fontMgr . MakeTypefaceFromData ( robotoData ) ;
106106
107- const textPaint = new CanvasKit . SkPaint ( ) ;
107+ const textPaint = new CanvasKit . Paint ( ) ;
108108 textPaint . setColor ( CanvasKit . RED ) ;
109109 textPaint . setAntiAlias ( true ) ;
110110
111- const textFont = new CanvasKit . SkFont ( roboto , 30 ) ;
111+ const textFont = new CanvasKit . Font ( roboto , 30 ) ;
112112
113113 let i = 0 ;
114114
@@ -120,7 +120,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
120120 // Some animations see performance improvements by marking their
121121 // paths as volatile.
122122 path . setIsVolatile ( true ) ;
123- const dpe = CanvasKit . SkPathEffect . MakeDash ( [ 15 , 5 , 5 , 10 ] , i / 5 ) ;
123+ const dpe = CanvasKit . PathEffect . MakeDash ( [ 15 , 5 , 5 , 10 ] , i / 5 ) ;
124124 i ++ ;
125125
126126 paint . setPathEffect ( dpe ) ;
@@ -165,13 +165,13 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
165165 }
166166
167167 function drawFrame ( canvas ) {
168- const paint = new CanvasKit . SkPaint ( ) ;
168+ const paint = new CanvasKit . Paint ( ) ;
169169 paint . setStrokeWidth ( 1.0 ) ;
170170 paint . setAntiAlias ( true ) ;
171171 paint . setColor ( CanvasKit . Color ( 0 , 0 , 0 , 1.0 ) ) ;
172172 paint . setStyle ( CanvasKit . PaintStyle . Stroke ) ;
173173
174- const path = new CanvasKit . SkPath ( ) ;
174+ const path = new CanvasKit . Path ( ) ;
175175 path . moveTo ( 10 , 10 ) ;
176176 path . lineTo ( 100 , 10 ) ;
177177 path . moveTo ( 10 , 10 ) ;
@@ -197,13 +197,13 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
197197 }
198198
199199 function drawFrame ( canvas ) {
200- const paint = new CanvasKit . SkPaint ( ) ;
200+ const paint = new CanvasKit . Paint ( ) ;
201201 paint . setStrokeWidth ( 1.0 ) ;
202202 paint . setAntiAlias ( true ) ;
203203 paint . setColor ( CanvasKit . Color ( 0 , 0 , 0 , 1.0 ) ) ;
204204 paint . setStyle ( CanvasKit . PaintStyle . Stroke ) ;
205205
206- const path = new CanvasKit . SkPath ( ) ;
206+ const path = new CanvasKit . Path ( ) ;
207207 path . moveTo ( 20 , 5 ) ;
208208 path . lineTo ( 30 , 20 ) ;
209209 path . lineTo ( 40 , 10 ) ;
@@ -229,7 +229,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
229229
230230 const rrect = CanvasKit . RRectXY ( [ 100 , 10 , 140 , 62 ] , 10 , 4 ) ;
231231
232- const rrectPath = new CanvasKit . SkPath ( ) . addRRect ( rrect , true ) ;
232+ const rrectPath = new CanvasKit . Path ( ) . addRRect ( rrect , true ) ;
233233
234234 canvas . drawPath ( rrectPath , paint ) ;
235235
@@ -256,15 +256,15 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
256256 return ;
257257 }
258258
259- let paint = new CanvasKit . SkPaint ( ) ;
259+ let paint = new CanvasKit . Paint ( ) ;
260260 paint . setAntiAlias ( true ) ;
261261 paint . setColor ( CanvasKit . Color ( 0 , 0 , 0 , 1.0 ) ) ;
262262 paint . setStyle ( CanvasKit . PaintStyle . Stroke ) ;
263263 paint . setStrokeWidth ( 4.0 ) ;
264- paint . setPathEffect ( CanvasKit . SkPathEffect . MakeCorner ( 50 ) ) ;
264+ paint . setPathEffect ( CanvasKit . PathEffect . MakeCorner ( 50 ) ) ;
265265
266266 // Draw I N K
267- let path = new CanvasKit . SkPath ( ) ;
267+ let path = new CanvasKit . Path ( ) ;
268268 path . moveTo ( 80 , 30 ) ;
269269 path . lineTo ( 80 , 80 ) ;
270270
@@ -305,7 +305,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
305305 paint = paint . copy ( ) ;
306306 paint . setColor ( CanvasKit . Color ( Math . random ( ) * 255 , Math . random ( ) * 255 , Math . random ( ) * 255 , Math . random ( ) + .2 ) ) ;
307307 paints . push ( paint ) ;
308- path = new CanvasKit . SkPath ( ) ;
308+ path = new CanvasKit . Path ( ) ;
309309 paths . push ( path ) ;
310310 path . moveTo ( e . offsetX , e . offsetY ) ;
311311 }
@@ -320,7 +320,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
320320 }
321321
322322 function starPath ( CanvasKit , X = 128 , Y = 128 , R = 116 ) {
323- let p = new CanvasKit . SkPath ( ) ;
323+ let p = new CanvasKit . Path ( ) ;
324324 p . moveTo ( X + R , Y ) ;
325325 for ( let i = 1 ; i < 8 ; i ++ ) {
326326 let a = 2.6927937 * i ;
@@ -864,14 +864,14 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
864864 return ;
865865 }
866866 const canvas = surface . getCanvas ( ) ;
867- let paint = new CanvasKit . SkPaint ( ) ;
867+ let paint = new CanvasKit . Paint ( ) ;
868868
869869 // See https://fiddle.skia.org/c/f48b22eaad1bb7adcc3faaa321754af6
870870 // for original c++ version.
871871 let points = [ [ 0 , 0 ] , [ 250 , 0 ] , [ 100 , 100 ] , [ 0 , 250 ] ] ;
872872 let colors = [ CanvasKit . RED , CanvasKit . BLUE ,
873873 CanvasKit . YELLOW , CanvasKit . CYAN ] ;
874- let vertices = CanvasKit . MakeSkVertices ( CanvasKit . VertexMode . TriangleFan ,
874+ let vertices = CanvasKit . MakeVertices ( CanvasKit . VertexMode . TriangleFan ,
875875 points , null , colors ,
876876 false /*isVolatile*/ ) ;
877877
@@ -883,10 +883,10 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
883883 // for original c++ version.
884884 points = [ [ 300 , 300 ] , [ 50 , 300 ] , [ 200 , 200 ] , [ 300 , 50 ] ] ;
885885 let texs = [ [ 0 , 0 ] , [ 0 , 250 ] , [ 250 , 250 ] , [ 250 , 0 ] ] ;
886- vertices = CanvasKit . MakeSkVertices ( CanvasKit . VertexMode . TriangleFan ,
886+ vertices = CanvasKit . MakeVertices ( CanvasKit . VertexMode . TriangleFan ,
887887 points , texs , colors ) ;
888888
889- let shader = CanvasKit . SkShader . MakeLinearGradient ( [ 0 , 0 ] , [ 250 , 0 ] ,
889+ let shader = CanvasKit . Shader . MakeLinearGradient ( [ 0 , 0 ] , [ 250 , 0 ] ,
890890 colors , null , CanvasKit . TileMode . Clamp ) ;
891891 paint . setShader ( shader ) ;
892892
@@ -905,7 +905,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
905905 return ;
906906 }
907907 const canvas = surface . getCanvas ( ) ;
908- let paint = new CanvasKit . SkPaint ( ) ;
908+ let paint = new CanvasKit . Paint ( ) ;
909909
910910 // See https://fiddle.skia.org/c/f48b22eaad1bb7adcc3faaa321754af6
911911 // for original c++ version.
@@ -915,12 +915,12 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
915915 let transform = [ 2 , 0 , 0 ,
916916 0 , 2 , 0 ,
917917 0 , 0 , 1 ]
918- let shader = CanvasKit . SkShader . MakeRadialGradient ( [ 150 , 150 ] , 130 , colors ,
918+ let shader = CanvasKit . Shader . MakeRadialGradient ( [ 150 , 150 ] , 130 , colors ,
919919 pos , CanvasKit . TileMode . Mirror , transform ) ;
920920
921921 paint . setShader ( shader ) ;
922- const textFont = new CanvasKit . SkFont ( null , 75 ) ;
923- const textBlob = CanvasKit . SkTextBlob . MakeFromText ( 'Radial' , textFont ) ;
922+ const textFont = new CanvasKit . Font ( null , 75 ) ;
923+ const textBlob = CanvasKit . TextBlob . MakeFromText ( 'Radial' , textFont ) ;
924924
925925 canvas . drawTextBlob ( textBlob , 10 , 200 , paint ) ;
926926 paint . delete ( )
@@ -939,15 +939,15 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
939939 return ;
940940 }
941941 const canvas = surface . getCanvas ( ) ;
942- const paint = new CanvasKit . SkPaint ( ) ;
942+ const paint = new CanvasKit . Paint ( ) ;
943943 paint . setColor ( CanvasKit . BLUE ) ;
944944 paint . setStyle ( CanvasKit . PaintStyle . Stroke ) ;
945945
946- const fontMgr = CanvasKit . SkFontMgr . RefDefault ( ) ;
946+ const fontMgr = CanvasKit . FontMgr . RefDefault ( ) ;
947947 const notoSerif = fontMgr . MakeTypefaceFromData ( notoserifData ) ;
948948
949- const textPaint = new CanvasKit . SkPaint ( ) ;
950- const textFont = new CanvasKit . SkFont ( notoSerif , 20 ) ;
949+ const textPaint = new CanvasKit . Paint ( ) ;
950+ const textFont = new CanvasKit . Font ( notoSerif , 20 ) ;
951951
952952 canvas . drawRect ( CanvasKit . LTRBRect ( 30 , 30 , 200 , 200 ) , paint ) ;
953953 canvas . drawText ( 'This text is not shaped, and overflows the boundry' ,
@@ -971,7 +971,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
971971
972972 canvas . drawRect ( bounds , paint ) ;
973973 const SHAPE_TEST_TEXT = 'VAVAVAVAVAFIfi' ;
974- const textFont2 = new CanvasKit . SkFont ( notoSerif , 60 ) ;
974+ const textFont2 = new CanvasKit . Font ( notoSerif , 60 ) ;
975975 const shapedText2 = new CanvasKit . ShapedText ( {
976976 font : textFont2 ,
977977 leftToRight : true ,
@@ -1006,16 +1006,16 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
10061006 console . error ( 'Could not make surface' ) ;
10071007 return ;
10081008 }
1009- const paint = new CanvasKit . SkPaint ( ) ;
1009+ const paint = new CanvasKit . Paint ( ) ;
10101010 paint . setColor ( CanvasKit . BLUE ) ;
10111011 paint . setStyle ( CanvasKit . PaintStyle . Stroke ) ;
10121012
1013- const fontMgr = CanvasKit . SkFontMgr . RefDefault ( ) ;
1013+ const fontMgr = CanvasKit . FontMgr . RefDefault ( ) ;
10141014 const notoSerif = fontMgr . MakeTypefaceFromData ( notoserifData ) ;
10151015
1016- const textPaint = new CanvasKit . SkPaint ( ) ;
1017- const bigFont = new CanvasKit . SkFont ( notoSerif , 40 ) ;
1018- const smallFont = new CanvasKit . SkFont ( notoSerif , 25 ) ;
1016+ const textPaint = new CanvasKit . Paint ( ) ;
1017+ const bigFont = new CanvasKit . Font ( notoSerif , 40 ) ;
1018+ const smallFont = new CanvasKit . Font ( notoSerif , 25 ) ;
10191019
10201020 const TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ac leo vitae ipsum hendrerit euismod quis rutrum nibh. Quisque non suscipit urna. Donec enim urna, facilisis vitae volutpat in, mattis at elit. Sed quis augue et dolor dignissim fringilla. Sed non massa eu neque tristique malesuada. ' ;
10211021
@@ -1062,22 +1062,22 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
10621062 return ;
10631063 }
10641064 const canvas = surface . getCanvas ( ) ;
1065- const paint = new CanvasKit . SkPaint ( ) ;
1065+ const paint = new CanvasKit . Paint ( ) ;
10661066 paint . setStyle ( CanvasKit . PaintStyle . Stroke ) ;
10671067 paint . setAntiAlias ( true ) ;
10681068
1069- const font = new CanvasKit . SkFont ( null , 24 ) ;
1070- const fontPaint = new CanvasKit . SkPaint ( ) ;
1069+ const font = new CanvasKit . Font ( null , 24 ) ;
1070+ const fontPaint = new CanvasKit . Paint ( ) ;
10711071 fontPaint . setStyle ( CanvasKit . PaintStyle . Fill ) ;
10721072 fontPaint . setAntiAlias ( true ) ;
10731073
1074- const arc = new CanvasKit . SkPath ( ) ;
1074+ const arc = new CanvasKit . Path ( ) ;
10751075 arc . arcToOval ( CanvasKit . LTRBRect ( 20 , 40 , 280 , 300 ) , - 160 , 140 , true ) ;
10761076 arc . lineTo ( 210 , 140 ) ;
10771077 arc . arcToOval ( CanvasKit . LTRBRect ( 20 , 0 , 280 , 260 ) , 160 , - 140 , true ) ;
10781078
10791079 const str = 'This téxt should follow the curve across contours...' ;
1080- const textBlob = CanvasKit . SkTextBlob . MakeOnPath ( str , arc , font ) ;
1080+ const textBlob = CanvasKit . TextBlob . MakeOnPath ( str , arc , font ) ;
10811081
10821082 canvas . drawPath ( arc , paint ) ;
10831083 canvas . drawTextBlob ( textBlob , 0 , 0 , fontPaint ) ;
@@ -1105,7 +1105,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
11051105 height : 50 ,
11061106 alphaType : CanvasKit . AlphaType . Premul ,
11071107 colorType : CanvasKit . ColorType . RGBA_8888 ,
1108- colorSpace : CanvasKit . SkColorSpace . SRGB ,
1108+ colorSpace : CanvasKit . ColorSpace . SRGB ,
11091109 } ) ;
11101110
11111111 if ( ! subSurface ) {
@@ -1114,7 +1114,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
11141114 }
11151115
11161116 // draw a small "scene"
1117- const paint = new CanvasKit . SkPaint ( ) ;
1117+ const paint = new CanvasKit . Paint ( ) ;
11181118 paint . setColor ( CanvasKit . Color ( 139 , 228 , 135 , 0.95 ) ) ; // greenish
11191119 paint . setStyle ( CanvasKit . PaintStyle . Fill ) ;
11201120 paint . setAntiAlias ( true ) ;
@@ -1131,7 +1131,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
11311131 subCanvas . drawOval ( CanvasKit . XYWHRect ( x , y , 6 , 6 ) , paint ) ;
11321132 }
11331133
1134- // Snap it off as an SkImage - this image will be in the form the
1134+ // Snap it off as an Image - this image will be in the form the
11351135 // parent surface prefers (e.g. Texture for GPU / Raster for CPU).
11361136 const img = subSurface . makeImageSnapshot ( ) ;
11371137
@@ -1141,7 +1141,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
11411141
11421142 // Make it repeat a bunch with a shader
11431143 const pattern = img . makeShader ( CanvasKit . TileMode . Repeat , CanvasKit . TileMode . Mirror ) ;
1144- const patternPaint = new CanvasKit . SkPaint ( ) ;
1144+ const patternPaint = new CanvasKit . Paint ( ) ;
11451145 patternPaint . setShader ( pattern ) ;
11461146
11471147 let i = 0 ;
@@ -1170,18 +1170,18 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
11701170 }
11711171 const img = CanvasKit . MakeImageFromEncoded ( imgData ) ;
11721172
1173- const paint = new CanvasKit . SkPaint ( ) ;
1173+ const paint = new CanvasKit . Paint ( ) ;
11741174 paint . setColor ( CanvasKit . Color ( 0 , 0 , 0 , 0.8 ) ) ;
11751175
1176- const srcs = new CanvasKit . SkRectBuilder ( ) ;
1176+ const srcs = new CanvasKit . RectBuilder ( ) ;
11771177 srcs . push ( 0 , 0 , 250 , 250 ) ; // LTRB
11781178 srcs . push ( 250 , 0 , 500 , 250 ) ;
11791179
11801180 const dsts = new CanvasKit . RSXFormBuilder ( ) ;
11811181 dsts . push ( .5 , 0 , 0 , 0 ) ; // scos, ssin, tx, ty
11821182 dsts . push ( 0 , .8 , 200 , 100 ) ;
11831183
1184- const colors = new CanvasKit . SkColorBuilder ( ) ;
1184+ const colors = new CanvasKit . ColorBuilder ( ) ;
11851185 colors . push ( CanvasKit . ColorAsInt ( 85 , 170 , 10 , 128 ) ) ; // light green
11861186 colors . push ( CanvasKit . ColorAsInt ( 51 , 51 , 191 , 128 ) ) ; // light blue
11871187
@@ -1199,18 +1199,7 @@ <h2> CanvasKit can allow for text shaping (e.g. breaking, kerning)</h2>
11991199 dsts . set ( 1 , scale * Math . sin ( i / 20 ) , scale * Math . cos ( i / 20 ) , 200 , 100 ) ;
12001200
12011201 canvas . drawAtlas ( img , srcs , dsts , paint , CanvasKit . BlendMode . Plus , colors ) ;
1202-
1203- // Skip drawing the 17th frame to the screen, and instead draw it to
1204- // an SkPicture - a format which can be useful for debugging.
1205- // The C++ version of Skia can open a SKP created by the WASM version,
1206- // which can aid performance diagnosis.
1207- //if (i === 17) {
1208- // const pic = surface.captureFrameAsSkPicture(drawFrame, "frame17.skp");
1209- // pic.DEBUGONLY_saveAsFile("frame17.skp");
1210- // pic.delete();
1211- // } else {
1212- surface . requestAnimationFrame ( drawFrame ) ;
1213- // }
1202+ surface . requestAnimationFrame ( drawFrame ) ;
12141203 }
12151204 surface . requestAnimationFrame ( drawFrame ) ;
12161205
0 commit comments