graphics-and-shapes

Draw primitives, paths, and shape game objects with the Phaser 4 Graphics API.

465|41|Updated Aug 4, 2026
One-click install
npx skills add https://github.com/autonomous-ai/openharness --skill graphics-and-shapes-autonomous-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: graphics-and-shapes
Source: https://github.com/autonomous-ai/openharness/tree/main/store/agents/phaser/skills/graphics-and-shapes
Command: npx skills add https://github.com/autonomous-ai/openharness --skill graphics-and-shapes-autonomous-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Drawing rectangles, circles, polygons, and custom paths in Phaser 4 requires choosing between the imperative Graphics object and standalone Shape game objects, each with different APIs, angle units, and component support. This Skill provides the correct patterns, method signatures, and gotchas so shapes render as intended on the first attempt. ## Core Features & Use Cases - Graphics Drawing: Covers fillStyle, lineStyle, gradients, paths, arcs, rounded rectangles, canvas transforms, and generateTexture for baking drawings into reusable textures. - Shape Game Objects: Documents all 12 shape factories (arc, circle, curve, ellipse, grid, isobox, isotriangle, line, polygon, rectangle, star, triangle) with fill, stroke, and shape-specific methods. - Use Case: When building a game HUD, use Shape objects for individual UI elements that need input and physics, and use Graphics with generateTexture for complex static drawings that would otherwise hurt frame rate. ## Quick Start Draw a filled green rectangle and a red-stroked circle in my Phaser 4 scene using the Graphics game object.

Frequently Asked Questions about graphics-and-shapes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I draw shapes in Phaser 4?

Use this.add.graphics() for imperative drawing with methods like fillRect, strokeCircle, and fillRoundedRect, or use Shape factories like this.add.rectangle() and this.add.circle() for standalone game objects. Set fillStyle or lineStyle before calling the corresponding draw method.

Phaser Graphics vs Shape objects: which should I use?

Use Graphics for dynamic drawing, complex paths, gradients, multiple shapes on one object, or generating textures. Use Shape objects for individual elements needing origin, bounds, input, physics, or tweening, since Shapes include Origin and GetBounds components that Graphics lacks.

Why is my Phaser arc drawing at the wrong angle?

The Graphics arc() method takes start and end angles in radians, while the this.add.arc() factory takes angles in degrees from 0 to 360. Mixing these units is the most common cause of incorrectly rotated arcs.

Can Phaser Shape objects use setTint like sprites?

No, Shape game objects do not support setTint() or tint properties. Change their appearance with setFillStyle(color, alpha) and setStrokeStyle(lineWidth, color, alpha), or set fillColor, strokeColor, and alpha properties directly.

Why are gradients missing from my Phaser generated texture?

generateTexture uses the Canvas API, so WebGL-only fillGradientStyle and lineGradientStyle fills do not appear in generated textures. Only Canvas-compatible drawing operations are captured when baking a Graphics object to a texture.

How do I improve Phaser Graphics rendering performance?

Graphics replays its command buffer and rebuilds geometry every frame, which is expensive. For static drawings, call generateTexture and use the result as a sprite, group Graphics objects to reduce batch flushes, and tune pathDetailThreshold for complex paths.