Beispiel #1
0
        private static Point FindGlyph(Point center)
        {
            var rect = new Rectangle(center.X - HexGrid.HexWidth, center.Y - HexGrid.HexHeight, HexGrid.HexWidth * 2, HexGrid.HexHeight * 2);

            using (var capture = new ScreenCapture(rect))
            {
                var analyzer   = new GlyphAnalyzer(capture);
                var startPoint = new Point(rect.Width / 2 - SearchWidth / 2, rect.Height / 2 - SearchHeight / 2);
                for (int y = 0; y < SearchHeight; y++)
                {
                    for (int x = 0; x < SearchWidth; x++)
                    {
                        var location = startPoint.Add(new Point(x, y));
                        if (analyzer.IsMatch(location, GlyphType.Equilibrium))
                        {
                            if (ScreenCapture.LoggingEnabled)
                            {
                                capture.Bitmap.SetPixel(location.X, location.Y, Color.Red);
                                capture.Save();
                            }

                            return(location.Add(capture.Rect.Location));
                        }
                    }
                }
            }

            throw new AnalysisException(Invariant($"Cannot find a glyph in {rect}."));
        }
Beispiel #2
0
 public GlyphPaletteAnalyzer(Palette <GlyphType, GlyphType> palette, ScreenCapture capture)
     : base(capture)
 {
     m_palette       = palette;
     m_glyphAnalyzer = new GlyphAnalyzer(capture);
 }