Excalibur.js logoDocsSamplesCommunityGalleryContributeBlogDonate
Open Table of Contents Close Table of Contents
Documentation
Introduction
WelcomeExcalibur's Philosophy
Getting Started
Installation GuideGetting StartedBuild & Bundlers
Fundamentals
ActorsEngine FundamentalsCamerasScenesClock
Screen & Viewport
DisplayModesScreen & Viewport
Graphics
ColorGraphicsLinesSpritesSpritesheetsText & FontsAnimationCanvasGraphics ComponentGraphics GroupGraphics ContextParallaxPostProcessorsCustom Renderer Plugins
Entity Component System
ECSEntitiesComponentsSystemsQueries
Resources
ImageSourceLoaderSound
Actions
ActionsBlinkCallMethodParallel ActionsDelayEaseToMoveTo/MoveByFadeRotateTo/RotateByRepeatDieFollowMeetScaleTo/ScaleBy
TileMaps
Isometric TileMapsTileMap
Math
MatrixRandomRayVector
Physics
PhysicsFixed UpdateBodiesCollidersCollision EventsCollision GroupsCollision Types
Input
InputKeyboardPointersGamepad
Migration Guides
Migration
Other
Debugging TipsEventsPatternsTimersTriggersUIParticlesPerformanceHosting Excalibur GamesUtilities
Plugins
Aseprite pluginTiled PluginDev Tool
Examples
API Reference
Edge (latest)v0.27.0v0.26.0v0.25.3v0.25.2v0.25.1

Lines

The line graphic object can be used to draw lines using Excalibur. The Actor GraphicsComponent centers graphics by default, so it might be desireable to set the anchor to (0, 0);

const lineActor = new ex.Actor({
  pos: ex.vec(100, 0),
})
lineActor.graphics.anchor = ex.Vector.Zero
lineActor.graphics.use(
  new ex.Line({
    start: ex.vec(0, 0),
    end: ex.vec(200, 200),
    color: ex.Color.Green,
    thickness: 10,
  })
)
game.add(lineActor)
Get Involved
GitHub RepoOpen an IssueAsk a QuestionDonate
Excalibur.js logo
Free & Open Source (BSD 2-Clause)