MCPcopy Create free account
hub / github.com/divan/gotrace / createPath

Function createPath

page/js/three.js:35141–35246  ·  view source on GitHub ↗
( c, scale, offset )

Source from the content-addressed store, hash-verified

35139 }
35140
35141 function createPath( c, scale, offset ) {
35142
35143 var glyph = data.glyphs[ c ] || data.glyphs[ '?' ];
35144
35145 if ( ! glyph ) return;
35146
35147 var path = new THREE.Path();
35148
35149 var pts = [], b2 = THREE.ShapeUtils.b2, b3 = THREE.ShapeUtils.b3;
35150 var x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2, laste;
35151
35152 if ( glyph.o ) {
35153
35154 var outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) );
35155
35156 for ( var i = 0, l = outline.length; i < l; ) {
35157
35158 var action = outline[ i ++ ];
35159
35160 switch ( action ) {
35161
35162 case 'm': // moveTo
35163
35164 x = outline[ i ++ ] * scale + offset;
35165 y = outline[ i ++ ] * scale;
35166
35167 path.moveTo( x, y );
35168
35169 break;
35170
35171 case 'l': // lineTo
35172
35173 x = outline[ i ++ ] * scale + offset;
35174 y = outline[ i ++ ] * scale;
35175
35176 path.lineTo( x, y );
35177
35178 break;
35179
35180 case 'q': // quadraticCurveTo
35181
35182 cpx = outline[ i ++ ] * scale + offset;
35183 cpy = outline[ i ++ ] * scale;
35184 cpx1 = outline[ i ++ ] * scale + offset;
35185 cpy1 = outline[ i ++ ] * scale;
35186
35187 path.quadraticCurveTo( cpx1, cpy1, cpx, cpy );
35188
35189 laste = pts[ pts.length - 1 ];
35190
35191 if ( laste ) {
35192
35193 cpx0 = laste.x;
35194 cpy0 = laste.y;
35195
35196 for ( var i2 = 1; i2 <= divisions; i2 ++ ) {
35197
35198 var t = i2 / divisions;

Callers 1

createPathsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected