@Luatee nothing wrong with it in this simple example
-- testingline
-- Use this function to perform your initial setup
function setup()
bgimg=image(WIDTH,HEIGHT)
setContext(bgimg)
background(0, 0, 0, 255)
strokeWidth(2)
line(100,100,400,500)
text("hello",500,500)
setContext()
end
-- This function gets called once every frame
function draw()
sprite(bgimg,WIDTH/2,HEIGHT/2)
end
@Luatee - I get the feeling that something is going wrong with adding pos.x and pos.y to p1 and p2. I think pos.x and pos.y are referring to the global mesh coords with p1 and p2 being local inside the (smaller) self.text image. Try removing the references to pos.x and pos.y from your vec2 definitions and updating
@luatee: @West’s analysis is absolutely correct. Modulo a few details I had to provide (it’s always easier if you provide code that can be cut and pasted directly), the following works for me:
function setup()
size = 100
pos = vec2(WIDTH/2,HEIGHT/2)
self = {}
self.size = size
self.sval = 3
self.eval = 5
self.txt = image(size,size)
self.t = mesh()
self.tr = self.t:addRect(pos.x,pos.y,size+35,size+35)
for i=0,20 do
local mth = ((math.pi*2)/20-((math.pi/20)/(20/2)))*i
local p1 = size*vec2(.5,.5) + vec2(math.sin(mth)*size/2,
math.cos(mth)*size/2)
local p2 = size*vec2(.5,.5) + vec2(math.sin(mth)*(size/2-4),
math.cos(mth)*(size/2-4))
local p3 = vec2(math.sin(mth)*(self.size/2-4),
math.cos(mth)*(self.size/2-4))
setContext(self.txt)
pushStyle()
fontSize(5)
strokeWidth(2)
stroke(220,255)
line(p1.x,p1.y,p2.x,p2.y)
fill(255,255)
text(self.sval+((self.eval-self.sval)/20)*i,p3.x+size/2,p3.y+size/2)
popStyle()
setContext()
end
self.t.texture = self.txt
end
function draw()
background(44, 25, 25, 255)
self.t:draw()
end
Youre absolutely right is was the adding of the positions I only just realised after I went back to look and that was the case, thanks a lot guys helped through my hours of brain bashing