npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

codraw

v1.0.0

Published

Advanced Drawing & Code Generation Library - Draw shapes, symbols, and generate code in multiple programming languages

Readme

🎨 Codraw v1.0.0

Advanced Drawing & Code Generation Library

Version License Downloads Build Status

Codraw is a powerful JavaScript library that allows you to draw shapes, symbols, and generate code in multiple programming languages. Perfect for developers, designers, and educators who want to create visual content and convert it to code.

Codraw Demo

📖 Table of Contents

  1. Features
  2. Installation
  3. Quick Start
  4. API Reference
  5. Examples
  6. Advanced Features
  7. Troubleshooting
  8. Contributing

✨ Features

🎨 Advanced Drawing Capabilities

  • Multiple Drawing Modes: Shapes, Symbols, Freehand drawing
  • Rich Shape Library: Triangle, Square, Circle, Line, Polygon
  • Symbol Support: Stars, Emojis, Custom characters
  • Real-time Preview: Instant visual feedback
  • Customizable Styles: Colors, stroke width, opacity

💻 Code Generation

  • 10+ Programming Languages: JavaScript, Python, Java, C++, C#, PHP, Go, Rust, HTML, CSS
  • Clean Code Output: Well-formatted, commented code
  • Multiple Export Formats: Source code, images, HTML
  • Language-specific Optimizations: Tailored for each programming language

Developer Experience

  • Simple API: Easy to integrate and use
  • Touch Support: Mobile and tablet friendly
  • Keyboard Shortcuts: Ctrl+Z (undo), Ctrl+Y (redo), Ctrl+S (export)
  • History Management: Undo/Redo functionality
  • Responsive Design: Works on all screen sizes

🚀 Installation

Method 1: NPM (Recommended)

npm install codraw

Method 2: CDN

<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/codraw.css">

<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/codraw.js"></script>

Method 3: Download

Download the latest release from GitHub and include the files in your project.

🎯 Quick Start

Basic Setup

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Codraw App</title>
    <link rel="stylesheet" href="codraw.css">
</head>
<body>
    <canvas id="myCanvas" width="800" height="600"></canvas>
    <script src="codraw.js"></script>
    <script>
        // Initialize Codraw
        const codraw = new Codraw('myCanvas', {
            defaultColor: '#667eea',
            strokeWidth: 3,
            enableAnimations: true
        });
    </script>
</body>
</html>

Advanced Configuration

const codraw = new Codraw('canvasId', {
    defaultColor: '#FFD700',        // Default stroke color
    strokeWidth: 5,                 // Default stroke width
    fillOpacity: 0.3,               // Default fill opacity (0-1)
    enableAnimations: true,         // Enable smooth animations
    enableSnapToGrid: true,         // Enable grid snapping
    gridSize: 20                    // Grid size in pixels
});

📚 API Reference

Constructor

new Codraw(canvasId, options)

Parameters:

  • canvasId (string): ID of the canvas element
  • options (object): Configuration options

Methods

Drawing Methods

// Clear the canvas
codraw.clearCanvas()

// Add a shape programmatically
codraw.addShape({
    type: 'circle',
    startX: 100,
    startY: 100,
    endX: 200,
    endY: 200,
    color: '#FF6B6B',
    strokeWidth: 3
})

// Add a symbol
codraw.addSymbol({
    text: '⭐',
    x: 150,
    y: 150,
    color: '#FFD700',
    size: 32
})

// Redraw all elements
codraw.redrawAll()

History Management

// Undo last action
codraw.undo()

// Redo last action
codraw.redo()

Export Methods

// Export canvas as image
codraw.exportAsImage()

// Generate code for selected language
codraw.generateCode()

Shape Types

  • triangle - Triangle shape
  • square - Rectangle/square
  • circle - Circle/ellipse
  • line - Straight line
  • polygon - Regular polygon

Supported Languages

| Language | File Extension | Status | |----------|----------------|--------| | JavaScript | .js | ✅ Complete | | Python | .py | ✅ Complete | | Java | .java | ✅ Complete | | C++ | .cpp | ✅ Complete | | C# | .cs | ✅ Complete | | PHP | .php | ✅ Complete | | Go | .go | ✅ Complete | | Rust | .rs | ✅ Complete | | HTML | .html | ✅ Complete | | CSS | .css | ✅ Complete |

💡 Examples

Example 1: Basic Drawing

// Initialize Codraw
const codraw = new Codraw('canvas');

// Draw a circle
codraw.addShape({
    type: 'circle',
    startX: 100,
    startY: 100,
    endX: 200,
    endY: 200,
    color: '#FF6B6B',
    strokeWidth: 3
});

// Draw a triangle
codraw.addShape({
    type: 'triangle',
    startX: 300,
    startY: 100,
    endX: 400,
    endY: 200,
    color: '#4ECDC4',
    strokeWidth: 3
});

// Add a star symbol
codraw.addSymbol({
    text: '⭐',
    x: 250,
    y: 300,
    color: '#FFD700',
    size: 40
});

Example 2: Interactive Drawing

// Set up event listeners
document.getElementById('drawBtn').addEventListener('click', () => {
    codraw.drawingType = 'shapes';
    codraw.currentShape = 'circle';
});

document.getElementById('symbolBtn').addEventListener('click', () => {
    codraw.drawingType = 'symbols';
    codraw.currentSymbol = '⭐';
});

document.getElementById('generateBtn').addEventListener('click', () => {
    codraw.generateCode();
});

Example 3: Custom Styling

// Customize appearance
codraw.options.defaultColor = '#FF6B6B';
codraw.options.strokeWidth = 5;
codraw.options.fillOpacity = 0.5;

// Update canvas
codraw.ctx.strokeStyle = codraw.options.defaultColor;
codraw.ctx.lineWidth = codraw.options.strokeWidth;

🔧 Advanced Features

Custom Shapes

// Create custom shape
codraw.addShape({
    type: 'polygon',
    startX: 100,
    startY: 100,
    endX: 200,
    endY: 200,
    color: '#9B59B6',
    strokeWidth: 4
});

Animation Support

// Enable animations
const codraw = new Codraw('canvas', {
    enableAnimations: true
});

// Animate shapes
function animateShape(shape) {
    let angle = 0;
    const animate = () => {
        angle += 0.1;
        // Update shape position
        shape.x = 200 + Math.cos(angle) * 50;
        shape.y = 200 + Math.sin(angle) * 50;
        codraw.redrawAll();
        requestAnimationFrame(animate);
    };
    animate();
}

Touch Support

// Touch events are automatically handled
// No additional configuration needed
const codraw = new Codraw('canvas');
// Works on mobile devices out of the box

🎯 Use Cases

Educational Tools

  • Teach programming concepts visually
  • Create interactive coding tutorials
  • Generate code examples for students

Prototyping

  • Quick UI mockups
  • Visual design iterations
  • Rapid prototyping tools

Code Generation

  • Convert visual designs to code
  • Generate boilerplate code
  • Create code templates

Art & Design

  • Digital art creation
  • Logo design tools
  • Visual content generation

📱 Browser Support

| Browser | Version | |---------|---------| | Chrome | 60+ | | Firefox | 55+ | | Safari | 12+ | | Edge | 79+ | | Mobile Safari | 12+ | | Chrome Mobile | 60+ |

🐛 Troubleshooting

Common Issues

Canvas Not Found

// Make sure canvas element exists
const canvas = document.getElementById('canvasId');
if (!canvas) {
    console.error('Canvas element not found');
}

Drawing Not Working

// Check if Codraw is properly initialized
if (typeof codraw === 'undefined') {
    console.error('Codraw not initialized');
}

Code Generation Issues

// Ensure shapes/symbols exist before generating code
if (codraw.shapes.length === 0 && codraw.symbols.length === 0) {
    console.warn('No content to generate code from');
}

Browser Compatibility

| Browser | Version | Support | |---------|---------|---------| | Chrome | 60+ | ✅ Full | | Firefox | 55+ | ✅ Full | | Safari | 12+ | ✅ Full | | Edge | 79+ | ✅ Full | | Mobile Safari | 12+ | ✅ Full | | Chrome Mobile | 60+ | ✅ Full |

🔧 Development

Setup

git clone https://github.com/En-Hussain/codraw.git
cd codraw
npm install
npm run dev

Build

npm run build

Test

npm test

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone repository
git clone https://github.com/En-Hussain/codraw.git
cd codraw

# Install dependencies
npm install

# Start development server
npm run dev

# Run tests
npm test

# Build for production
npm run build

Code Style

  • Use ES6+ features
  • Follow JavaScript Standard Style
  • Add JSDoc comments for functions
  • Write tests for new features

📄 License

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

🙏 Acknowledgments

  • Thanks to all contributors who helped make this project possible
  • Inspired by the need for better visual-to-code tools
  • Built with modern web technologies

📞 Support