Translation Code

Run Settings
LanguageLua
Language Version
Run Command
function translateToScreen(x,y) x = x - 960 y = y - 540 x = x * 0.5 local angle = math.atan2(y,x)-math.pi/4 if angle < 0 then angle = angle +math.pi*2 end local length = math.sqrt(x * x + y * y) x,y = math.cos(angle)*length , math.sin(angle)*length x = x / grid.blockSize y = y / grid.blockSize return x,y end function translateToIso(x,y,z) z = z or 0 assert(type(x) == "number", "first argument (x) is not a number") assert(type(y) == "number", "second argument (y) is not a number") local angle = math.atan2(y,x)+math.pi/4 if angle < 0 then angle = angle +math.pi*2 end local length = math.sqrt(x * x + y * y) x,y = math.cos(angle)*length , math.sin(angle)*length x,y = x*2*grid.blockSize, y*grid.blockSize x,y = x+960,y+540- z*grid.blockSize*math.sqrt(2) return x , y end
Editor Settings
Theme
Key bindings
Full width
Lines