-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw.lua
More file actions
87 lines (73 loc) · 2.57 KB
/
Copy pathdraw.lua
File metadata and controls
87 lines (73 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
local LM = require("includes.lovemachine")
--https://love2d.org/forums/viewtopic.php?t=80746
-- Returns canvas of given width and height containing a circle
function initCanvas(size, color)
local c = love.graphics.newCanvas(size, size)
love.graphics.setCanvas(c) -- Switch to drawing on canvas 'c'
--love.graphics.setLineWidth for circle thickness
love.graphics.setBlendMode("alpha")
love.graphics.setColor(color:get())
love.graphics.circle("line", size / 2, size / 2, size / 2.2, 100)
love.graphics.setCanvas() -- Switch back to drawing on main screen
return c
end
--function to create a pulse
--could probably calculate the particle count in an intelligent way...
function createPulse(startSize, color, frequency, duration, endscale)
local img = initCanvas(startSize, color)
--[[local pulse = {
{LM.Components.particle, img, --image
frequency * duration, -- count
duration--[ lifetime]] , frequency, false, --rate, once
{ 0, 0, 0, 0 }, 0, { 0, 0 }, { 0, 0 }, 0, --acceleration, speed, rotation, spin
{ 1, endscale }, 0 --[[scale} --sizes, size variation
}]]
return LM.Components.particle(img, frequency * duration,
duration, frequency, false, { 0, 0, 0, 0 }, 0, { 0, 0 }, { 0, 0 }, 0,
{ 1, endscale }, 0, true)
end
function createStockParticleSystem(imgPath)
return LM.Components.particle(initCanvas(32, Color.new(1, 1, 1, 1)),
32, 5, 5, false, { 0, 0, 0, 0 }, 0, { 0, 0 }, { 0, 0 }, 0,
{ 1, 2 }, 0, true)
end
-- DEBUG HELPERS
function DrawGridFilled(x, y, cellSize)
for i = 0, x, cellSize do
for j = 0, y, cellSize do
love.graphics.rectangle("fill", i, j, cellSize, cellSize)
end
end
end
function DrawGridLines(sX, sY, eX, eY, cellSize)
for i = sX, eX, cellSize do
love.graphics.line(i, 0, i, eY)
end
for j = sY, eY, cellSize do
love.graphics.line(0, j, eX, j)
end
end
function DrawArrows(x, y, cellSize)
local arrowSize = cellSize / 2
for i = 0, x, cellSize do
for j = 0, y, cellSize do
-- Draw the arrow
love.graphics.push()
love.graphics.translate(i + cellSize / 2, j + cellSize / 2)
love.graphics.rotate(math.pi / 4)
love.graphics.polygon("fill", arrowSize / 2, 0, -arrowSize / 2, -arrowSize / 2, -arrowSize / 2, arrowSize / 2)
love.graphics.pop()
end
end
end
-- Function to create the canvas
function CreateGridCanvas(width, height, cellSize)
local canvas = love.graphics.newCanvas(width, height)
love.graphics.setCanvas(canvas)
love.graphics.setColor(255, 255, 255, 1)
-- Reset the color to white
DrawGridLines(0, 0, width, height, cellSize)
love.graphics.setColor(255, 255, 255)
love.graphics.setCanvas()
return canvas
end