Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------
- -- Object: tLayer --
- -- Author: JaggerDer --
- -- Created: --.--.14 --
- ------------------------
- tLayer = {}
- function tLayer:Init(anWidth, anHeight, asName, abVis, abLck)
- if (type(anWidth) ~= "number" or type(anHeight) ~= "number") then
- error("Error: expected number, got " .. type(anWidth) or type(anHeight) .. ".")
- elseif (type(asName) ~= "string") then
- error("Error: expected string, got " .. type(asName) .. ".")
- end
- tLayer = {}
- tLayer.tTextSpace = {}
- tLayer.tTextColorSpace = {}
- tLayer.tColorSpace = {}
- tLayer.sName = asName or "Default"
- tLayer.nWidth = anWidth or 1
- tLayer.nHeight = anHeight or 1
- tLayer.nShiftX = 0
- tLayer.nShiftY = 0
- tLayer.bIsVisible = abVis or true
- tLayer.bIsLocked = abLck or false
- for y = 1, tLayer.nHeight, 1 do
- tLayer.tColorSpace[y] = {}
- tLayer.tTextSpace[y] = {}
- tLayer.tTextColorSpace[y] = {}
- for x = 1, tLayer.nWidth, 1 do
- tLayer.tColorSpace[y][x] = 0
- tLayer.tTextSpace[y][x] = " "
- tLayer.tTextColorSpace[y][x] = 0
- end
- end
- setmetatable(tLayer, self)
- self.__index = self
- return tLayer
- end
- function tLayer:Remove()
- self.sName = nil
- self.tTextSpace = nil
- self.tTextColorSpace = nil
- self.tColorSpace = nil
- return true
- end
- function tLayer:GetParameters()
- return self.sName, self.nWidth, self.nHeight, self.nShiftX, self.nShiftY, self.bIsVisible, self.bIsLocked
- end
- function tLayer:Shift(anShiftX, anShiftY)
- self.nShiftX = anShiftX
- self.nShiftY = anShiftY
- end
- function tLayer:SetPixel(anX, anY, asText, anTextColor, anColor)
- if (string.len(asText) > 1) then
- for i = 1, string.len(asText), 1 do
- self.tTextSpace[anY][anX+i-1] = string.char(string.byte(asText, i))
- self.tTextColorSpace[anY][anX+i-1] = anTextColor
- self.tColorSpace[anY][anX+i-1] = anColor
- end
- else
- self.tTextSpace[anY][anX] = asText
- self.tTextColorSpace[anY][anX] = anTextColor
- self.tColorSpace[anY][anX] = anColor
- end
- end
- function tLayer:GetPixel(anX, anY)
- return self.tTextSpace[anY][anX], self.tTextColorSpace[anY][anX], self.tColorSpace[anY][anX]
- end
- function tLayer:SetVisAndLock(vis, lock)
- self.bIsVisible = vis
- self.self.bIsLocked = lock
- end
- function tLayer:ClearLayer()
- self.tTextSpace = {}
- self.tTextColorSpace = {}
- self.tColorSpace = {}
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement