8000 T1.2: Canvas Worksheet Rendering Engine Development · Issue #3 · yjyang1990/zitie_mini · GitHub
[go: up one dir, main page]

Skip to content

T1.2: Canvas Worksheet Rendering Engine Development #3

Open

Description

@yjyang1990

Sprint 1: Project Setup & Core Infrastructure (Week 1-2)

Epic Task: T1.2 - Canvas worksheet rendering engine development

📋 Task Description

Develop the core Canvas 2D API integration and worksheet rendering system that forms the foundation of the calligraphy worksheet generator.

🎯 Goals

  • Implement Canvas 2D API integration for high-quality worksheet rendering
  • Create flexible grid rendering system supporting multiple Chinese calligraphy formats
  • Develop text placement and alignment algorithms for precise character positioning
  • Build font loading and rendering system for multiple calligraphy styles

📝 Detailed Requirements

Canvas Integration

  • Initialize Canvas 2D context with optimal settings for text rendering
  • Configure Canvas dimensions for A4 paper format (210×297mm at 300DPI)
  • Implement high-resolution rendering for print quality (300DPI+)
  • Set up Canvas coordinate system and scaling functions
  • Add Canvas export functionality (toDataURL for images)

Grid Rendering System

  • 田字格 (Tian Zi Ge): Traditional 4-section practice grid
    • Draw horizontal and vertical center lines
    • Support configurable cell sizes (10-30mm)
    • Implement proper stroke width and opacity
  • 米字格 (Mi Zi Ge): 8-section diagonal practice grid
    • Add diagonal guide lines crossing at center
    • Maintain proper proportions and spacing
  • 九宫格 (Jiu Gong Ge): 9-section advanced practice grid
    • Create 3×3 internal grid structure
    • Support fine-grained character positioning
  • 空白格 (Kong Bai Ge): Clean grid without guides
    • Simple border-only cells for advanced practice
    • Minimal visual interference

Text Placement & Alignment

  • Character positioning algorithms:
    • Center alignment within grid cells
    • Baseline calculation for consistent text positioning
    • Support for different character sizes and weights
  • Multi-line text flow management
  • Character spacing and line height calculations
  • Support for mixed content (Chinese characters + pinyin)

Font Loading & Rendering

  • Font loading system for multiple calligraphy styles:
    • 庞中华行书 (Pang Zhonghua Xingshu)
    • 楷体 (Kai Ti - Regular script)
    • 宋体 (Song Ti - Song typeface)
    • 仿宋 (Fang Song - Imitation Song)
    • 黑体 (Hei Ti - Gothic)
  • Font caching and optimization
  • Font fallback system for missing characters
  • Dynamic font size calculation based on grid dimensions

✅ Definition of Done

  • Canvas can render basic worksheets with all 4 grid types
  • Text renders clearly at 300DPI resolution suitable for printing
  • Font loading works reliably across different WeChat environments
  • Grid dimensions are configurable and scale properly
  • Character positioning is precise and visually balanced
  • Performance: Renders a full A4 page in <3 seconds
  • Export functionality produces high-quality images

🔗 Dependencies

  • Task T1.1: Project initialization must be completed
  • Font licensing agreements and font file access
  • Canvas API limitations research and testing

📊 Acceptance Criteria

  1. Rendering Quality: 300DPI output suitable for professional printing
  2. Grid Accuracy: All 4 grid types render with correct proportions
  3. Font Support: Minimum 3 calligraphy fonts working correctly
  4. Performance: <3 second render time for full worksheet
  5. Compatibility: Works across iOS/Android WeChat clients
  6. Precision: Character positioning within 1px accuracy

🧪 Testing Requirements

  • Visual regression testing for all grid types
  • Font rendering consistency across devices
  • Performance testing with large character sets
  • Export quality verification at multiple resolutions
  • Memory usage optimization testing

📁 Deliverables

  • Complete Canvas rendering engine module
  • Grid rendering system supporting 4 grid types
  • Font loading and caching system
  • Text positioning algorithms
  • Export functionality for images
  • Performance optimization implementations

Related to Epic: #1 - Chinese Calligraphy Worksheet Generator WeChat Mini Program
Sprint: 1 (Week 1-2)
Story Points: 8
Assignee: Frontend Developer

Activity

  1. self-assigned this
    on Sep 13, 2025
  2. added
    wechat-miniprogram
    frontend
    canvas
    on Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

canvasfrontendwechat-miniprogram

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0