The face itself
Everything the face needs is found in the botface.svelte
inside the components folder. It's a Svelte component which is displayed additionally to the contents of the +page.svelte
main page.
The script
tag:
- The necessary scripts, functions and assets are imported.
- The needed variables are created
eyeL
andeyeR
for the assets of the eyesmouth
for the asset of the mouthblinking
for the blinking abilitycolor
is for the default color the emotion should havemouth_class
andeye_class
for the right coloring later in the CSS- The animations are handled. See The animation for additional details
- The
robotFace(emotion)
function
robotFace(emotion)
The function contains a constant which holds all the available emotions and their needed assets, coloring classes and their blinking ability. Depending on the given emotion
the needed parameters are set for display and for the animation.
The HTML
The HTML is a single div
that contains the base of the face, the eyes and the mouth. They are displayed as HTML elements and not as simple SVGs. This allows us to recolor them freely, like an HTML element, without changing the color of the SVG.