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

Function generateBothEyes

src/utils/eye_shape.js:139–163  ·  view source on GitHub ↗
(width = 50)

Source from the content-addressed store, hash-verified

137}
138
139export function generateBothEyes(width = 50) {
140 let rands_left = generateEyeParameters(width)
141 // Create a shallow copy of the object
142 let rands_right = { ...rands_left };
143
144 // Iterate over the object's keys
145 for (let key in rands_right) {
146 // Check if the property value is a number
147 if (typeof rands_right[key] === 'number') {
148 // Add a random value to the number, for example, between -5 and 5
149 rands_right[key] += randomFromInterval(-rands_right[key] / 2.0, rands_right[key] / 2.0);
150 }
151 }
152 let left_eye = generateEyePoints(rands_left, width)
153 let right_eye = generateEyePoints(rands_right, width)
154
155 for (let key in left_eye) {
156 if (typeof left_eye[key] === 'object') {
157 for (let i = 0; i < left_eye[key].length; i++) {
158 left_eye[key][i][0] = -left_eye[key][i][0]
159 }
160 }
161 }
162 return { left: left_eye, right: right_eye }
163}

Callers

nothing calls this directly

Calls 3

generateEyeParametersFunction · 0.85
generateEyePointsFunction · 0.85
randomFromIntervalFunction · 0.70

Tested by

no test coverage detected