All tales starts with a hero-to-be on a adventure ...
His / her quest ?
"Final boss"
Solutions
Many solutions
Spoiler in title 😣
Solution #1 : "GIF"
Is it pronouced `gee-if` or "jee-if" ?Solution #1 : "GIF"
How ?
- Save animation as a GIF
- Host the GIF file somewhere
- Load the GIF asset
What ?
Why not ?
- File size can be big even at low resolutions
Why not ?
- File size can be big even at low resolutions
- Lower FPS vs file size
- Resize and Scaling (reusability) issues
- How do I even "GIF" ?
Solution #2 : Animation Libraries
Making our problem other people's problemSolution #2 : Animation Libraries
How ?
- Create animation (online editor / photoshop)
- Export JSON file
- Load animation library
- Load JSON file
Why ?
Why ?
- Smaller file size
- Simple to use
- JSON file usable across platforms
Why not ?
- Need photoshop skills ?
- High initialisation cost
It's time to engineer it ourselves!
"Weiyuan, why are you looking up Wikipedia for trigonometry?" - ManagerSolution #3 : CSS
How ?
- Implement CSS styles
- Load CSS Stylesheet
- That's it?
Breaking down the problem
- Hexagon
- Rotation Animation
- Hexagons of different sizes
- Clockwise and Anti-clockwise animation for each hexagon
Breaking down the problem
- Hexagon
- Rotation Animation
- Hexagons of different sizes
- Clockwise and Anti-clockwise animation for each hexagon
Hexagon
- Draw a <div /> with top and bottom border
- Do the same for ":before", rotate 60°
- Do the same for ":after", rotate -60°
Height !== Side (width)
Re-examine the hexagon
#toacahsoh
Solution #3.1 : CSS Sass
Using the SCSS syntaxFAQ : Why not SVG ?
1.2% of all domains were using at least one SVG background image 11 - Fun fact from Css Tricks
FAQ : Why not SVG ?
Smallest file size !!!
Why not ?
- Coupling of styling methods with server side content
What if my Sass functions break ?
Can we even unit test CSS ?What if my SCSS functions break ?
Writing a test for factorial method
It works!
Reflecting on my "adventure"
Level 1 - Gifs - n00b days
Level 10 - Third party - student / young engineer
Level 50 - Performance, Practices - maturing engineer
Level ? - Unit tests - ???
Trigonometry in CSS - WIP ?
Watch out for it