private LTexture Copy(int width, int height, bool flipHorizontal, bool flipVertial) { int hashCode = 1; hashCode = LSystem.Unite(hashCode, width); hashCode = LSystem.Unite(hashCode, height); hashCode = LSystem.Unite(hashCode, flipHorizontal); hashCode = LSystem.Unite(hashCode, flipVertial); if (childs == null) { childs = new System.Collections.Generic.Dictionary <Int32, LTexture>(10); } lock (childs) { LTexture cache = (LTexture)CollectionUtils.Get(childs, hashCode); if (cache != null) { return(cache); } if (dataCords == null) { SetVertCords(this.GetWidth(), this.GetHeight()); } LTexture copy = new LTexture(); if (isLoaded) { copy.parent = this; copy.imageData = imageData; copy.textureID = textureID; copy.isLoaded = isLoaded; copy.replace = replace; copy.isStatic = isStatic; copy.reload = reload; copy.format = format; copy.hasAlpha = hasAlpha; copy.SetVertCords(width, height); copy.texWidth = texWidth; copy.texHeight = texHeight; copy.SetTexCords(xOff, yOff, widthRatio, heightRatio); if (flipHorizontal) { Swap(8, 10, copy.dataCords); Swap(12, 14, copy.dataCords); } if (flipVertial) { Swap(9, 13, copy.dataCords); Swap(11, 15, copy.dataCords); } copy.xOff = dataCords[8]; copy.yOff = dataCords[9]; copy.widthRatio = dataCords[14]; copy.heightRatio = dataCords[15]; System.Array.Copy(crops, 0, copy.crops, 0, crops.Length); } else { copy.width = width; copy.height = height; copy.texWidth = texWidth; copy.texHeight = texHeight; copy.imageData = imageData; copy.subX = 0; copy.subY = 0; copy.subWidth = width; copy.subHeight = height; copy.isVisible = false; LSystem.Load(new CopyUpdate(this, copy, 0, 0, width, height, flipHorizontal, flipVertial)); } isChild = true; CollectionUtils.Put(childs, hashCode, copy); return(copy); } }
private LTexture Copy(int width, int height, bool flipHorizontal, bool flipVertial) { int hashCode = 1; hashCode = LSystem.Unite(hashCode, width); hashCode = LSystem.Unite(hashCode, height); hashCode = LSystem.Unite(hashCode, flipHorizontal); hashCode = LSystem.Unite(hashCode, flipVertial); if (childs == null) { childs = new System.Collections.Generic.Dictionary<Int32, LTexture>(10); } lock (childs) { LTexture cache = (LTexture)CollectionUtils.Get(childs, hashCode); if (cache != null) { return cache; } if (dataCords == null) { SetVertCords(this.GetWidth(), this.GetHeight()); } LTexture copy = new LTexture(); if (isLoaded) { copy.parent = this; copy.imageData = imageData; copy.textureID = textureID; copy.isLoaded = isLoaded; copy.replace = replace; copy.isStatic = isStatic; copy.reload = reload; copy.format = format; copy.hasAlpha = hasAlpha; copy.SetVertCords(width, height); copy.texWidth = texWidth; copy.texHeight = texHeight; copy.SetTexCords(xOff, yOff, widthRatio, heightRatio); if (flipHorizontal) { Swap(8, 10, copy.dataCords); Swap(12, 14, copy.dataCords); } if (flipVertial) { Swap(9, 13, copy.dataCords); Swap(11, 15, copy.dataCords); } copy.xOff = dataCords[8]; copy.yOff = dataCords[9]; copy.widthRatio = dataCords[14]; copy.heightRatio = dataCords[15]; System.Array.Copy(crops, 0, copy.crops, 0, crops.Length); } else { copy.width = width; copy.height = height; copy.texWidth = texWidth; copy.texHeight = texHeight; copy.imageData = imageData; copy.subX = 0; copy.subY = 0; copy.subWidth = width; copy.subHeight = height; copy.isVisible = false; LSystem.Load(new CopyUpdate(this, copy, 0, 0, width, height, flipHorizontal, flipVertial)); } isChild = true; CollectionUtils.Put(childs, hashCode, copy); return copy; } }
public LTexture GetSubTexture(int x, int y, int width, int height) { int hashCode = 1; hashCode = LSystem.Unite(hashCode, x); hashCode = LSystem.Unite(hashCode, y); hashCode = LSystem.Unite(hashCode, width); hashCode = LSystem.Unite(hashCode, height); if (childs == null) { childs = new System.Collections.Generic.Dictionary <Int32, LTexture>(10); } lock (childs) { LTexture cache = (LTexture)CollectionUtils.Get(childs, hashCode); if (cache != null) { return(cache); } LTexture sub = new LTexture(); if (isLoaded) { sub.parent = this; sub.textureID = textureID; sub.isLoaded = isLoaded; sub.imageData = imageData; sub.hasAlpha = hasAlpha; sub.replace = replace; sub.isStatic = isStatic; sub.reload = reload; sub.format = format; sub.width = width; sub.height = height; sub.texWidth = texWidth; sub.texHeight = texHeight; sub.SetVertCords(width, height); sub.xOff = (((float)x / this.width) * widthRatio) + xOff; sub.yOff = (((float)y / this.height) * heightRatio) + yOff; sub.widthRatio = (((float)width / this.width) * widthRatio) + sub.xOff; sub.heightRatio = (((float)height / this.height) * heightRatio) + sub.yOff; sub.SetTexCords(sub.xOff, sub.yOff, sub.widthRatio, sub.heightRatio); Crop(sub, x, y, width, height); } else { sub.width = width; sub.height = height; sub.texWidth = texWidth; sub.texHeight = texHeight; sub.imageData = imageData; sub.subX = x; sub.subY = y; sub.subWidth = width; sub.subHeight = height; sub.isVisible = false; LSystem.Load(new SubUpdate(this, sub, x, y, width, height)); } isChild = true; CollectionUtils.Put(childs, hashCode, sub); return(sub); } }
public LTexture GetSubTexture(int x, int y, int width, int height) { int hashCode = 1; hashCode = LSystem.Unite(hashCode, x); hashCode = LSystem.Unite(hashCode, y); hashCode = LSystem.Unite(hashCode, width); hashCode = LSystem.Unite(hashCode, height); if (childs == null) { childs = new System.Collections.Generic.Dictionary<Int32, LTexture>(10); } lock (childs) { LTexture cache = (LTexture)CollectionUtils.Get(childs, hashCode); if (cache != null) { return cache; } LTexture sub = new LTexture(); if (isLoaded) { sub.parent = this; sub.textureID = textureID; sub.isLoaded = isLoaded; sub.imageData = imageData; sub.hasAlpha = hasAlpha; sub.replace = replace; sub.isStatic = isStatic; sub.reload = reload; sub.format = format; sub.width = width; sub.height = height; sub.texWidth = texWidth; sub.texHeight = texHeight; sub.SetVertCords(width, height); sub.xOff = (((float)x / this.width) * widthRatio) + xOff; sub.yOff = (((float)y / this.height) * heightRatio) + yOff; sub.widthRatio = (((float)width / this.width) * widthRatio) + sub.xOff; sub.heightRatio = (((float)height / this.height) * heightRatio) + sub.yOff; sub.SetTexCords(sub.xOff, sub.yOff, sub.widthRatio, sub.heightRatio); Crop(sub, x, y, width, height); } else { sub.width = width; sub.height = height; sub.texWidth = texWidth; sub.texHeight = texHeight; sub.imageData = imageData; sub.subX = x; sub.subY = y; sub.subWidth = width; sub.subHeight = height; sub.isVisible = false; LSystem.Load(new SubUpdate(this, sub, x, y, width, height)); } isChild = true; CollectionUtils.Put(childs, hashCode, sub); return sub; } }