void Start() { figura = 0; posic[0, 0] = new PosStruct(0.0f, 0.0f); posic[0, 1] = new PosStruct(0.4f, 0.0f); posic[0, 2] = new PosStruct(-0.4f, 0.0f); posic[0, 3] = new PosStruct(0.8f, 0.0f); posic[0, 4] = new PosStruct(-0.8f, 0.0f); posic[0, 5] = new PosStruct(1.2f, 0.0f); posic[0, 6] = new PosStruct(-1.2f, 0.0f); posic[0, 7] = new PosStruct(1.6f, 0.0f); posic[0, 8] = new PosStruct(-1.6f, 0.0f); posic[0, 9] = new PosStruct(-2.0f, 0.0f); posic[0, 10] = new PosStruct(-2.4f, 0.0f); posic[0, 11] = new PosStruct(-2.8f, 0.0f); posic[1, 0] = new PosStruct(-0.4f, 0.0f); posic[1, 1] = new PosStruct(0.4f, 0.0f); posic[1, 2] = new PosStruct(-0.8f, 0.0f); posic[1, 3] = new PosStruct(0.8f, 0.0f); posic[1, 4] = new PosStruct(1.2f, 0.0f); posic[1, 5] = new PosStruct(-1.2f, 0.0f); posic[1, 6] = new PosStruct(0.0f, 0.4f); posic[1, 7] = new PosStruct(0.0f, -0.4f); posic[1, 8] = new PosStruct(0.0f, 0.8f); posic[1, 9] = new PosStruct(0.0f, -0.8f); posic[1, 10] = new PosStruct(0.0f, 1.2f); posic[1, 11] = new PosStruct(0.0f, -1.2f); posic[2, 0] = new PosStruct(-0.1f, 0.3f); posic[2, 1] = new PosStruct(0.3f, 0.3f); posic[2, 2] = new PosStruct(-0.1f, -0.1f); posic[2, 3] = new PosStruct(0.3f, -0.1f); posic[2, 4] = new PosStruct(-0.4f, 0.6f); posic[2, 5] = new PosStruct(0.6f, 0.6f); posic[2, 6] = new PosStruct(-0.4f, -0.4f); posic[2, 7] = new PosStruct(0.6f, -0.4f); posic[2, 8] = new PosStruct(-0.6f, 0.8f); posic[2, 9] = new PosStruct(0.8f, 0.8f); posic[2, 10] = new PosStruct(-0.6f, -0.6f); posic[2, 11] = new PosStruct(0.8f, -0.6f); posic[3, 0] = new PosStruct(-0.9f, 0.0f); posic[3, 1] = new PosStruct(-0.7f, 0.4f); posic[3, 2] = new PosStruct(-0.3f, 0.8f); posic[3, 3] = new PosStruct(0.1f, 1.0f); posic[3, 4] = new PosStruct(0.5f, 0.8f); posic[3, 5] = new PosStruct(0.9f, 0.4f); posic[3, 6] = new PosStruct(1.1f, 0.0f); posic[3, 7] = new PosStruct(0.9f, -0.4f); posic[3, 8] = new PosStruct(0.5f, -0.8f); posic[3, 9] = new PosStruct(0.1f, -1.0f); posic[3, 10] = new PosStruct(-0.3f, -0.8f); posic[3, 11] = new PosStruct(-0.9f, -0.4f); }
void InitBaseData() { this.m_BasePosInfo = new PosStruct(); this.m_BasePosInfo.TopGoPos = this.TopGo.localPosition; this.m_BasePosInfo.BottomGoPos = this.BottomGo.localPosition; this.m_BasePosInfo.RightGoPos = this.RightGo.localPosition; this.m_BasePosInfo.GridPos = this.Grid.transform.localPosition; this.m_BasePosInfo.GridBgSize = this.GridBg0.localScale; this.m_BasePosInfo.GridBgPos = this.GridBg0.localPosition; this.m_InitData = true; }
void InitBaseData() { this.m_BasePosInfo = new PosStruct(); this.m_BasePosInfo.Bg0GoSize = this.Bg0Go.localScale; this.m_BasePosInfo.RightGoPos = this.RightGo.localPosition; this.m_BasePosInfo.LeftGoPos = this.LeftGo.localPosition; this.m_BasePosInfo.LeftGoSize = this.LeftGo.localScale; this.m_BasePosInfo.LeftBgSize = this.LeftBG.localScale; this.m_BasePosInfo.LeftBgPos = this.LeftBG.localPosition; this.m_BasePosInfo.BtnGoPos = this.BtnGo.localPosition; this.m_InitData = true; }
public void Generate(int ncount, int incount,int i2ncount, int n2ncount, int n2ocount) { List<PosStruct> nodes = new List<PosStruct>(); for (int i = 0; i < ncount; i++) { PosStruct p = new PosStruct(); bool run = true; while (run) { run = false; p.x = r.Next(20); p.y = r.Next(10); p.state = 0; for (int j = 0; j < i; j++) if (nodes[j].x == p.x && nodes[j].y == p.y) { run = true; break; } } nodes.Add(p); } NeuroNodes = nodes.ToArray(); List<PosStruct> instates = new List<PosStruct>(); for (int i = 0; i < incount; i++) { PosStruct p = new PosStruct(); p.x = r.Next(10); p.y = r.Next(10); p.state = 0; instates.Add(p); } InNodes = instates.ToArray(); OutStates = new int[1]; List<Connection> in2nodcon = new List<Connection>(); for (int i = 0; i < i2ncount; i++) { Connection con = new Connection(); con.start = r.Next(incount); con.end = r.Next(ncount); if (r.NextDouble() >= 0.5f) con.xor = true; in2nodcon.Add(con); } In2Nod = in2nodcon.ToArray(); List<Connection> n2nlist = new List<Connection>(); for (int i = 0; i < n2ncount; i++) { Connection n2n = new Connection(); n2n.start = r.Next(ncount); n2n.end = r.Next(ncount); if (r.NextDouble() >= 0.5f) n2n.xor = true; n2nlist.Add(n2n); } Nod2Nod = n2nlist.ToArray(); List<Connection> n2olist = new List<Connection>(); for (int i = 0; i < n2ncount; i++) { Connection n2o = new Connection(); n2o.start = r.Next(ncount); n2o.end = 0; if (r.NextDouble() >= 0.5f) n2o.xor = true; n2olist.Add(n2o); } Nod2Out = n2olist.ToArray(); }
public void WritePosStruct(Stream s, PosStruct p) { s.WriteByte((byte)p.x); s.WriteByte((byte)p.y); }
public PosStruct ReadPosStruct(Stream s) { PosStruct p = new PosStruct(); p.x = s.ReadByte(); p.y = s.ReadByte(); p.state = 0; return p; }
static void change(PosClass pc, PosStruct ps) { pc.x = 3; ps.x = 3; }
static void Main(string[] args) { string currentDir = Environment.CurrentDirectory; string inputFolder = currentDir + "\\Input"; string[] imagePaths = Directory.GetFiles(inputFolder); int imageOffset = 5500; int currentRomAddress = 0; string outPath = currentDir + "\\Output\\Image.txt"; StreamWriter sw = new StreamWriter(outPath); sw.WriteLine("v2.0 raw"); foreach (string imagePath in imagePaths) { if (imagePath.Contains(".png")) { #region png Image image = System.Drawing.Image.FromFile(imagePath); Bitmap bmp = new Bitmap(image, new Size(screenWidth, screenHeight)); List <PosStruct> cyanList = new List <PosStruct>(); List <PosStruct> magentaList = new List <PosStruct>(); List <PosStruct> yellowList = new List <PosStruct>(); for (int y = 0; y < screenHeight; y++) { for (int x = 0; x < screenWidth; x++) { Color color = bmp.GetPixel(x, y); float black = new float[] { 1 - color.R, 1 - color.G, 1 - color.B }.Min(); float Cyan = (1 - color.R - black) / (1 - black); float magenta = (1 - color.G - black) / (1 - black); float yellow = (1 - color.B - black) / (1 - black); if (Cyan > Colourcutoff) { int width = 1 << x; int height = 1 << (screenHeight - y - 1); PosStruct p = new PosStruct() { x = width.ToString("x"), y = height.ToString("x") }; cyanList.Add(p); } if (magenta > Colourcutoff) { int width = 1 << x; int height = 1 << (screenHeight - y + 1); PosStruct p = new PosStruct() { x = width.ToString("x"), y = height.ToString("x") }; magentaList.Add(p); } if (yellow > Colourcutoff) { int width = 1 << x; int height = 1 << (screenHeight - y + 3); PosStruct p = new PosStruct() { x = width.ToString("x"), y = height.ToString("x") }; yellowList.Add(p); } } } bool cyanFinished = true; bool magentaFinished = true; bool yellowFinished = false; while (!cyanFinished | !magentaFinished | !yellowFinished) { if (cyanList.Count > 0) { PosStruct pos = cyanList.First(); sw.Write(" " + pos.x); sw.Write(" " + pos.y); cyanList.Remove(pos); } else { cyanFinished = true; sw.Write(" 0"); sw.Write(" 0"); } if (magentaList.Count > 0) { PosStruct pos = magentaList.First(); sw.Write(" " + pos.x); sw.Write(" " + pos.y); magentaList.Remove(pos); } else { magentaFinished = true; sw.Write(" 0"); sw.Write(" 0"); } if (yellowList.Count > 0) { PosStruct pos = yellowList.First(); sw.Write(" " + pos.x); sw.Write(" " + pos.y); yellowList.Remove(pos); } else { yellowFinished = true; sw.Write(" 0"); sw.Write(" 0"); } sw.WriteLine(); currentRomAddress += 6; } sw.WriteLine((imageOffset - currentRomAddress) + "*0"); currentRomAddress = 0; Console.WriteLine("Image converted"); #endregion } else if (imagePath.Contains(".gif")) { #region gif string gifoutPath = currentDir + "\\Output\\gif.txt"; StreamWriter swgif = new StreamWriter(gifoutPath); swgif.WriteLine("v2.0 raw"); Image gifImg = Image.FromFile(imagePath); FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]); int framecount = gifImg.GetFrameCount(dimension); for (int i = 0; i < framecount; i++) { gifImg.SelectActiveFrame(dimension, i); Bitmap bmp = new Bitmap(gifImg, new Size(screenWidth, screenHeight - 2)); currentRomAddress = 0; for (int y = 0; y < screenHeight - 2; y++) { for (int x = 0; x < screenWidth; x++) { Color color = bmp.GetPixel(x, y); int coloravg = (color.R + color.G + color.B) / 3; if (coloravg > 200) { int width = 1 << x; int height = 1 << (screenHeight - y + 5); swgif.Write(width.ToString("x") + " "); swgif.WriteLine(height.ToString("x")); currentRomAddress += 2; } } } swgif.WriteLine((4096 - currentRomAddress) + "*0"); } swgif.Close(); Console.WriteLine("Gif converted"); #endregion } else { Console.WriteLine("File type was not .supported: " + imagePath); } } sw.Close(); Console.ReadKey(); }