public PsgSprite(PsgMask mask, PsgOptions options) { this.width = mask.width * (mask.mirrorX ? 2 : 1); this.height = mask.height * (mask.mirrorY ? 2 : 1); this.mask = mask; this.data = new int[this.width * this.height]; var defaults = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; if (options == null) { this.options = defaults; } else { this.options = options; } this.Init (); }
public PsgSprite(PsgMask mask, PsgOptions options) { this.width = mask.width * (mask.mirrorX ? 2 : 1); this.height = mask.height * (mask.mirrorY ? 2 : 1); this.mask = mask; this.data = new int[this.width * this.height]; var defaults = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; if (options == null) { this.options = defaults; } else { this.options = options; } this.Init(); }
private void CheckTemplateSelection() { switch (SpriteTemplateSelection) { case SpriteTemplate.spaceShipColored: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.spaceShipColoredLowSat: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.2f }; break; case SpriteTemplate.spaceShipManyColor: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.85f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.shrubColored: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, -1, 2, 0, 0, 0, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, 0, -1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, -1, -1, 2, 2, 2, 0, 0, -1, -1, 0, 0, -1, -1, 2, 0, -1, 0, -1, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -1, -1, 2, 0, 0, 0, 2, 0, -1, 0, 0, -1, -1, 2, 0, 2, -1, 0, 0, 0, 0, 0, -1, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, -1, -2, 2 }, 9, 21, true, false); spritePadding = 1.7f; options = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.treeColored: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, -1, -1, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 1, -1, -1, -1, -1, 0, 0, 0, 0, 1, -1, 0, 1, 0, 0, 0, 1, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1 }, 13, 26, true, false); spritePadding = 2.1f; options = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.dragonColored: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 12, 12, false, false); spritePadding = 1f; options = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.robotBW: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 2, 2, 0, 0, 1, 2, 0, 0, 0, 2, 1, 1, 1, 2, 0, 1, 1, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 1, 2, 2, 1, 1, 0, 0 }, 4, 11, true, false); spritePadding = 1f; options = new PsgOptions () { Colored = false, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; default: mask = new PsgMask (new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions () { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; } }
private void CheckTemplateSelection() { switch (SpriteTemplateSelection) { case SpriteTemplate.spaceShipColored: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.spaceShipColoredLowSat: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.2f }; break; case SpriteTemplate.spaceShipManyColor: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.85f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.shrubColored: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, -1, 2, 0, 0, 0, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, 0, -1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, -1, -1, 2, 2, 2, 0, 0, -1, -1, 0, 0, -1, -1, 2, 0, -1, 0, -1, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -1, -1, 2, 0, 0, 0, 2, 0, -1, 0, 0, -1, -1, 2, 0, 2, -1, 0, 0, 0, 0, 0, -1, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 0, -1, -2, 2 }, 9, 21, true, false); spritePadding = 1.7f; options = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.treeColored: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, -1, -1, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 1, -1, -1, -1, -1, 0, 0, 0, 0, 1, -1, 0, 1, 0, 0, 0, 1, -1, -1, -1, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1 }, 13, 26, true, false); spritePadding = 2.1f; options = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.dragonColored: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 12, 12, false, false); spritePadding = 1f; options = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; case SpriteTemplate.robotBW: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 2, 2, 0, 0, 1, 2, 0, 0, 0, 2, 1, 1, 1, 2, 0, 1, 1, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 1, 2, 2, 1, 1, 0, 0 }, 4, 11, true, false); spritePadding = 1f; options = new PsgOptions() { Colored = false, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; default: mask = new PsgMask(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 1, -1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, 6, 12, true, false); spritePadding = 1f; options = new PsgOptions() { Colored = true, EdgeBrightness = 0.3f, ColorVariations = 0.2f, BrightnessNoise = 0.3f, Saturation = 0.5f }; break; } }