MCPcopy
hub / github.com/txstc55/ugly-avatar / generateMouthShape2

Function generateMouthShape2

src/utils/mouth_shape.js:155–171  ·  view source on GitHub ↗
(faceCountour, faceHeight, faceWidth)

Source from the content-addressed store, hash-verified

153}
154
155export function generateMouthShape2(faceCountour, faceHeight, faceWidth) {
156 // generate a random center
157 var center = [randomFromInterval(-faceWidth / 8, faceWidth / 8), randomFromInterval(faceHeight / 4, faceHeight / 2.5)]
158
159 var mouthPoints = getEggShapePoints(randomFromInterval(faceWidth / 4, faceWidth / 10), randomFromInterval(faceHeight / 10, faceHeight / 20), 0.001, 50);
160 var randomRotationDegree = randomFromInterval(-Math.PI / 9.5, Math.PI / 9.5)
161 for (var i = 0; i < mouthPoints.length; i++) {
162 // rotate the point
163 var x = mouthPoints[i][0]
164 var y = mouthPoints[i][1]
165 mouthPoints[i][0] = x * Math.cos(randomRotationDegree) - y * Math.sin(randomRotationDegree)
166 mouthPoints[i][1] = x * Math.sin(randomRotationDegree) + y * Math.cos(randomRotationDegree)
167 mouthPoints[i][0] += center[0]
168 mouthPoints[i][1] += center[1]
169 }
170 return mouthPoints;
171}

Callers

nothing calls this directly

Calls 2

randomFromIntervalFunction · 0.70
getEggShapePointsFunction · 0.70

Tested by

no test coverage detected