Repository navigation
Particle Shapes
So far, every emitter we've made had particles spawn from a single point, that being the emitter's position. However, what if you want to spread your particles out over an area? Fortunately, we can achieve this with the Shape module!
The Shape module allows you to set the shape of the emitter. When setting the shape, particles can spawn anywhere inside it or along its outline. This is great for various effects such as rain or a ring of fire.
Unlike other modules, Shape doesn't have an Enabled field. Instead, you pick a shape by setting Shape.Type. By default, it's set to "Point", which is what causes particles to spawn from the emitter's position.
Note
The emitter's Orientation field affects the orientation of shapes!
Setting Shape.Type to "Circle" causes particles to spawn inside a circle. You can change the size of the circle by changing the Radius field (default: 40):
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 0
emitter.ParticleRate = 15
emitter.Shape.Type = "Circle"
emitter.Shape.Radius = 602026-11-23.16-46-27.mp4
The Shape module has a few additional fields that affect emitters with its shape set to "Circle":
-
RadiusThickness(default:1): How much of the circle particles can spawn in, from the edge inwards.1fills the whole circle,0.5only uses the outer 50% (making a thick ring), and so on. -
Arc(default:360): How much of the circle is used, in degrees. For example,180only spawns particles in half of the circle.
Here's a quick example:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 0
emitter.ParticleRate = 40
emitter.Shape.Type = "Circle"
emitter.Shape.Radius = 70
emitter.Shape.RadiusThickness = 0.3
emitter.Shape.Arc = 2702026-11-23.16-51-27.mp4
Setting Shape.Type to "Rectangle" causes particles to spawn inside a rectangle. You can set its width and height using the Size field (default: Vector(1, 1)):
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 0
emitter.ParticleRate = 30
emitter.Shape.Type = "Rectangle"
emitter.Shape.Size = Vector(200, 80)2026-11-23.16-53-51.mp4
Setting Shape.Type to "Line" causes particles to spawn along a straight line. You can set its length with the Length field (default: 120):
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 0
emitter.ParticleRate = 30
emitter.Shape.Type = "Line"
emitter.Shape.Length = 2002026-11-23.16-56-34.mp4
Palette offers many other shapes that you can choose from. However, this page won't cover them extensively, so below is a quick overview.
-
"Triangle": Spawns inside a triangle made from three points inShape.Vertices. -
"Polygon": A regular polygon withShape.Sidessides and a size ofShape.Radius. -
"Star": A star withShape.Sidespoints.Shape.InnerRadiusRatiocontrols how deep the star's points are. -
"Capsule": A pill shape, set withShape.RadiusandShape.Length. -
"Bezier": Spawns along a smooth curve through the points inShape.Points. -
"Polyline": Spawns along straight lines connecting the points inShape.Points. SetShape.Closedtotrueto connect the last point back to the first.
You can view more info regarding them in the API documentation.
Every shape can be stretched with Scale (default: Vector(1, 1)). For example, this squashes a circle into an oval:
emitter.Shape.Scale = Vector(1, 0.5)Shape.EmitFrom determines whether particles spawn within the shape itself or only along the outline. It takes two values:
-
"Area"(default): Particles spawn inside the shape's area. -
"Edge": Particles only spawn along the shape's edges.
By default, particles from a shape all move in the emitter's StartDirection no matter where they spawn. If you set DirectionMode to "Radial", each particle instead moves away from the center of the emitter, which is perfect for bursts and shockwaves:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 2
emitter.ParticleRate = 30
emitter.Shape.Type = "Circle"
emitter.Shape.Radius = 90
emitter.Shape.DirectionMode = "Radial"2026-11-23.17-01-39.mp4
Let's create a cool rain effect! We'll set the emitter's shape to "Line" and line it up along the top of the room:
local mod = RegisterMod("Palette Test", 1)
local Palette = include("palette_scripts.palette")
Palette:Init(mod)
mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
local room = Game():GetRoom()
local topLeft = room:GetTopLeftPos()
local bottomRight = room:GetBottomRightPos()
local position = Vector(room:GetCenterPos().X, topLeft.Y - 80)
local rain = Palette:CreateParticleEmitter("gfx/particle.png", position)
rain.Shape.Type = "Line"
rain.Shape.Length = bottomRight.X - topLeft.X
rain.ParticleRate = 120
rain.MaxParticles = 400
rain.StartDirection = Vector(0, 1)
rain.StartSpeed = { Min = 8, Max = 10 }
rain.Lifetime = { Min = 30, Max = 40 }
rain.StartScale = Vector(0.1, 0.3)
rain.StartColor = KColor(0.6, 0.7, 1, 1)
rain:Prewarm()
end)2026-11-23.17-11-53.mp4
- Palette API
- Particle Emitter API
- AlignToVelocity API
- ColorBySpeed API
- ColorOverLifetime API
- ForceOverLifetime API
- InheritVelocity API
- Keyframe API
- LimitVelocityOverLifetime API
- Noise API
- PaletteBurst API
- PaletteGradient API
- PaletteOverLifetime API
- RotationBySpeed API
- ScaleBySpeed API
- Shape API
- SpriteSheet API
- SubEmitterOptions API
- VelocityOverLifetime API