1. Initialize Data
Define spirit classes and their images, positions, and sizes in JavaScript objects. Each class has a bit value that corresponds to a spirit class (e.g., Dewdrop = 1, Tulip = 2).
const classImages = { 1: { src: '/images/1.gif', width: 250, height: 250 }, ... };
const classFilters = { 1: 'Dewdrop', 2: 'Tulip', ... };
3. Bitmasking
The input is processed using bitwise operations. This helps determine which spirit images should be displayed based on which bits are set in the input.
const selectedImageKeys = Object.keys(classFilters).filter(key => (input & parseInt(key)) > 0);
4. Render Images
For each matching bit, corresponding images are dynamically displayed. The images are positioned based on the data stored in `classImages`.
return selectedImageKeys.map(key => {
const selectedImage = classImages[key];
return ();
});
5. Display Spirit Information
A table is shown that links each bit value to a spirit class name (e.g., 1 = Dewdrop). This helps users understand which input reveals which spirits.
{Object.keys(classFilters).map(item => (
{item} | {classFilters[item]} |
))}
6. Styling and Responsiveness
CSS is used to style the images, and make the user interface visually appealing with features like hover effects and flexbox for layout.
.steps-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.step-box:hover { transform: translateY(-10px); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); }