(faceCountour, faceHeight, faceWidth)
| 107 | } |
| 108 | |
| 109 | export function generateMouthShape1(faceCountour, faceHeight, faceWidth) { |
| 110 | // the first one is a a big smile U shape |
| 111 | var faceCountourCopy = faceCountour.slice(0, faceCountour.length - 2); |
| 112 | // choose one point on face at bottom side |
| 113 | var mouthRightY = randomFromInterval(faceHeight / 7, faceHeight / 4) |
| 114 | var mouthLeftY = randomFromInterval(faceHeight / 7, faceHeight / 4) |
| 115 | var mouthRightX = randomFromInterval(faceWidth / 10, faceWidth / 2) |
| 116 | var mouthLeftX = -mouthRightX + randomFromInterval(-faceWidth / 20, faceWidth / 20) |
| 117 | var mouthRight = [mouthRightX, mouthRightY] |
| 118 | var mouthLeft = [mouthLeftX, mouthLeftY] |
| 119 | |
| 120 | var controlPoint0 = [randomFromInterval(0, mouthRightX), randomFromInterval(mouthLeftY + 5, faceHeight / 1.5)] |
| 121 | var controlPoint1 = [randomFromInterval(mouthLeftX, 0), randomFromInterval(mouthLeftY + 5, faceHeight / 1.5)] |
| 122 | |
| 123 | var mouthPoints = [] |
| 124 | for (var i = 0; i < 1; i += 0.01) { |
| 125 | mouthPoints.push(cubicBezier(mouthLeft, controlPoint1, controlPoint0, mouthRight, i)) |
| 126 | } |
| 127 | |
| 128 | var center = [(mouthRight[0] + mouthLeft[0]) / 2, mouthPoints[25][1] / 2 + mouthPoints[75][1] / 2]; |
| 129 | if (Math.random() > 0.5) { |
| 130 | for (var i = 0; i < 1; i += 0.01) { |
| 131 | mouthPoints.push(cubicBezier(mouthRight, controlPoint0, controlPoint1, mouthLeft, i)) |
| 132 | } |
| 133 | }else{ |
| 134 | var y_offset_portion = randomFromInterval(0, 0.8); |
| 135 | for (var i = 0; i < 100; i += 1) { |
| 136 | mouthPoints.push([mouthPoints[99][0] * (1 - i / 100.0) + mouthPoints[0][0] * i / 100.0, (mouthPoints[99][1] * (1 - i / 100.0) + mouthPoints[0][1] * i / 100.0) * (1 - y_offset_portion) + mouthPoints[99 - i][1] * y_offset_portion]) |
| 137 | } |
| 138 | } |
| 139 | // translate to center |
| 140 | for (var i = 0; i < mouthPoints.length; i++) { |
| 141 | mouthPoints[i][0] -= center[0] |
| 142 | mouthPoints[i][1] -= center[1] |
| 143 | // rotate 180 degree |
| 144 | mouthPoints[i][1] = -mouthPoints[i][1] |
| 145 | // scale smaller |
| 146 | mouthPoints[i][0] = mouthPoints[i][0] * 0.6 |
| 147 | mouthPoints[i][1] = mouthPoints[i][1] * 0.6 |
| 148 | // translate back |
| 149 | mouthPoints[i][0] += center[0] |
| 150 | mouthPoints[i][1] += center[1] * 0.8 |
| 151 | } |
| 152 | return mouthPoints; |
| 153 | } |
| 154 | |
| 155 | export function generateMouthShape2(faceCountour, faceHeight, faceWidth) { |
| 156 | // generate a random center |
nothing calls this directly
no test coverage detected