Draw image along line

I have an image which I want to draw along a line. The image is a tile and I want it to repeat as many times as needed, and the line is not parallel to X or Y axis (well, at least not everytime).

How can I achieve this?

 Try this

--Line Coordinates local x1=0 local y1=0 local x2=100 local y2=100 -- local function xypoints(distance,angle) &nbsp;&nbsp;&nbsp; local newpointx,newpointy &nbsp;&nbsp;&nbsp; if math.fmod(angle,90)==0 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if angle==0 or angle==360 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=-distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif angle==90 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif angle==180 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif angle==270 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=-distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=distance\*math.sin(math.rad(angle)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=-distance\*math.cos(math.rad(angle)) &nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; return newpointx,newpointy end local distance=math.sqrt((x2-x1)^2+(y2-y1)^2) --Line width local stepbeetweenimages=10 local widthimage=32 local heightimage=32 --Number of images in line local numberofimages=math.floor(distance/(widthimage+stepbeetweenimages)) local angleofimages = (math.deg(math.atan2( (y2-y1), (x2-x1)))) + 90 if angleofimages \< 0 then &nbsp;&nbsp;&nbsp;&nbsp; angleofimages = 360 + angleofimages end local imagex,imagey=xypoints(widthimage,angleofimages) local stepx,stepy=xypoints(stepbeetweenimages,angleofimages) local groupofimages=display.newGroup() -- Your line group for i=1,numberofimages do &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local imagelink=display.newImageRect("image.png",widthimage,heightimage) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; groupofimages:insert(imagelink,true) imagelink.x=(i-1)\*(imagex+stepx)+imagex/2 imagelink.y=(i-1)\*(imagey+stepy)+imagey/2 imagelink.rotation=angleofimages end groupofimages.x,groupofimages.y=x1,y1

 Try this

--Line Coordinates local x1=0 local y1=0 local x2=100 local y2=100 -- local function xypoints(distance,angle) &nbsp;&nbsp;&nbsp; local newpointx,newpointy &nbsp;&nbsp;&nbsp; if math.fmod(angle,90)==0 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if angle==0 or angle==360 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=-distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif angle==90 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif angle==180 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif angle==270 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=-distance &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointx=distance\*math.sin(math.rad(angle)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newpointy=-distance\*math.cos(math.rad(angle)) &nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; return newpointx,newpointy end local distance=math.sqrt((x2-x1)^2+(y2-y1)^2) --Line width local stepbeetweenimages=10 local widthimage=32 local heightimage=32 --Number of images in line local numberofimages=math.floor(distance/(widthimage+stepbeetweenimages)) local angleofimages = (math.deg(math.atan2( (y2-y1), (x2-x1)))) + 90 if angleofimages \< 0 then &nbsp;&nbsp;&nbsp;&nbsp; angleofimages = 360 + angleofimages end local imagex,imagey=xypoints(widthimage,angleofimages) local stepx,stepy=xypoints(stepbeetweenimages,angleofimages) local groupofimages=display.newGroup() -- Your line group for i=1,numberofimages do &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local imagelink=display.newImageRect("image.png",widthimage,heightimage) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; groupofimages:insert(imagelink,true) imagelink.x=(i-1)\*(imagex+stepx)+imagex/2 imagelink.y=(i-1)\*(imagey+stepy)+imagey/2 imagelink.rotation=angleofimages end groupofimages.x,groupofimages.y=x1,y1