Skip to content

fihtony/drawIt

Repository files navigation

DrawIt Perfect

DrawIt Perfect is a fun drawing challenge where you try to draw perfect geometric shapes in one smooth stroke. As you draw, you'll see how accurate your shape is in real-time. When you beat your best score, enjoy a celebration animation that recognizes your achievement. You can play solo or create a group session to compete with friends, share your drawings, and see who can draw the most perfect shapes!

Live Demo

Try it out at drawit.tarch.ca

Screenshots

Solo Player

Solo Player

Play alone and challenge yourself to draw perfect geometric shapes. Each shape has a time limit, and you'll get real-time feedback on your drawing accuracy as you draw.

Celebration Animation

Celebration

When you achieve a new best score, enjoy a vibrant celebration animation that recognizes your achievement and keeps you motivated to improve.

Group Challenge

Group Challenge

Create or join a group session to compete with friends in real-time. Share shapes, see each other's drawings, and compete on leaderboards for each shape type.

Session Timer

Session Timer

Group sessions have a maximum duration of 30 minutes. A countdown timer appears in the last 3 minutes to let everyone know when the session will end.

Features

  • Canvas-based single-stroke drawing with real-time perfection scoring.
  • Support for circle, triangle, square, trapezoid, star, pentagon, hexagon, and heart.
  • Gradient feedback along the stroke, countdown timer, session-best tracking, and celebration effects.
  • Responsive sidebar with shape selector, status bar, and collapsible sections tailored for small screens.
  • Multiplayer groups (create/join/quit) with shared shape selection, live cursor sharing, synchronized drawings, and per-shape leaderboards.

Tech Stack

  • Front-end: Vanilla JavaScript, HTML5 canvas, CSS (responsive, mobile-first tweaks).
  • Real-time: WebSocket server built with Node.js + ws.
  • Testing: Node --test for server-side modules in tests/.

Project Structure

drawit/
├── index.html              # App markup
├── styles.css              # Global styles & responsive rules
├── app.js                  # Front-end controller
├── shapes.js               # Shape definitions & scoring helpers
├── js/modules/             # Front-end modules (drawing engine, dialogs, realtime, etc.)
├── server/                 # Node WebSocket server
└── tests/                  # Node test runner & suites

Prerequisites

  • Node.js 18+ (tested with Node 18 and 20).
  • npm 8+.

Local Development

# 1. Install dependencies for the WebSocket server/client utilities
npm install

# 2. Start the WebSocket server (port 3001 by default)
node server/index.js

# 3. Serve the static front-end (any static server works)
npx serve . -p 3456

# 4. Open the app
open http://localhost:3456

The client automatically connects to ws://localhost:3001 while running on localhost.

Running Tests

npm run test        # runs node --test tests/server-tests.js

Deployment Guide

The project consists of two deployables:

  1. Static Front-end (HTML/CSS/JS) – deploy to any static host.
  2. WebSocket Server (server/index.js) – deploy to a Node-compatible host that supports persistent WebSocket connections.

Tip: If your host requires HTTPS for WebSockets, use wss:// and ensure TLS is configured.

Server Configuration

The WebSocket server includes security features that can be configured via environment variables:

Origin Verification

The server only accepts WebSocket connections from allowed origins (domains). This prevents unauthorized websites from using your WebSocket server.

Configuration:

  • Set ALLOWED_ORIGINS environment variable (comma-separated list)
  • Default: https://drawit.tarch.ca

IP Connection Limits

Limit the number of concurrent WebSocket connections per IP address to prevent abuse.

Configuration:

  • Set MAX_CONNECTIONS_PER_IP environment variable
  • Default: 15 connections per IP

Contributing

  1. Fork, clone, and install dependencies.
  2. Create a branch (git checkout -b feature/...).
  3. Make changes, run tests, open a PR.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

Tony Xu
Email: tony@tarch.ca
Repository: https://github.com/fihtony/drawIt

About

Shape Drawing Challenge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors