Changes to collabcanvas.scroll.pub

root
root
4 days ago
Initial commit
index.scroll
Changed around line 1
+ buildHtml
+ baseUrl https://collabcanvas.scroll.pub
+ metaTags
+ editButton /edit.html
+ title Collaborative Canvas
+ style.css
+
+ header
+ class hero
+ nav
+ div CollabCanvas
+ class logo
+ div
+ class nav-links
+ a Home
+ href #
+ a Edit
+ href edit.html
+ div
+ class hero-content
+ h1 Collaborative Canvas
+ p A simple, real-time collaborative canvas for teams
+ main
+ section
+ id canvas-section
+ class canvas-container
+ h2 Shared Canvas
+ div
+ class canvas-wrapper
+ canvas
+ id main-canvas
+ div
+ class upload-controls
+ input
+ type file
+ id image-upload
+ accept image/*
+ button
+ id clear-canvas
+ Clear Canvas
+ footer
+ div
+ class footer-content
+ p A simple collaborative tool built with HTML, CSS, and JavaScript
+ script.js
prompt.json
Changed around line 1
+ {
+ "id": "e1550254-7660-4efa-b038-44f165de6437",
+ "object": "chat.completion",
+ "created": 1737909892,
+ "model": "deepseek-chat",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "---domain---\ncollabcanvas.scroll.pub\n---index.scroll---\nbuildHtml\nbaseUrl https://collabcanvas.scroll.pub\nmetaTags\neditButton /edit.html\ntitle Collaborative Canvas\nstyle.css\n\nheader\n class hero\n nav\n div CollabCanvas\n class logo\n div\n class nav-links\n a Home\n href #\n a Edit\n href edit.html\n div\n class hero-content\n h1 Collaborative Canvas\n p A simple, real-time collaborative canvas for teams\nmain\n section\n id canvas-section\n class canvas-container\n h2 Shared Canvas\n div\n class canvas-wrapper\n canvas\n id main-canvas\n div\n class upload-controls\n input\n type file\n id image-upload\n accept image/*\n button\n id clear-canvas\n Clear Canvas\nfooter\n div\n class footer-content\n p A simple collaborative tool built with HTML, CSS, and JavaScript\nscript.js\n---style.css---\n:root {\n --primary-color: #2563eb;\n --secondary-color: #1e40af;\n --background-color: #f8fafc;\n --text-color: #1e293b;\n --canvas-bg: #ffffff;\n}\n\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: -apple-system, BlinkMacSystemFont, sans-serif;\n line-height: 1.6;\n color: var(--text-color);\n background-color: var(--background-color);\n}\n\n.hero {\n background: var(--primary-color);\n color: white;\n padding: 2rem 1rem;\n text-align: center;\n}\n\n.nav-links {\n display: flex;\n justify-content: center;\n gap: 1rem;\n margin-top: 1rem;\n}\n\n.nav-links a {\n color: white;\n text-decoration: none;\n padding: 0.5rem 1rem;\n border-radius: 0.25rem;\n transition: background-color 0.2s;\n}\n\n.nav-links a:hover {\n background-color: var(--secondary-color);\n}\n\n.canvas-container {\n max-width: 1200px;\n margin: 2rem auto;\n padding: 0 1rem;\n}\n\n.canvas-wrapper {\n position: relative;\n width: 100%;\n height: 600px;\n background-color: var(--canvas-bg);\n border: 2px solid var(--primary-color);\n border-radius: 0.5rem;\n overflow: hidden;\n}\n\n#main-canvas {\n width: 100%;\n height: 100%;\n cursor: crosshair;\n}\n\n.upload-controls {\n margin-top: 1rem;\n display: flex;\n gap: 1rem;\n justify-content: center;\n}\n\nbutton {\n background-color: var(--primary-color);\n color: white;\n border: none;\n padding: 0.5rem 1rem;\n border-radius: 0.25rem;\n cursor: pointer;\n transition: background-color 0.2s;\n}\n\nbutton:hover {\n background-color: var(--secondary-color);\n}\n\nfooter {\n text-align: center;\n padding: 2rem 1rem;\n margin-top: 2rem;\n border-top: 1px solid #e2e8f0;\n}\n\n@media (max-width: 768px) {\n .canvas-wrapper {\n height: 400px;\n }\n \n .hero-content h1 {\n font-size: 1.5rem;\n }\n}\n---script.js---\nconst canvas = document.getElementById('main-canvas');\nconst ctx = canvas.getContext('2d');\nconst imageUpload = document.getElementById('image-upload');\nconst clearButton = document.getElementById('clear-canvas');\n\nlet images = [];\nlet currentUser = Math.random().toString(36).substring(7);\n\n// Set canvas dimensions\ncanvas.width = canvas.offsetWidth;\ncanvas.height = canvas.offsetHeight;\n\n// Handle image upload\nimageUpload.addEventListener('change', (e) => {\n const file = e.target.files[0];\n if (file) {\n const reader = new FileReader();\n reader.onload = (event) => {\n const img = new Image();\n img.src = event.target.result;\n img.onload = () => {\n const imageData = {\n img: img,\n x: 100,\n y: 100,\n width: 200,\n height: 200,\n user: currentUser\n };\n images.push(imageData);\n drawCanvas();\n };\n };\n reader.readAsDataURL(file);\n }\n});\n\n// Clear canvas\nclearButton.addEventListener('click', () => {\n images = [];\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n});\n\n// Draw all elements on canvas\nfunction drawCanvas() {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n images.forEach(image => {\n ctx.drawImage(image.img, image.x, image.y, image.width, image.height);\n });\n}\n\n// Handle mouse events for moving images\nlet selectedImage = null;\nlet offset = {x: 0, y: 0};\n\ncanvas.addEventListener('mousedown', (e) => {\n const rect = canvas.getBoundingClientRect();\n const mouseX = e.clientX - rect.left;\n const mouseY = e.clientY - rect.top;\n \n // Find clicked image\n for (let i = images.length - 1; i >= 0; i--) {\n const img = images[i];\n if (mouseX > img.x && mouseX < img.x + img.width &&\n mouseY > img.y && mouseY < img.y + img.height &&\n img.user === currentUser) {\n selectedImage = img;\n offset.x = mouseX - img.x;\n offset.y = mouseY - img.y;\n break;\n }\n }\n});\n\ncanvas.addEventListener('mousemove', (e) => {\n if (selectedImage) {\n const rect = canvas.getBoundingClientRect();\n selectedImage.x = e.clientX - rect.left - offset.x;\n selectedImage.y = e.clientY - rect.top - offset.y;\n drawCanvas();\n }\n});\n\ncanvas.addEventListener('mouseup', () => {\n selectedImage = null;\n});\n\ncanvas.addEventListener('mouseleave', () => {\n selectedImage = null;\n});\n\n// Simple WebSocket implementation for real-time updates\nconst ws = new WebSocket('wss://collabcanvas.scroll.pub/ws');\n\nws.onmessage = (event) => {\n const data = JSON.parse(event.data);\n if (data.type === 'update') {\n images = data.images;\n drawCanvas();\n }\n};\n\nsetInterval(() => {\n if (images.length > 0) {\n ws.send(JSON.stringify({\n type: 'update',\n images: images\n }));\n }\n}, 1000);\n\n// Clean up images when user leaves\nwindow.addEventListener('beforeunload', () => {\n images = images.filter(img => img.user !== currentUser);\n ws.send(JSON.stringify({\n type: 'update',\n images: images\n }));\n});\n---end---"
+ },
+ "logprobs": null,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 773,
+ "completion_tokens": 1560,
+ "total_tokens": 2333,
+ "prompt_tokens_details": {
+ "cached_tokens": 0
+ },
+ "prompt_cache_hit_tokens": 0,
+ "prompt_cache_miss_tokens": 773
+ },
+ "system_fingerprint": "fp_3a5770e1b4"
+ }
readme.scroll
Changed around line 1
+ # collabcanvas.scroll.pub
+
+ Prompt: website
+ Agent: deepseek
+ Model: deepseek-chat
+
+ ## User prompt
+ 一个可以多人协同编辑的画布,可以用canvas,上传图片,图片的容器可以控制大小,但是只能由上传者移动和编辑,上传者关闭页面后容器就会自动消失。其他用户在编辑容器的时候可以实时看到效果。能不能最简单的纯html js实现?
+
+ ## System prompt
+ You are an expert web developer. Create a website based on this request: "一个可以多人协同编辑的画布,可以用canvas,上传图片,图片的容器可以控制大小,但是只能由上传者移动和编辑,上传者关闭页面后容器就会自动消失。其他用户在编辑容器的时候可以实时看到效果。能不能最简单的纯html js实现?"
+
+ Requirements:
+ - Use only Scroll, CSS, and JavaScript (NO frameworks, NO external dependencies)
+ - Create clean, semantic HTML5
+ - Make it mobile-responsive
+ - Follow modern best practices and accessibility guidelines
+ - Keep it simple but professional
+ - Use only relative links and no external resources
+ - Do not put a copyright symbol or all rights reserved in the footer.
+ - Make it beautiful. Dazzling. Advanced used of CSS.
+
+ As a refresher, for doing the html body, Scroll is a whitespace based language that uses a single indented space to mark a line (aka particle) as a subparticle of a parent line.
+
+ For example:
+
+ header
+ class hero
+ nav
+ div Scroll
+ class logo
+ div
+ class nav-links
+ a Features
+ href #features
+ a Examples
+ href #examples
+ a Edit
+ href edit.html
+ a GitHub
+ class cta-button
+ href https://github.com/breck7/scroll
+ div
+ class hero-content
+ h1 Write Better with Scroll
+ p The extendible markup language that makes source beautiful and compiles to anything
+ a Get Started
+ class primary-button
+ href https://hub.scroll.pub/
+ main
+ section
+ id features
+ class features
+ h2 Why Scroll?
+ div
+ class feature-grid
+ div
+ class feature-card
+ div ⚡
+ class feature-icon
+ h3 Simple Syntax
+ p Like Markdown, but more powerful. No parentheses needed.
+ div
+ class feature-card
+ div 🧩
+ class feature-icon
+ h3 Extendible
+ p Build your own custom parsers.
+ div
+ class feature-card
+ div 🎨
+ class feature-icon
+ h3 Beautiful Output
+ p Create stunning documents with minimal effort.
+ div
+ class feature-card
+ div 🚀
+ class feature-icon
+ h3 Fast & Light
+ p Built on the efficient PPS Stack.
+ section
+ id examples
+ class code-demo
+ h2 See It In Action
+ div
+ class code-container
+ pre
+ class code-example
+ div
+ class code-output
+ footer
+ div
+ class footer-content
+ div
+ class footer-links
+ a Documentation
+ href https://scroll.pub/tutorial.html
+ a Community
+ href https://www.reddit.com/r/WorldWideScroll/
+ a Blog
+ href https://scroll.pub/blog
+ p Started by Breck Yunits. Evolved by a community.
+ https://twitter.com/breckyunits Breck Yunits
+ https://github.com/breck7/scroll/graphs/contributors community
+
+
+ First suggest a short, memorable domain name ending in scroll.pub that represents this website. Then provide the website files. Use this exact format:
+
+ ---domain---
+ (domainscroll.pub here)
+ ---index.scroll---
+ buildHtml
+ baseUrl https://(domainscroll.pub here)
+ metaTags
+ editButton /edit.html
+ title (Title here)
+ style.css
+
+ (body content here. no blank lines please.)
+
+ script.js
+ ---style.css---
+ (CSS content here)
+ ---script.js---
+ (JavaScript content here)
+ ---end---
script.js
Changed around line 1
+ const canvas = document.getElementById('main-canvas');
+ const ctx = canvas.getContext('2d');
+ const imageUpload = document.getElementById('image-upload');
+ const clearButton = document.getElementById('clear-canvas');
+
+ let images = [];
+ let currentUser = Math.random().toString(36).substring(7);
+
+ // Set canvas dimensions
+ canvas.width = canvas.offsetWidth;
+ canvas.height = canvas.offsetHeight;
+
+ // Handle image upload
+ imageUpload.addEventListener('change', (e) => {
+ const file = e.target.files[0];
+ if (file) {
+ const reader = new FileReader();
+ reader.onload = (event) => {
+ const img = new Image();
+ img.src = event.target.result;
+ img.onload = () => {
+ const imageData = {
+ img: img,
+ x: 100,
+ y: 100,
+ width: 200,
+ height: 200,
+ user: currentUser
+ };
+ images.push(imageData);
+ drawCanvas();
+ };
+ };
+ reader.readAsDataURL(file);
+ }
+ });
+
+ // Clear canvas
+ clearButton.addEventListener('click', () => {
+ images = [];
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ });
+
+ // Draw all elements on canvas
+ function drawCanvas() {
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ images.forEach(image => {
+ ctx.drawImage(image.img, image.x, image.y, image.width, image.height);
+ });
+ }
+
+ // Handle mouse events for moving images
+ let selectedImage = null;
+ let offset = {x: 0, y: 0};
+
+ canvas.addEventListener('mousedown', (e) => {
+ const rect = canvas.getBoundingClientRect();
+ const mouseX = e.clientX - rect.left;
+ const mouseY = e.clientY - rect.top;
+
+ // Find clicked image
+ for (let i = images.length - 1; i >= 0; i--) {
+ const img = images[i];
+ if (mouseX > img.x && mouseX < img.x + img.width &&
+ mouseY > img.y && mouseY < img.y + img.height &&
+ img.user === currentUser) {
+ selectedImage = img;
+ offset.x = mouseX - img.x;
+ offset.y = mouseY - img.y;
+ break;
+ }
+ }
+ });
+
+ canvas.addEventListener('mousemove', (e) => {
+ if (selectedImage) {
+ const rect = canvas.getBoundingClientRect();
+ selectedImage.x = e.clientX - rect.left - offset.x;
+ selectedImage.y = e.clientY - rect.top - offset.y;
+ drawCanvas();
+ }
+ });
+
+ canvas.addEventListener('mouseup', () => {
+ selectedImage = null;
+ });
+
+ canvas.addEventListener('mouseleave', () => {
+ selectedImage = null;
+ });
+
+ // Simple WebSocket implementation for real-time updates
+ const ws = new WebSocket('wss://collabcanvas.scroll.pub/ws');
+
+ ws.onmessage = (event) => {
+ const data = JSON.parse(event.data);
+ if (data.type === 'update') {
+ images = data.images;
+ drawCanvas();
+ }
+ };
+
+ setInterval(() => {
+ if (images.length > 0) {
+ ws.send(JSON.stringify({
+ type: 'update',
+ images: images
+ }));
+ }
+ }, 1000);
+
+ // Clean up images when user leaves
+ window.addEventListener('beforeunload', () => {
+ images = images.filter(img => img.user !== currentUser);
+ ws.send(JSON.stringify({
+ type: 'update',
+ images: images
+ }));
+ });
style.css
Changed around line 1
+ :root {
+ --primary-color: #2563eb;
+ --secondary-color: #1e40af;
+ --background-color: #f8fafc;
+ --text-color: #1e293b;
+ --canvas-bg: #ffffff;
+ }
+
+ * {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ }
+
+ body {
+ font-family: -apple-system, BlinkMacSystemFont, sans-serif;
+ line-height: 1.6;
+ color: var(--text-color);
+ background-color: var(--background-color);
+ }
+
+ .hero {
+ background: var(--primary-color);
+ color: white;
+ padding: 2rem 1rem;
+ text-align: center;
+ }
+
+ .nav-links {
+ display: flex;
+ justify-content: center;
+ gap: 1rem;
+ margin-top: 1rem;
+ }
+
+ .nav-links a {
+ color: white;
+ text-decoration: none;
+ padding: 0.5rem 1rem;
+ border-radius: 0.25rem;
+ transition: background-color 0.2s;
+ }
+
+ .nav-links a:hover {
+ background-color: var(--secondary-color);
+ }
+
+ .canvas-container {
+ max-width: 1200px;
+ margin: 2rem auto;
+ padding: 0 1rem;
+ }
+
+ .canvas-wrapper {
+ position: relative;
+ width: 100%;
+ height: 600px;
+ background-color: var(--canvas-bg);
+ border: 2px solid var(--primary-color);
+ border-radius: 0.5rem;
+ overflow: hidden;
+ }
+
+ #main-canvas {
+ width: 100%;
+ height: 100%;
+ cursor: crosshair;
+ }
+
+ .upload-controls {
+ margin-top: 1rem;
+ display: flex;
+ gap: 1rem;
+ justify-content: center;
+ }
+
+ button {
+ background-color: var(--primary-color);
+ color: white;
+ border: none;
+ padding: 0.5rem 1rem;
+ border-radius: 0.25rem;
+ cursor: pointer;
+ transition: background-color 0.2s;
+ }
+
+ button:hover {
+ background-color: var(--secondary-color);
+ }
+
+ footer {
+ text-align: center;
+ padding: 2rem 1rem;
+ margin-top: 2rem;
+ border-top: 1px solid #e2e8f0;
+ }
+
+ @media (max-width: 768px) {
+ .canvas-wrapper {
+ height: 400px;
+ }
+
+ .hero-content h1 {
+ font-size: 1.5rem;
+ }
+ }