사용 방법
- 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
- 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
- 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/bintzgavin/helios --skill example-canvas시작 전 확인
- 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
- 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.
Vanilla Canvas Patterns
Use Helios directly with the HTML5 Canvas API. This provides the lowest overhead and highest performance.
Quick Start
1. HTML Setup
<!-- composition.html -->
<canvas id="canvas"></canvas>
<script type="module" src="./main.js"></script>2. Logic Setup
// main.js
import { Helios } from '@helios-project/core';
// Setup
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const width = 1920;
const height = 1080;
canvas.width = width;
canvas.height = height;
// Initialize Helios
const helios = new Helios({
duration: 5,
fps: 60
});
helios.bindToDocumentTimeline();
window.helios = helios;
// Draw Function
function draw(frame) {
// Clear
ctx.clearRect(0, 0, width, height);
// Calculate state
const time = frame / helios.fps;
const t = time / helios.duration; // 0..1
// Draw
const x = t * (width - 100);
ctx.fillStyle = 'tomato';
ctx.fillRect(x, height / 2 - 50, 100, 100);
}
// Subscribe
helios.subscribe((state) => {
draw(state.currentFrame);
});
// Initial Render
draw(0);Performance Tips
- Pre-calculate values: Do heavy math (like sine tables or physics simulations) upfront if possible.
- OffscreenCanvas: For very complex scenes, consider rendering in a Web Worker using
OffscreenCanvasto keep the main thread free. - Batch Draw Calls: Minimize context state changes (
fillStyle,strokeStyle, etc).
Source Files
- Example:
examples/simple-canvas-animation/