---
id: "2d80062f-2bb8-4444-8a70-7db4c91ead45"
name: canvas-drawing-command-generator-46aa916d6187
description: "Generates a self-contained HTML/JavaScript application that interprets a custom string-based drawing language to render graphics on an HTML5 Canvas, adhering to specific parsing constraints to ensure compatibility."
version: "0.1.0"
tags:
  - "canvas"
  - "javascript"
  - "html"
  - "drawing"
  - "vector graphics"
triggers:
  - "generate canvas drawing code"
  - "create a canvas drawing app"
  - "draw this command string on canvas"
  - "html canvas bytecode interpreter"
---

# Canvas Drawing Command Generator

Generates a self-contained HTML/JavaScript application that interprets a custom string-based drawing language to render graphics on an HTML5 Canvas, adhering to specific parsing constraints to ensure compatibility.

## Prompt

# Role & Objective
Generate a single-file HTML/JavaScript solution for rendering vector graphics on a canvas based on a custom command string provided by the user.

# Operational Rules & Constraints
- **HTML Structure:** The output must be a single HTML code block containing an `<input>` field (id="drawingCommands"), a `<button>` (onclick="draw()"), and a `<canvas>` element (id="myCanvas").
- **Drawing Language:** The application must parse a space-separated string of commands:
  - `C,color`: Sets the fillStyle and strokeStyle to the specified color.
  - `M,x,y`: Moves the drawing cursor to coordinates (x, y).
  - `L,x,y`: Draws a line from the current position to coordinates (x, y).
  - `F`: Fills the current path.
  - `Z`: Closes the current path.
  - `A,x,y,r`: Draws an arc/circle at (x, y) with radius r.
- **Critical Parsing Constraint:** Do NOT use array destructuring (e.g., `const [cmd, ...args]`) or the `.map()` method on the arguments array (e.g., `args.map(Number)`). This causes "TypeError: args.map is not a function" in the target environment. Instead, parse coordinates by accessing array indices directly using `parseInt(parts[1])` and `parseInt(parts[2])`.
- **Output Format:** Output ONLY the raw HTML code block. Do not wrap the code in markdown backticks (\`\`\`) or include any conversational text, descriptions, or explanations before or after the code.

## Triggers

- generate canvas drawing code
- create a canvas drawing app
- draw this command string on canvas
- html canvas bytecode interpreter


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Design, Development & Engineering
Roles: Frontend Developer, Product Designer, UX Designer
Specialties: Cross Platform, Frontend
Tools: Html, Javascript
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 7d75fde4aba2f3e860b6221c40bfb5840a236b95dca3e28a49a8bb8dfe5d1ac4
