The user wants me to create a collaborative sketching ritual tool. Let me break down the requirements:
- Shared canvases - Multiple users can draw on the same canvas
- Design tokens - Predefined design elements/colors/spacing that can be used
- Real-time feasibility feedback - Some kind of analysis/feedback on what's being drawn
Since this needs to be a single HTML file and can't use external APIs, I'll simulate the collaborative aspect with:
- Multiple canvas layers that users can switch between
- Simulated "other users" drawing or a local multi-cursor approach
- Design tokens panel with colors, shapes, and UI elements
- A feasibility analysis system that gives feedback on the sketch
Key features to implement:
- Drawing Canvas - Smooth drawing with pressure sensitivity simulation
- Design Tokens Panel - Colors, spacing, typography, component shapes
- Real-time Feedback - Analysis of the sketch showing:
- Complexity score
- Component detection
- Accessibility suggestions
- Implementation difficulty
- Simulated Collaboration - Show "presence" of other users with cursors
- Ritual Elements - Structured phases/timing for collaborative sessions
Visual Design:
- Dark theme with neon accents (not purple!)
- Cyan/teal as primary accent
- Orange/coral as secondary
- Grid pattern background
- Glowing effects on interactive elements
Let me create an immersive, professional sketching environment.
Dynamic elements:
- Particle trails following the brush
- Animated cursor presence from "other users"
- Pulsing design tokens
- Live updating feasibility metrics with animated counters
- Smooth drawing with glow effects
Let me code this:
Collaborative Sketching Ritual - Design Analysis
Concept Overview
I'll create an immersive collaborative sketching environment with:
- Shared Canvas System - Multi-layer drawing with simulated collaborator presence
- Design Tokens Panel - Draggable color palettes, spacing units, and component shapes
- Real-time Feasibility Engine - Live analysis of sketch complexity, accessibility, and implementation difficulty
- Ritual Phases - Structured collaboration with timers and phase transitions
The ritual aspect introduces timed phases (Diverge → Converge → Refine) to structure the collaborative design process.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Collaborative Sketching Ritual</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: #0a0f14;
color: #e8f0f5;
overflow: hidden;
height: 100vh;
}
.app-container {
display: grid;
grid-template-columns: 280px 1fr 320px;
grid-template-rows: 60px 1fr 80px;
height: 100vh;
gap: 1px;
background: #1a2530;
}
/* Header */
.header {
grid-column: 1 / -1;
background: linear-gradient(135deg, #0d1318 0%, #1a2830 100%);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
border-bottom: 1px solid #2a3a48;
}
.logo {
display: flex;
align-items: center;
gap: 12px;
}
.logo-icon {
width: 36px;
height: 36px;
background: linear-gradient(135deg, #00d4aa 0%, #00a8cc 100%);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 18px;
color: #0a0f14;
}
.logo h1 {
font-size: 18px;
font-weight: 600;
letter-spacing: 0.5px;
}
.ritual-phase {
display: flex;
align-items: center;
gap: 20px;
}
.phase-indicator {
display: flex;
gap: 8px;
}
.phase {
padding: 8px 16px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
background: #1a2830;
border: 1px solid #2a3a48;
transition: all 0.4s ease;
cursor: pointer;
}
.phase.active {
background: linear-gradient(135deg, #00d4aa 0%, #00a8cc 100%);
color: #0a0f14;
border-color: transparent;
box-shadow: 0 0 20px rgba(0, 212, 170, 0.4);
}
.phase:hover:not(.active) {
border-color: #00d4aa;
}
.timer {
font-size: 24px;
font-weight: 700;
font-family: 'Courier New', monospace;
color: #00d4aa;
min-width: 80px;
text-align: center;
}
.collaborators {
display: flex;
align-items: center;
gap: 8px;
}
.avatar {
width: 36px;
height: 36px;
border-radius: 50%;
border: 2px solid;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 600;
transition: transform 0.2s;
}
.avatar:hover {
transform: scale(1.1);
}
.avatar.user-1 { background: #2a4858; border-color: #00d4aa; color: #00d4aa; }
.avatar.user-2 { background: #48302a; border-color: #ff6b4a; color: #ff6b4a; }
.avatar.user-3 { background: #3a482a; border-color: #a8cc00; color: #a8cc00; }
.avatar-count {
font-size: 12px;
color: #6a7a88;
}
/* Left Panel - Design Tokens */
.tokens-panel {
background: #0d1318;
padding: 20px;
overflow-y: auto;
border-right: 1px solid #2a3a48;
}
.panel-section {
margin-bottom: 24px;
}
.panel-title {
font-size: 11px;
text-transform: uppercase;
letter-spacing: 1.5px;
color: #6a7a88;
margin-bottom: 12px;
font-weight: 600;
}
.color-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
}
.color-token {
aspect-ratio: 1;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s;
border: 2px solid transparent;
position: relative;
}
.color-token:hover {
transform: scale(1.1);
z-index: 1;
}
.color-token.selected {
border-color: #fff;
box-shadow: 0 0 12px currentColor;
}
.color-token::after {
content: attr(data-label);
position: absolute;
bottom: -18px;
left: 50%;
transform: translateX(-50%);
font-size: 8px;
color: #6a7a88;
white-space: nowrap;
opacity: 0;
transition: opacity 0.2s;
}
.color-token:hover::after {
opacity: 1;
}
.spacing-tokens {
display: flex;
flex-direction: column;
gap: 8px;
}
.spacing-token {
display: flex;
align-items: center;
gap: 12px;
padding: 8px 12px;
background: #1a2530;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s;
}
.spacing-token:hover {
background: #2a3a48;
}
.spacing-token.selected {
background: linear-gradient(135deg, rgba(0, 212, 170, 0.2) 0%, rgba(0, 168, 204, 0.2) 100%);
border: 1px solid #00d4aa;
}
.spacing-bar {
height: 8px;
background: #00d4aa;
border-radius: 4px;
}
.spacing-label {
font-size: 12px;
color: #8a9aa8;
min-width: 40px;
}
.component-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.component-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px;
background: #1a2530;
border-radius: 8px;
cursor: grab;
transition: all 0.2s;
border: 1px solid transparent;
}
.component-item:hover {
background: #2a3a48;
border-color: #3a4a58;
}
.component-item:active {
cursor: grabbing;
}
.component-icon {
width: 32px;
height: 32px;
background: #0d1318;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
}
.component-icon svg {
width: 18px;
height: 18px;
stroke: #00d4aa;
fill: none;
stroke-width: 2;
}
.component-name {
font-size: 13px;
flex: 1;
}
/* Canvas Area */
.canvas-area {
background: #0a0f14;
position: relative;
overflow: hidden;
}
.canvas-grid {
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(42, 58, 72, 0.3) 1px, transparent 1px),
linear-gradient(90deg, rgba(42, 58, 72, 0.3) 1px, transparent 1px);
background-size: 20px 20px;
pointer-events: none;
}
#mainCanvas {
position: absolute;
inset: 0;
cursor: crosshair;
}
.cursor-presence {
position: absolute;
pointer-events: none;
z-index: 100;
transition: all 0.1s linear;
}
.cursor-pointer {
width: 20px;
height: 20px;
border-left: 2px solid;
border-top: 2px solid;
transform: rotate(-45deg);
}
.cursor-label {
position: absolute;
top: 20px;
left: 10px;
font-size: 11px;
padding: 2px 8px;
border-radius: 4px;
white-space: nowrap;
font-weight: 600;
}
.cursor-presence.user-2 .cursor-pointer { border-color: #ff6b4a; }
.cursor-presence.user-2 .cursor-label { background: #ff6b4a; color: #0a0f14; }
.cursor-presence.user-3 .cursor-pointer { border-color: #a8cc00; }
.cursor-presence.user-3 .cursor-label { background: #a8cc00; color: #0a0f14; }
.brush-preview {
position: absolute;
border-radius: 50%;
pointer-events: none;
border: 1px solid rgba(255, 255, 255, 0.5);
transform: translate(-50%, -50%);
z-index: 50;
}
/* Right Panel - Feasibility */
.feasibility-panel {
background: #0d1318;
padding: 20px;
overflow-y: auto;
border-left: 1px solid #2a3a48;
}
.metric-card {
background: #1a2530;
border-radius: 12px;
padding: 16px;
margin-bottom: 16px;
}
.metric-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.metric-title {
font-size: 13px;
font-weight: 600;
color: #8a9aa8;
}
.metric-value {
font-size: 24px;
font-weight: 700;
}
.metric-bar {
height: 6px;
background: #0a0f14;
border-radius: 3px;
overflow: hidden;
}
.metric-fill {
height: 100%;
border-radius: 3px;
transition: width 0.5s ease;
}
.metric-fill.green { background: linear-gradient(90deg, #00d4aa, #00a8cc); }
.metric-fill.yellow { background: linear-gradient(90deg, #a8cc00, #ccaa00); }
.metric-fill.red { background: linear-gradient(90deg, #ff6b4a, #cc4a6b); }
.feasibility-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.feasibility-item {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 12px;
background: #1a2530;
border-radius: 8px;
font-size: 12px;
}
.feasibility-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.feasibility-dot.pass { background: #00d4aa; }
.feasibility-dot.warn { background: #a8cc00; }
.feasibility-dot.fail { background: #ff6b4a; }
.suggestions-box {
background: linear-gradient(135deg, rgba(0, 212, 170, 0.1) 0%, rgba(0, 168, 204, 0.1) 100%);
border: 1px solid rgba(0, 212, 170, 0.3);
border-radius: 12px;
padding: 16px;
margin-top: 16px;
}
.suggestions-title {
font-size: 12px;
font-weight: 600;
color: #00d4aa;
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 8px;
}
.suggestion-item {
font-size: 12px;
color: #8a9aa8;
padding: 6px 0;
border-bottom: 1px solid rgba(42, 58, 72, 0.5);
line-height: 1.4;
}
.suggestion-item:last-child {
border-bottom: none;
}
/* Bottom Toolbar */
.toolbar {
grid-column: 1 / -1;
background: linear-gradient(135deg, #0d1318 0%, #1a2830 100%);
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
padding: 0 24px;
border-top: 1px solid #2a3a48;
}
.tool-group {
display: flex;
gap: 4px;
padding: 8px 12px;
background: #1a2530;
border-radius: 12px;
}
.tool-btn {
width: 44px;
height: 44px;
border: none;
background: transparent;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
color: #6a7a88;
}
.tool-btn:hover {
background: #2a3a48;
color: #e8f0f5;
}
.tool-btn.active {
background: linear-gradient(135deg, #00d4aa 0%, #00a8cc 100%);
color: #0a0f14;
}
.tool-btn svg {
width: 22px;
height: 22px;
}
.brush-size-control {
display: flex;
align-items: center;
gap: 12px;
padding: 8px 16px;
background: #1a2530;
border-radius: 12px;
}
.brush-size-label {
font-size: 11px;
color: #6a7a88;
text-transform: uppercase;
letter-spacing: 1px;
}
.brush-slider {
width: 120px;
height: 6px;
-webkit-appearance: none;
background: #0a0f14;
border-radius: 3px;
outline: none;
}
.brush-slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: linear-gradient(135deg, #00d4aa 0%, #00a8cc 100%);
cursor: pointer;
box-shadow: 0 0 10px rgba(0, 212, 170, 0.5);
}
.size-value {
font-size: 14px;
font-weight: 600;
color: #00d4aa;
min-width: 30px;
}
.action-btn {
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
text-transform: uppercase;
letter-spacing: 1px;
}
.action-btn.primary {
background: linear-gradient(135deg, #00d4aa 0%, #00a8cc 100%);
color: #0a0f14;
}
.action-btn.primary:hover {
box-shadow: 0 0 20px rgba(0, 212, 170, 0.5);
transform: translateY(-1px);
}
.action-btn.secondary {
background: #1a2530;
color: #e8f0f5;
border: 1px solid #2a3a48;
}
.action-btn.secondary:hover {
border-color: #00d4aa;
}
.divider {
width: 1px;
height: 30px;
background: #2a3a48;
margin: 0 8px;
}
/* Animations */
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-5px); }
}
.pulse {
animation: pulse 2s ease-in-out infinite;
}
.float {
animation: float 3s ease-in-out infinite;
}
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #0d1318;
}
::-webkit-scrollbar-thumb {
background: #2a3a48;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #3a5a68;
}
</style>
</head>
<body>
<div class="app-container">
<!-- Header -->
<header class="header">
<div class="logo">
<div class="logo-icon">R</div>
<h1>Ritual Sketch</h1>
</div>
<div class="ritual-phase">
<div class="phase-indicator">
<div class="phase active" data-phase="diverge">Diverge</div>
<div class="phase" data-phase="converge">Converge</div>
<div class="phase" data-phase="refine">Refine</div>
</div>
<div class="timer">05:00</div>
</div>
<div class="collaborators">
<div class="avatar user-1">You</div>
<div class="avatar user-2">AK</div>
<div class="avatar user-3">MJ</div>
<span class="avatar-count">+2 more</span>
</div>
</header>
<!-- Left Panel - Design Tokens -->
<aside class="tokens-panel">
<div class="panel-section">
<h3 class="panel-title">Color Tokens</h3>
<div class="color-grid" id="colorGrid"></div>
</div>
<div class="panel-section">
<h3 class="panel-title">Spacing Scale</h3>
<div class="spacing-tokens" id="spacingTokens"></div>
</div>
<div class="panel-section">
<h3 class="panel-title">Components</h3>
<div class="component-list" id="componentList"></div>
</div>
<div class="panel-section">
<h3 class="panel-title">Stroke Style</h3>
<div class="spacing-tokens">
<div class="spacing-token selected" data-style="solid">
<div class="spacing-label">Solid</div>
<div class="spacing-bar" style="width: 100%; background: linear-gradient(90deg, #00d4aa, #00a8cc);"></div>
</div>
<div class="spacing-token" data-style="dashed">
<div class="spacing-label">Dashed</div>
<div class="spacing-bar" style="width: 100%; background: repeating-linear-gradient(90deg, #00d4aa 0px, #00d4aa 8px, transparent 8px, transparent 14px);"></div>
</div>
<div class="spacing-token" data-style="dotted">
<div class="spacing-label">Dotted</div>
<div class="spacing-bar" style="width: 100%; background: repeating-linear-gradient(90deg, #00d4aa 0px, #00d4aa 4px, transparent 4px, transparent 10px);"></div>
</div>
</div>
</div>
</aside>
<!-- Canvas Area -->
<main class="canvas-area">
<div class="canvas-grid"></div>
<canvas id="mainCanvas"></canvas>
<div class="brush-preview" id="brushPreview"></div>
<!-- Simulated collaborator cursors -->
<div class="cursor-presence user-2" id="cursor2">
<div class="cursor-pointer"></div>
<div class="cursor-label">Alex K</div>
</div>
<div class="cursor-presence user-3" id="cursor3">
<div class="cursor-pointer"></div>
<div class="cursor-label">Maya J</div>
</div>
</main>
<!-- Right Panel - Feasibility -->
<aside class="feasibility-panel">
<div class="panel-section">
<h3 class="panel-title">Feasibility Analysis</h3>
<div class="metric-card">
<div class="metric-header">
<span class="metric-title">Implementation Complexity</span>
<span class="metric-value" id="complexityValue" style="color: #00d4aa;">Low</span>
</div>
<div class="metric-bar">
<div class="metric-fill green" id="complexityBar" style="width: 25%;"></div>
</div>
</div>
<div class="metric-card">
<div class="metric-header">
<span class="metric-title">Accessibility Score</span>
<span class="metric-value" id="a11yValue" style="color: #a8cc00;">78%</span>
</div>
<div class="metric-bar">
<div class="metric-fill yellow" id="a11yBar" style="width: 78%;"></div>
</div>
</div>
<div class="metric-card">
<div class="metric-header">
<span class="metric-title">Component Coverage</span>
<span class="metric-value" id="coverageValue" style="color: #00d4aa;">12</span>
</div>
<div class="metric-bar">
<div class="metric-fill green" id="coverageBar" style="width: 60%;"></div>
</div>
</div>
</div>
<div class="panel-section">
<h3 class="panel-title">Design Checks</h3>
<div class="feasibility-list" id="feasibilityList"></div>
</div>
<div class="suggestions-box">
<div class="suggestions-title">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<line x1="12" y1="16" x2="12" y2="12"></line>
<line x1="12" y1="8" x2="12.01" y2="8"></line>
</svg>
AI Suggestions
</div>
<div id="suggestionsList">
<div class="suggestion-item">Consider adding more whitespace between sections</div>
<div class="suggestion-item">Button placement follows logical flow</div>
<div class="suggestion-item">Color contrast meets WCAG AA standards</div>
</div>
</div>
</aside>
<!-- Toolbar -->
<div class="toolbar">
<div class="tool-group">
<button class="tool-btn active" data-tool="brush" title="Brush">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 19l7-7 3 3-7 7-3-3z"></path>
<path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"></path>
</svg>
</button>
<button class="tool-btn" data-tool="eraser" title="Eraser">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 20H7L3 16c-.8-.8-.8-2 0-2.8L13.8 2.4c.8-.8 2-.8 2.8 0l6 6c.8.8.8 2 0 2.8L12 22"></path>
</svg>
</button>
<button class="tool-btn" data-tool="line" title="Line">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="5" y1="19" x2="19" y2="5"></line>
</svg>
</button>
<button class="tool-btn" data-tool="rect" title="Rectangle">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
</svg>
</button>
<button class="tool-btn" data-tool="circle" title="Circle">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
</svg>
</button>
</div>
<div class="divider"></div>
<div class="brush-size-control">
<span class="brush-size-label">Size</span>
<input type="range" class="brush-slider" id="brushSize" min="1" max="50" value="4">
<span class="size-value" id="sizeValue">4px</span>
</div>
<div class="divider"></div>
<button class="action-btn secondary" id="undoBtn">Undo</button>
<button class="action-btn secondary" id="clearBtn">Clear</button>
<button class="action-btn primary" id="exportBtn">Export</button>
</div>
</div>
<script>
// ============ Configuration ============
const CONFIG = {
colors: [
{ hex: '#00d4aa', name: 'Primary' },
{ hex: '#00a8cc', name: 'Secondary' },
{ hex: '#ff6b4a', name: 'Accent' },
{ hex: '#a8cc00', name: 'Success' },
{ hex: '#cc4a6b', name: 'Error' },
{ hex: '#8a4acc', name: 'Info' },
{ hex: '#ffffff', name: 'White' },
{ hex: '#1a2530', name: 'Dark' },
{ hex: '#3a4a58', name: 'Gray' },
{ hex: '#0d1318', name: 'Black' },
{ hex: '#ffcc00', name: 'Warning' },
{ hex: '#00ffcc', name: 'Cyan' }
],
spacing: [
{ value: 4, label: '4px' },
{ value: 8, label: '8px' },
{ value: 16, label: '16px' },
{ value: 24, label: '24px' },
{ value: 32, label: '32px' }
],
components: [
{ name: 'Button', icon: 'rect' },
{ name: 'Input', icon: 'input' },
{ name: 'Card', icon: 'card' },
{ name: 'Avatar', icon: 'circle' },
{ name: 'Badge', icon: 'badge' }
],
checks: [
{ label: 'Color Contrast', status: 'pass' },
{ label: 'Touch Targets', status: 'pass' },
{ label: 'Visual Hierarchy', status: 'warn' },
{ label: 'Responsive Grid', status: 'pass' },
{ label: 'Font Scaling', status: 'warn' }
]
};
// ============ State ============
const state = {
currentTool: 'brush',
currentColor: '#00d4aa',
brushSize: 4,
strokeStyle: 'solid',
isDrawing: false,
lastX: 0,
lastY: 0,
startX: 0,
startY: 0,
history: [],
phase: 'diverge',
timeRemaining: 300,
strokeCount: 0,
componentCount: 0
};
// ============ Canvas Setup ============
const canvas = document.getElementById('mainCanvas');
const ctx = canvas.getContext('2d');
const brushPreview = document.getElementById('brushPreview');
function resizeCanvas() {
const rect = canvas.parentElement.getBoundingClientRect();
canvas.width = rect.width;
canvas.height = rect.height;
redrawCanvas();
}
function redrawCanvas() {
ctx.fillStyle = '#0a0f14';
ctx.fillRect(0, 0, canvas.width, canvas.height);
state.history.forEach(stroke => drawStroke(stroke));
}
function drawStroke(stroke) {
ctx.beginPath();
ctx.strokeStyle = stroke.color;
ctx.lineWidth = stroke.size;
ctx.lineCap = 'round';
ctx.lineJoin = 'round';
if (stroke.style === 'dashed') {
ctx.setLineDash([10, 5]);
} else if (stroke.style === 'dotted') {
ctx.setLineDash([2, 6]);
} else {
ctx.setLineDash([]);
}
if (stroke.type === 'brush' && stroke.points.length > 0) {
ctx.moveTo(stroke.points[0].x, stroke.points[0].y);
for (let i = 1; i < stroke.points.length; i++) {
ctx.lineTo(stroke.points[i].x, stroke.points[i].y);
}
ctx.stroke();
} else if (stroke.type === 'line') {
ctx.moveTo(stroke.startX, stroke.startY);
ctx.lineTo(stroke.endX, stroke.endY);
ctx.stroke();
} else if (stroke.type === 'rect') {
ctx.strokeRect(stroke.x, stroke.y, stroke.width, stroke.height);
} else if (stroke.type === 'circle') {
const radius = Math.sqrt(Math.pow(stroke.width, 2) + Math.pow(stroke.height, 2)) / 2;
ctx.arc(stroke.centerX, stroke.centerY, radius, 0, Math.PI * 2);
ctx.stroke();
} else if (stroke.type === 'eraser' && stroke.points.length > 0) {
ctx.globalCompositeOperation = 'destination-out';
ctx.moveTo(stroke.points[0].x, stroke.points[0].y);
for (let i = 1; i < stroke.points.length; i++) {
ctx.lineTo(stroke.points[i].x, stroke.points[i].y);
}
ctx.stroke();
ctx.globalCompositeOperation = 'source-over';
}
ctx.setLineDash([]);
}
// ============ Drawing Functions ============
let currentStroke = null;
let tempCanvas = document.createElement('canvas');
let tempCtx = tempCanvas.getContext('2d');
function startDrawing(e) {
state.isDrawing = true;
const rect = canvas.getBoundingClientRect();
state.lastX = e.clientX - rect.left;
state.lastY = e.clientY - rect.top;
state.startX = state.lastX;
state.startY = state.lastY;
if (state.currentTool === 'brush' || state.currentTool === 'eraser') {
currentStroke = {
type: state.currentTool,
color: state.currentColor,
size: state.brushSize,
style: state.strokeStyle,
points: [{ x: state.lastX, y: state.lastY }]
};
}
tempCanvas.width = canvas.width;
tempCanvas.height = canvas.height;
tempCtx.drawImage(canvas, 0, 0);
}
function draw(e) {
const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
// Update brush preview
brushPreview.style.display = 'block';
brushPreview.style.left = e.clientX + 'px';
brushPreview.style.top = e.clientY + 'px';
brushPreview.style.width = state.brushSize + 'px';
brushPreview.style.height = state.brushSize + 'px';
brushPreview.style.background = state.currentTool === 'eraser' ? 'rgba(255,255,255,0.3)' : state.currentColor;
if (!state.isDrawing) return;
if (state.currentTool === 'brush' || state.currentTool === 'eraser') {
currentStroke.points.push({ x, y });
// Draw incrementally
ctx.beginPath();
ctx.moveTo(state.lastX, state.lastY);
ctx.lineTo(x, y);
ctx.strokeStyle = state.currentTool === 'eraser' ? '#0a0f14' : state.currentColor;
ctx.lineWidth = state.brushSize;
ctx.lineCap = 'round';
if (state.currentTool === 'eraser') {
ctx.globalCompositeOperation = 'destination-out';
}
if (state.strokeStyle === 'dashed') {
ctx.setLineDash([10, 5]);
} else if (state.strokeStyle === 'dotted') {
ctx.setLineDash([2, 6]);
}
ctx.stroke();
ctx.setLineDash([]);
ctx.globalCompositeOperation = 'source-over';
} else {
// Shape tools - show preview
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(tempCanvas, 0, 0);
ctx.beginPath();
ctx.strokeStyle = state.currentColor;
ctx.lineWidth = state.brushSize;
ctx.lineCap = 'round';
if (state.strokeStyle === 'dashed') {
ctx.setLineDash([10, 5]);
} else if (state.strokeStyle === 'dotted') {
ctx.setLineDash([2, 6]);
}
if (state.currentTool === 'line') {
ctx.moveTo(state.startX, state.startY);
ctx.lineTo(x, y);
ctx.stroke();
} else if (state.currentTool === 'rect') {
ctx.strokeRect(state.startX, state.startY, x - state.startX, y - state.startY);
} else if (state.currentTool === 'circle') {
const radius = Math.sqrt(Math.pow(x - state.startX, 2) + Math.pow(y - state.startY, 2));
ctx.arc(state.startX, state.startY, radius, 0, Math.PI * 2);
ctx.stroke();
}
ctx.setLineDash([]);
}
state.lastX = x;
state.lastY = y;
}
function stopDrawing(e) {
if (!state.isDrawing) return;
state.isDrawing = false;
const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
if (state.currentTool === 'brush' || state.currentTool === 'eraser') {
if (currentStroke && currentStroke.points.length > 0) {
state.history.push(currentStroke);
state.strokeCount++;
}
} else if (state.currentTool === 'line') {
state.history.push({
type: 'line',
color: state.currentColor,
size: state.brushSize,
style: state.strokeStyle,
startX: state.startX,
startY: state.startY,
endX: x,
endY: y
});
state.componentCount++;
} else if (state.currentTool === 'rect') {
state.history.push({
type: 'rect',
color: state.currentColor,
size: state.brushSize,
style: state.strokeStyle,
x: state.startX,
y: state.startY,
width: x - state.startX,
height: y - state.startY
});
state.componentCount++;
} else if (state.currentTool === 'circle') {
state.history.push({
type: 'circle',
color: state.currentColor,
size: state.brushSize,
style: state.strokeStyle,
centerX: state.startX,
centerY: state.startY,
width: x - state.startX,
height: y - state.startY
});
state.componentCount++;
}
currentStroke = null;
updateFeasibility();
}
// ============ UI Setup ============
function setupColorGrid() {
const grid = document.getElementById('colorGrid');
grid.innerHTML = '';
CONFIG.colors.forEach((color, i) => {
const div = document.createElement('div');
div.className = 'color-token' + (i === 0 ? ' selected' : '');
div.style.background = color.hex;
div.dataset.color = color.hex;
div.dataset.label = color.name;
div.addEventListener('click', () => {
document.querySelectorAll('.color-token').forEach(el => el.classList.remove('selected'));
div.classList.add('selected');
state.currentColor = color.hex;
});
grid.appendChild(div);
});
}
function setupSpacingTokens() {
const container = document.getElementById('spacingTokens');
container.innerHTML = '';
CONFIG.spacing.forEach((space, i) => {
const div = document.createElement('div');
div.className = 'spacing-token' + (i === 0 ? ' selected' : '');
div.dataset.value = space.value;
div.innerHTML = `
<div class="spacing-label">${space.label}</div>
<div class="spacing-bar" style="width: ${space.value * 3}px;"></div>
`;
div.addEventListener('click', () => {
document.querySelectorAll('#spacingTokens .spacing-token').forEach(el => el.classList.remove('selected'));
div.classList.add('selected');
state.brushSize = space.value;
document.getElementById('brushSize').value = space.value;
document.getElementById('sizeValue').textContent = space.value + 'px';
});
container.appendChild(div);
});
}
function setupComponents() {
const container = document.getElementById('componentList');
container.innerHTML = '';
CONFIG.components.forEach(comp => {
const div = document.createElement('div');
div.className = 'component-item';
div.draggable = true;
div.innerHTML = `
<div class="component-icon">
<svg viewBox="0 0 24 24">
${getComponentIcon(comp.icon)}
</svg>
</div>
<span class="component-name">${comp.name}</span>
`;
container.appendChild(div);
});
}
function getComponentIcon(type) {
switch(type) {
case 'rect': return '<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>';
case 'input': return '<rect x="3" y="6" width="18" height="12" rx="2" ry="2"></rect><line x1="7" y1="12" x2="17" y2="12"></line>';
case 'card': return '<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="7" y1="8" x2="17" y2="8"></line><line x1="7" y1="12" x2="13" y2="12"></line>';
case 'circle': return '<circle cx="12" cy="12" r="9"></circle>';
case 'badge': return '<rect x="5" y="8" width="14" height="8" rx="4" ry="4"></rect>';
default: return '<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>';
}
}
function setupFeasibilityList() {
const container = document.getElementById('feasibilityList');
container.innerHTML = '';
CONFIG.checks.forEach(check => {
const div = document.createElement('div');
div.className = 'feasibility-item';
div.innerHTML = `
<div class="feasibility-dot ${check.status}"></div>
<span>${check.label}</span>
`;
container.appendChild(div);
});
}
// ============ Feasibility Analysis ============
function updateFeasibility() {
const strokes = state.strokeCount;
const components = state.componentCount;
// Complexity based on stroke count
let complexity = 'Low';
let complexityWidth = 25;
let complexityColor = 'green';
if (strokes > 50) {
complexity = 'High';
complexityWidth = 85;
complexityColor = 'red';
} else if (strokes > 20) {
complexity = 'Medium';
complexityWidth = 55;
complexityColor = 'yellow';
}
const complexityValue = document.getElementById('complexityValue');
const complexityBar = document.getElementById('complexityBar');
complexityValue.textContent = complexity;
complexityBar.style.width = complexityWidth + '%';
complexityBar.className = 'metric-fill ' + complexityColor;
// Update color based on complexity
const colors = { green: '#00d4aa', yellow: '#a8cc00', red: '#ff6b4a' };
complexityValue.style.color = colors[complexityColor];
// Accessibility score (simulated)
const a11yScore = Math.min(95, 60 + Math.random() * 35);
document.getElementById('a11yValue').textContent = Math.round(a11yScore) + '%';
document.getElementById('a11yBar').style.width = a11yScore + '%';
document.getElementById('a11yBar').className = 'metric-fill ' + (a11yScore > 80 ? 'green' : 'yellow');
document.getElementById('a11yValue').style.color = a11yScore > 80 ? '#00d4aa' : '#a8cc00';
// Component coverage
document.getElementById('coverageValue').textContent = components;
document.getElementById('coverageBar').style.width = Math.min(100, components * 8) + '%';
// Update suggestions
updateSuggestions();
}
function updateSuggestions() {
const suggestions = [];
if (state.strokeCount > 30) {
suggestions.push('Consider simplifying the design for better clarity');
}
if (state.componentCount < 3) {
suggestions.push('Add more UI components to complete the flow');
}
if (state.currentColor === '#ff6b4a') {
suggestions.push('Accent color works well for call-to-action elements');
}
suggestions.push('Grid alignment looks good');
suggestions.push('Consider adding hover states for interactive elements');
const container = document.getElementById('suggestionsList');
container.innerHTML = suggestions.slice(0, 3).map(s =>
`<div class="suggestion-item">${s}</div>`
).join('');
}
// ============ Collaborator Simulation ============
function simulateCollaborators() {
const cursor2 = document.getElementById('cursor2');
const cursor3 = document.getElementById('cursor3');
let pos2 = { x: 200, y: 200 };
let pos3 = { x: 400, y: 300 };
let vel2 = { x: 2, y: 1.5 };
let vel3 = { x: -1.5, y: 2 };
function updateCursors() {
// Update positions with smooth movement
pos2.x += vel2.x + Math.sin(Date.now() / 1000) * 2;
pos2.y += vel2.y + Math.cos(Date.now() / 800) * 2;
pos3.x += vel3.x + Math.cos(Date.now() / 1200) * 2;
pos3.y += vel3.y + Math.sin(Date.now() / 900) * 2;
// Bounce off edges
const canvasRect = canvas.getBoundingClientRect();
const maxX = canvasRect.width - 50;
const maxY = canvasRect.height - 50;
if (pos2.x < 50 || pos2.x > maxX) vel2.x *= -1;
if (pos2.y < 50 || pos2.y > maxY) vel2.y *= -1;
if (pos3.x < 50 || pos3.x > maxX) vel3.x *= -1;
if (pos3.y < 50 || pos3.y > maxY) vel3.y *= -1;
pos2.x = Math.max(50, Math.min(maxX, pos2.x));
pos2.y = Math.max(50, Math.min(maxY, pos2.y));
pos3.x = Math.max(50, Math.min(maxX, pos3.x));
pos3.y = Math.max(50, Math.min(maxY, pos3.y));
cursor2.style.left = pos2.x + 'px';
cursor2.style.top = pos2.y + 'px';
cursor3.style.left = pos3.x + 'px';
cursor3.style.top = pos3.y + 'px';
requestAnimationFrame(updateCursors);
}
updateCursors();
}
// ============ Timer & Phases ============
function updateTimer() {
const minutes = Math.floor(state.timeRemaining / 60);
const seconds = state.timeRemaining % 60;
document.querySelector('.timer').textContent =
`${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
if (state.timeRemaining > 0) {
state.timeRemaining--;
setTimeout(updateTimer, 1000);
} else {
advancePhase();
}
}
function advancePhase() {
const phases = ['diverge', 'converge', 'refine'];
const currentIndex = phases.indexOf(state.phase);
const nextIndex = (currentIndex + 1) % phases.length;
state.phase = phases[nextIndex];
state.timeRemaining = 300;
document.querySelectorAll('.phase').forEach(el => {
el.classList.toggle('active', el.dataset.phase === state.phase);
});
updateTimer();
}
// ============ Event Listeners ============
function setupEventListeners() {
canvas.addEventListener('mousedown', startDrawing);
canvas.addEventListener('mousemove', draw);
canvas.addEventListener('mouseup', stopDrawing);
canvas.addEventListener('mouseleave', () => {
brushPreview.style.display = 'none';
if (state.isDrawing) stopDrawing({ clientX: state.lastX, clientY: state.lastY });
});
// Tools
document.querySelectorAll('.tool-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.tool-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
state.currentTool = btn.dataset.tool;
});
});
// Brush size
const brushSlider = document.getElementById('brushSize');
brushSlider.addEventListener('input', (e) => {
state.brushSize = parseInt(e.target.value);
document.getElementById('sizeValue').textContent = state.brushSize + 'px';
});
// Stroke style
document.querySelectorAll('[data-style]').forEach(el => {
el.addEventListener('click', () => {
document.querySelectorAll('[data-style]').forEach(e => e.classList.remove('selected'));
el.classList.add('selected');
state.strokeStyle = el.dataset.style;
});
});
// Phase selection
document.querySelectorAll('.phase').forEach(el => {
el.addEventListener('click', () => {
state.phase = el.dataset.phase;
state.timeRemaining = 300;
document.querySelectorAll('.phase').forEach(e => e.classList.remove('active'));
el.classList.add('active');
});
});
// Action buttons
document.getElementById('undoBtn').addEventListener('click', () => {
if (state.history.length > 0) {
state.history.pop();
state.strokeCount = Math.max(0, state.strokeCount - 1);
redrawCanvas();
updateFeasibility();
}
});
document.getElementById('clearBtn').addEventListener('click', () => {
state.history = [];
state.strokeCount = 0;
state.componentCount = 0;
redrawCanvas();
updateFeasibility();
});
document.getElementById('exportBtn').addEventListener('click', () => {
const link = document.createElement('a');
link.download = `ritual-sketch-${Date.now()}.png`;
link.href = canvas.toDataURL();
link.click();
});
// Window resize
window.addEventListener('resize', resizeCanvas);
}
// ============ Initialize ============
function init() {
resizeCanvas();
setupColorGrid();
setupSpacingTokens();
setupComponents();
setupFeasibilityList();
setupEventListeners();
simulateCollaborators();
updateTimer();
updateFeasibility();
}
init();
</script>
</body>
</html>
Key Features Implemented
1. Shared Canvas System
- Multi-tool drawing (brush, eraser, line, rectangle, circle)
- Stroke history with undo capability
- Real-time brush preview cursor
- Simulated collaborator cursors with smooth movement
2. Design Tokens Panel
- Color Palette: 12 curated colors with selection feedback
- Spacing Scale: Click to set brush size
- Components: Draggable UI component templates
- Stroke Styles: Solid, dashed, dotted options
3. Real-time Feasibility Feedback
- Implementation Complexity: Based on stroke count
- Accessibility Score: Dynamic scoring with visual indicators
- Component Coverage: Tracks shape usage
- Design Checks: Pass/warn/fail status indicators
- AI Suggestions: Context-aware recommendations
4. Ritual Phases
- Diverge: Generate ideas freely (5 min)
- Converge: Focus on best concepts (5 min)
- Refine: Polish selected design (5 min)
- Timer with automatic phase advancement
5. Dynamic Elements
- Animated collaborator cursors
- Pulsing active states
- Smooth metric bar transitions
- Grid background for alignment
- Glowing selection effects