Recreating a Front-End Motion Effect with Large Language Models: From Requirement Breakdown to Evaluation

    This article describes a side-by-side evaluation of several large language models, each asked to recreate a spiral galaxy particle animation from a live web page. Particles gather into a shape as the user scrolls and scatter like a starfield when they scroll back. The article explains why this task suits model evaluation, how the prompt was written, a possible implementation path with code examples, how the models compared, and a reusable evaluation method.

    As large language models advance quickly, code generation is no longer a question of whether a model can write code. The real question is whether it can accurately understand a complex requirement and deliver a working result. Recreating a front-end motion effect is a good test for this. It checks visual understanding, code structure design, and the precision of interaction details. This article uses a task to recreate a “spiral galaxy particle effect” as an example. It documents a full multi-model comparison and distills a reusable method.

    1. Why Use Motion Effect Recreation as an Evaluation Scenario

    The scenario has several properties that make it useful for evaluation:

    1. A clear target with a reference. The effect is an animation on a live web page. Particles gather into a specific shape as the user scrolls, then scatter into something resembling a starfield. Because a reference exists, quality is easy to judge. There is no vague verdict that each model has its own strengths.

    2. A minimal requirement description. I only state what I want. The model decides how to implement it. This shows the model’s ability to plan on its own rather than following step-by-step instructions.

    3. A long chain of steps. The model must understand the visual logic of the effect, obtain the reference page’s source code or screenshots, analyze minified and obfuscated code, design a particle system, write rendering logic, and tune parameters. A weak link at any step lowers the final result.

    I initially wanted the models to use computer-use capabilities to operate the local environment and fetch page resources directly. Every model chose a built-in browser or a browser extension instead. In hindsight, this makes sense. Loading the page in a browser retrieves its resources. However, the code is often minified and loaded in batches, so retrieving and analyzing it is still difficult.

    2. Writing the Requirement: Prompt Design Principles

    My prompt was deliberately short. It had three points:

    • Goal: The page has a particle effect. On scroll, particles gather into a specific shape. After scattering, they look like star points. Hovering the mouse gives interactive feedback.
    • Deliverable: A standalone demo page that runs on its own.
    • Constraint: No creative reinterpretation. The goal is an exact replica.

    One prompt design lesson matters most: describe the phenomenon, not the implementation. I never mentioned Canvas, WebGL, particle counts, or easing functions. I described how the effect looks and behaves. This tests whether a model can map observed behavior to a technical approach on its own, and that mapping separates capability levels.

    Readers who want to try this themselves can use an equivalent requirement:

    1. Task: Recreate a particle gather-and-scatter effect
    2. Phenomenon:
    3. 1. A large number of particles are randomly distributed on a canvas, drifting slowly like a starfield
    4. 2. As the page scrolls, the particles gradually gather to form a target shape
    5. 3. Scrolling again scatters the particles back out
    6. 4. When the mouse moves, nearby particles react by being pushed away or following the cursor
    7. Deliverable: A standalone HTML demo page that opens directly in a browser

    3. Breakdown of an Implementation Path

    The reproduction results point to a reasonable implementation path with five stages:

    1. Sampling the target shape

    Gathering particles into a shape means mapping particles to a set of target points. A common method draws the target text or graphic onto an offscreen canvas, scans the pixels at a set step size, and collects the coordinates of non-transparent pixels as target points. Sampling density controls how sharp the final shape looks and also sets the particle count. You must balance visual fidelity against rendering performance.

    2. Designing the particle state

    Each particle needs at least a current position, a target position, and a velocity. Easing interpolation usually produces smooth transitions between gathering and scattering:

    1. // Update each frame: move toward the target point with easing
    2. particle.x += (particle.tx - particle.x) * ease;
    3. particle.y += (particle.ty - particle.y) * ease;

    The ease value typically falls between 0.02 and 0.08. Smaller values produce a more gradual, elegant gathering. Larger values make the motion snappier.

    3. Creating the starfield state when scattered

    Scattering does not simply clear the target points. Each particle gets a random drifting target, plus a slow sine-wave perturbation that mimics the breathing motion of stars. Whether this detail is included makes a clearly visible difference.

    4. Mouse interaction

    A common approach centers a repulsion force on the mouse position. Particles inside the radius are pushed away, and the force weakens with distance. Structure each particle’s offset as “target offset plus restoring force” so that pushed particles return to their positions naturally. Without this, the interaction looks abrupt.

    5. Scroll listening and state switching

    Listen for scroll events. Switch between the “gathered” and “scattered” target states based on the scroll range. Apply throttling so that rapid scroll events do not cause the state to flicker.

    4. Evaluation Results and Observations

    After I gave the same prompt to several leading models, the results fell into clear tiers:

    • Top tier: These models produced a complete, smooth version in one attempt. The gathered shape, easing rhythm, and mouse feedback all came close to the reference and were ready to use with little change.
    • Middle tier: These models got the overall flow working but lost points on details. Common issues included blurry shape edges, easing that moved too fast and looked like a sudden jump, and mouse repulsion strength set to unreasonable values.
    • Bottom tier: These models had structural problems, such as a particle count that did not match the sampled shape, or tangled state-switching logic. Their first version differed clearly from the reference, and they needed several rounds of iteration to converge.

    One useful observation: expectations strongly shape subjective judgment. When expectations for a model were low, an acceptable result felt like a pleasant surprise. With high expectations, the same output may only earn a “nothing special” rating. When evaluating models, anchor judgments to an objective reference, here the reference page, rather than relying on gut feeling.

    5. Reusable Conclusions

    1. Evaluate with tasks that have a reference answer. Visual replication, algorithm problems, and conversion to a fixed output format expose real capability gaps more reliably than open-ended tasks.

    2. Prompt for the goal, not the method. Leaving the model room to plan shows its true capability ceiling. It also makes it easier to compare technical choices across models.

    3. Acceptance criteria for motion effects: shape accuracy (is the gathered shape clear?), rhythm (does the easing feel natural?), interaction feedback (does the mouse response feel refined?), and performance (particle count and frame rate). Scoring each item separately is more useful than a general verdict like “looks good.”

    4. The first version is rarely the final one. Even the best-performing model needed one or two rounds of parameter tuning. The practical way to work with AI today is to treat it as a first-draft generator and a fast iteration partner, not a one-click delivery tool.

    Overall, leading models already handle complex front-end motion tasks well. Fidelity to the original, however, still varies noticeably between models. For developers, a structured evaluation method has more long-term value than chasing any single model.