xiaoiver / infinite-canvas-tutorial

A tutorial on infinite canvas
https://infinitecanvas.cc
97 stars 6 forks source link
infinite-canvas rendering-2d-graphics rendering-engine visualization webgl webgpu

An Infinite Canvas Tutorial

Build Status Coverage Status

What is an Infinite Canvas? The term "infinite" in infinitecanvas is described as follows:

The infinitecanvas showcases numerous examples ranging from design tools to creative boards, including some well-known products such as: Figma, Modyfi, Motiff, rnote, tldraw, excalidraw and so on.

As a front-end developer, I am very interested in the rendering technologies involved. Although tldraw, excalidraw, and others generally use more user-friendly technologies like Canvas2D/SVG, there are also many editors and design tools in the JS and Rust ecosystems that use more low-level rendering technologies for 2D graphics with GPU acceleration to achieve better performance and experience:

Therefore, in this tutorial, I hope to implement the following features:

I hope to rewrite the rendering part of the canvas with Rust in the future, but the current project completion is still relatively low:

Let's get started!

Getting Started

The course project uses pnpm workspace, so you need to install pnpm first.

pnpm i

After entering the course directory, run Vite devserver:

cd packages/lesson_001
pnpm run dev

Lesson 1 - Initialize canvas πŸ”—

Lesson 2 - Draw a circle πŸ”—

Lesson 3 - Scene graph and transform πŸ”—

Lesson 3

Lesson 4 - Camera πŸ”—

Lesson 5 - Grid πŸ”—

Lesson 5

Lesson 6 - Event system πŸ”—

Lesson 7 - Web UI πŸ”—

Lesson 8 - Optimize performance πŸ”—

Lesson 8

Lesson 9 - Draw ellipse and rectangle πŸ”—

Lesson 9 - drop shadow Lesson 9 - inner shadow

Lesson 10 - Import and export images πŸ”—

Lesson 10 - import and export images

Lesson 11 - Test and server-side rendering πŸ”—

Lesson 12 - Draw polyline πŸ”—

Lesson 12 - polyline

Lesson 13 - Draw path and hand-drawn shapes πŸ”—

Lesson 13 - path

Lesson 14 - Canvas mode πŸ”—