Useful links:
https://love2d.org/wiki/Texture:setWrap
https://love2d.org/wiki/WrapMode
Code: Select all
local createCricleMap = function(image, r)
local cos, sin, pi = math.cos, math.sin, math.pi
local d = 2*r
local segments = math.round(pi/math.acos(1-.33/r))
local vertices = {{0, 0, 0.5, 0.5}}
image:setWrap( "repeat" )
for i=0, segments do
local angle = (i / segments) * pi * 2
local x = cos(angle) * r
local y = sin(angle) * r
local u = (0.5 + 4*x / d)
local v = (0.5 + 4*y / d)
vertices[#vertices+1] = {x, y, u, v}
end
local mesh = love.graphics.newMesh(vertices, "fan")
mesh:setTexture(image)
return mesh
end
- 2022-11-17T14_46_22-Untitled.png (26.15 KiB) Viewed 901 times
But what is Cricle Map?
Update:
Code: Select all
local createCricleMap = function(image, r)
local cos, sin, pi = math.cos, math.sin, math.pi
local d = 2*r
local segments = math.round(pi/math.acos(1-.33/r))
local vertices = {{0, 0, 0.5, 0.5, 1,1,1,1}}
image:setWrap( "repeat" )
for i=0, segments do
local angle = (i / segments) * pi * 2
local x = cos(angle) * r
local y = sin(angle) * r
local u = (0.5 + 4*x / d)
local v = (0.5 + 4*y / d)
vertices[#vertices+1] = {x, y, u, v, 1,1,1,0}
end
local mesh = love.graphics.newMesh(vertices, "fan")
mesh:setTexture(image)
return mesh
end
- 2022-11-17T17_08_06-Untitled.png (111.47 KiB) Viewed 866 times
Update2:
Code: Select all
local createCricleMap = function(image, r)
local cos, sin, pi = math.cos, math.sin, math.pi
local d = 2*r
local segments = math.round(pi/math.acos(1-.33/r))
local vertices = {{0, 0, 0.5, 0.5, 1,1,1,1}}
image:setWrap( "repeat" )
for i=0, segments do
local angle = (i / segments) * pi * 2
local x = cos(angle) * r
local y = sin(angle) * r
local u = (0.5 + 4*x / d)
local v = (0.5 + 4*y / d)
vertices[#vertices+1] = {x, y, u, v, 0,0,0,0}
end
local mesh = love.graphics.newMesh(vertices, "fan")
mesh:setTexture(image)
return mesh
end
- 2022-11-17T17_09_17-Untitled.png (95.97 KiB) Viewed 865 times