Set() private method

private Set ( Rect rect ) : void
rect Rect
return void
Esempio n. 1
0
            /// <summary>
            /// Packs a single image. Order is defined externally.
            /// </summary>
            public Rect Insert(Rect rect, FreeRectChoiceHeuristic method)
            {
                Rect newNode = ScoreRect(rect, method);

                if (newNode.Height == 0)
                {
                    return(null);
                }

                int numRectanglesToProcess = _freeRectangles.Count;

                for (int i = 0; i < numRectanglesToProcess; i++)
                {
                    if (SplitFreeNode(_freeRectangles[i], newNode))
                    {
                        _freeRectangles.RemoveAt(i);
                        i--;
                        numRectanglesToProcess--;
                    }
                }

                PruneFreeList();

                Rect bestNode = new Rect();

                bestNode.Set(rect);
                bestNode.Score1  = newNode.Score1;
                bestNode.Score2  = newNode.Score2;
                bestNode.X       = newNode.X;
                bestNode.Y       = newNode.Y;
                bestNode.Width   = newNode.Width;
                bestNode.Height  = newNode.Height;
                bestNode.Rotated = newNode.Rotated;

                _usedRectangles.Add(bestNode);
                return(bestNode);
            }
Esempio n. 2
0
        private void WritePackFile(string outputDir, List<Page> pages, string packFileName)
        {
            string packFile = Path.Combine(outputDir, packFileName);

            if (File.Exists(packFile)) {

            }

            using (FileStream fstr = File.OpenWrite(packFile)) {
                using (TextWriter writer = new StreamWriter(fstr)) {
                    foreach (Page page in pages) {
                        writer.Write("\n" + page.ImageName + "\n");
                        writer.Write("format: " + _settings.Format + "\n");
                        writer.Write("filter: " + "" + "," + "" + "\n");
                        writer.Write("repeat: " + "" + "\n");

                        foreach (Rect rect in page.OutputRects) {
                            WriteRect(writer, page, rect, rect.Name);

                            foreach (Alias alias in rect.Aliases) {
                                Rect aliasRect = new Rect();
                                aliasRect.Set(rect);
                                alias.Apply(aliasRect);
                                WriteRect(writer, page, aliasRect, alias.Name);
                            }
                        }
                    }
                }
            }
        }