public void RenderExplodedMine() { RemoveAllChildren(); var s = new SKShapeNode(); var path = new CGPath(); path.MoveToPoint(0, 0); path.AddLineToPoint(size, 0); path.AddLineToPoint(size, size); path.AddLineToPoint(0, size); path.AddLineToPoint(0, 0); s.Path = path.CopyByTransformingPath(CGAffineTransform.MakeTranslation(x * size, y * size)); s.StrokeColor = NSColor.FromCalibratedRgb(0.502f, 0.502f, 0.502f); s.FillColor = NSColor.FromCalibratedRgb(0.8f, 0.8f, 0.8f); AddChild(s); var s1 = new SKShapeNode(); var p1 = new CGPath(); p1.AddArc(x * size + size / 2, y * size + size / 2, size / 4, 0, 2 * (float)Math.PI, true); s1.Path = p1; s1.StrokeColor = NSColor.FromCalibratedRgb(0.2f, 0.2f, 0.2f); s1.FillColor = NSColor.FromCalibratedRgb(0.8f, 0.0f, 0.0f); AddChild(s1); }
private void Win() { state = State.Win; ShowMines(-1); var background = new SKShapeNode(); var p = new CGPath(); p.MoveToPoint(0, 0); p.AddLineToPoint(40 * 19, 0); p.AddLineToPoint(40 * 19, 40 * 13); p.AddLineToPoint(0, 40 * 13); p.AddLineToPoint(0, 0); background.Path = p; background.FillColor = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.7f); AddChild(background); var label = new SKLabelNode("Arial"); label.Text = "Win"; label.FontColor = NSColor.FromCalibratedRgb(0.0f, 0.502f, 0.0f); label.FontSize = 40; label.Position = new CGPoint(40 * 19 / 2, 40 * 13 / 2); label.VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center; label.HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center; AddChild(label); }
NSColor MapColor(int color, bool isFg) { // The default color if (color == Renderer.DefaultColor) { if (isFg) { return(NSColor.Black); } else { return(NSColor.White); } } else if (color == Renderer.InvertedDefaultColor) { if (isFg) { return(NSColor.White); } else { return(NSColor.Black); } } if (colors [color] == null) { Color tcolor = Color.DefaultAnsiColors [color]; colors [color] = NSColor.FromCalibratedRgb(tcolor.Red / 255f, tcolor.Green / 255f, tcolor.Blue / 255f); } return(colors [color]); }
private void DrawMine() { var s1 = new SKShapeNode(); var p1 = new CGPath(); p1.AddArc(size / 2, size / 2, size / 4, 0, 2 * (float)Math.PI, true); s1.Path = p1.CopyByTransformingPath(CGAffineTransform.MakeTranslation(x * size, y * size)); s1.StrokeColor = NSColor.FromCalibratedRgb(0.2f, 0.2f, 0.2f); s1.FillColor = NSColor.FromCalibratedRgb(0.4f, 0.4f, 0.4f); AddChild(s1); }
private void DrawTile() { var s = new SKShapeNode(); var path = new CGPath(); path.MoveToPoint(0, 0); path.AddLineToPoint(size, 0); path.AddLineToPoint(size, size); path.AddLineToPoint(0, size); path.AddLineToPoint(0, 0); s.Path = path.CopyByTransformingPath(CGAffineTransform.MakeTranslation(x * size, y * size)); s.StrokeColor = NSColor.FromCalibratedRgb(0.502f, 0.502f, 0.502f); s.FillColor = NSColor.FromCalibratedRgb(0.8f, 0.8f, 0.8f); AddChild(s); }
public static NSColor ConvertToNSColor(string data) { if (string.IsNullOrEmpty(data)) { return(NSColor.Clear); } if (data != "none") { if (data == "black") { return(NSColor.Black); } if (data == "white") { return(NSColor.White); } } try { data = data.TrimStart('#'); if (data.Length == 6) { return(NSColor.FromCalibratedRgb( int.Parse(data.Substring(0, 2), NumberStyles.HexNumber), int.Parse(data.Substring(2, 2), NumberStyles.HexNumber), int.Parse(data.Substring(4, 2), NumberStyles.HexNumber))); } else // assuming length of 8 { return(NSColor.FromCalibratedRgba( int.Parse(data.Substring(2, 2), NumberStyles.HexNumber), int.Parse(data.Substring(4, 2), NumberStyles.HexNumber), int.Parse(data.Substring(6, 2), NumberStyles.HexNumber), int.Parse(data.Substring(0, 2), NumberStyles.HexNumber))); } } catch (Exception ex) { Console.WriteLine(ex); } return(NSColor.Clear); }
public void RenderDiscovered(int nbMinesAround) { state = State.Discovered; RemoveAllChildren(); var s = new SKShapeNode(); var path = new CGPath(); path.MoveToPoint(0, 0); path.AddLineToPoint(size, 0); path.AddLineToPoint(size, size); path.AddLineToPoint(0, size); path.AddLineToPoint(0, 0); s.Path = path.CopyByTransformingPath(CGAffineTransform.MakeTranslation(x * size, y * size)); s.StrokeColor = NSColor.FromCalibratedRgb(0.502f, 0.502f, 0.502f); s.FillColor = NSColor.FromCalibratedRgb(1.0f, 1.0f, 1.0f); AddChild(s); if (nbMinesAround == 0) { return; } NSColor[] colors = { NSColor.FromCalibratedRgb(0.0f, 0.0f, 1.0f), // Blue NSColor.FromCalibratedRgb(0.0f, 0.502f, 0.0f), // Green NSColor.FromCalibratedRgb(1.0f, 0.0f, 0.0f), // Red NSColor.FromCalibratedRgb(0.0f, 0.0f, 0.502f), // Navy NSColor.FromCalibratedRgb(0.502f, 0.0f, 0.0f), // Maroon NSColor.FromCalibratedRgb(0.0f, 1.0f, 1.0f), // Aqua NSColor.FromCalibratedRgb(0.502f, 0.0f, 0.502f), // Purple NSColor.FromCalibratedRgb(0.0f, 0.0f, 0.0f), // Black }; var label = new SKLabelNode("Arial") { Text = nbMinesAround.ToString(), Position = new CGPoint(x * 40 + 20, y * 40 + 20), FontColor = colors[nbMinesAround - 1], HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center, VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center, FontSize = 38, }; AddChild(label); }