Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5-webdev· AnthropicHugging Face Arena WebDev Preferences (2026)

I'm working on a fully local simple graffiti drawing offline game (basic MS Paint style…

  1. User

    I'm working on a fully local simple graffiti drawing offline game (basic MS Paint style brush) and I need a way to prevent players from making offensive content (e.g., drawing swastikas and whatnot).

    For that, re-create that simple graffiti drawing interface and then create a moderation script that inputs the canvas with the drawing from the interface (in a way that would make it simple to plug that moderations script into the game itself) and then simply shows what it detected (e.g. 'no forbidden content - a car' if it's some inoffensive drawing like a car or 'forbidden content - swastika' if it's something offensive like swastika or other inappropriate drawing), so later in my game I can match it with the block list.

    List of JavaScript libraries you might utilize:

    • TensorFlow.js The core engine. Runs models fully in-browser (WebGL/WASM/WebGPU), 100% offline. Everything below sits on top of it or is an alternative to it.
    • ONNX Runtime Web Alternative runtime; run models exported to ONNX in-browser.
    • Transformers.js (Hugging Face) Run modern vision/vision-language models locally in JS. Heavier, but future-proof if you want a smarter classifier.
    • MediaPipe Tasks (JS) Google's on-device vision tasks, including an image classifier task you can load custom models into.
    • brain.js Lightweight neural nets in JS; workable for very simple custom classification, less capable than TF.js.
    • NSFWJS Popular TF.js model classifying images into porn/hentai/sexy/neutral/drawing. Runs fully offline. Good if you also want to block explicit drawings — but it will not detect swastikas.
    • OpenCV.js Full OpenCV compiled to WASM. Could do template/shape matching or contour analysis. In practice, brittle for freely-drawn rotated symbols — treat as a secondary signal, not the main line of defense.
    • Quick, Draw!/DoodleNet-style classifier
    • Use an existing DoodleNet / Quick, Draw!-style model, and map suspicious guesses to flags: swastika → often guessed as "stairs" / "windmill", peengus → often guessed as "hot dog" / "mushroom" / "snake" / "carrot"

    False positives are acceptable as long as it works. Apply whatever restrictions it takes to guarantee maximum accuracy as possible however (e.g., smaller image resolution like 100x100 - if it actually improves it).

  2. Claude Assistant

    I'll research the best approach for an offline doodle classifier before building the app.

    Now I'll build the project. First, installing TensorFlow.js (used for the optional pluggable "real model" upgrade path), then building the core moderation engine files.

    Now let's build the core image-processing utilities (binarizing the canvas, computing Hu moments, and symmetry analysis).

    Now the Hu-moment shape descriptor module:

    Now the main moderation engine that ties everything together and exposes the pluggable API:

    Expected — now let's create the optional neural model upgrade path (neuralModel.ts), which lets users drop in a real pretrained DoodleNet model later while working fully offline today via the heuristic engine.

    Now let's build the drawing canvas component (the MS-Paint style interface):

    Now let's build the main App.tsx tying the canvas, moderation panel, and example loader together:

    Now let's build the project to check for errors.

    The build succeeded and the title is updated. Here's a summary of what I built:

    Summary

    The drawing interface (src/components/DoodleCanvas.tsx) — a classic MS Paint-style graffiti canvas with color palette + custom color picker, brush size slider, eraser, undo, and clear, using pointer events for smooth freehand strokes.

    The moderation engine (src/moderation/) — a fully offline, on-device computer-vision pipeline, since I discovered mid-build that I have no way to reliably transfer the multi-megabyte binary weights of an actual pretrained DoodleNet model into this sandbox (attempts to fetch the real 345-class Quick,Draw model got truncated). Rather than fake it, I engineered a genuine, explainable, zero-dependency-weights alternative:

    • imageProcessing.ts — normalizes the canvas into a cropped/centered binary grid, plus symmetry/connected-component/hole/ray-cast analysis.
    • moments.ts — computes classic Hu image moments (rotation/scale/translation-invariant shape fingerprints), including the 7th moment that flips sign for mirror-image ("chiral") shapes.
    • templates.ts — a library of ~20 canvas-drawn reference shapes (car, house, star, circle... and flagged proxies: swastika/windmill/stairs for hate symbols, hot dog/mushroom/snake/carrot for explicit anatomy — exactly the DoodleNet misclassification mapping you described).
    • moderate.ts — the pluggable entry point: moderateCanvas(canvas) returns { forbidden, label, message, confidence, topGuesses, ... } with messages formatted exactly like "no forbidden content - car" / "forbidden content - swastika".
    • labelMapping.ts — the blocklist table your game can match against.
    • neuralModel.ts — an optional upgrade path: if you drop a real pretrained TF.js DoodleNet model (model.json, weights, class_names.txt) into public/model/, the app auto-detects and uses it instead — documented inline with the exact source to fetch it from.

    UI (App.tsx, ModerationPanel.tsx) — scan button + live auto-scan, confidence bars, "how it works" explainer, integration code snippet, and quick test-pattern buttons to instantly try flagged vs. safe shapes.

    Build completed successfully with no errors.

    Files built: index.html, src/moderation/imageProcessing.ts, src/moderation/moments.ts, src/moderation/templates.ts, src/moderation/moderate.ts, src/moderation/neuralModel.ts, src/moderation/labelMapping.ts, src/components/DoodleCanvas.tsx, src/components/ModerationPanel.tsx, src/App.tsx

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.