// чтение цвета каждого пикселя в соответсвии с RGB private byte[] ReadColour(Bitmap bitmap, Colours c) { byte[] colArr = new byte[bitmap.Height * bitmap.Width]; // массив байтов, количество элементов которого равно количеству пикселей int ind = 0; // счетчик для прохода по элементам массива байтов // проходим по каждому пикселю и выбираем нужный в соответствии с цветом for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { if (c == Colours.Red) { colArr[ind++] = bitmap.GetPixel(i, j).R; } else if (c == Colours.Green) { colArr[ind++] = bitmap.GetPixel(i, j).G; } else if (c == Colours.Blue) { colArr[ind++] = bitmap.GetPixel(i, j).B; } } } return(colArr); }
public static void MoveOneDice(Colours colour, int roll) { var repeater = "notValid"; do { int pieceNumber = 0; Console.WriteLine("If your piece has been taken you piece will come in on the dice you chose press 0 to continue in this case"); var availableMoves = Board.ValidLocationsPiecesCanGo(colour); Console.WriteLine("Select a piece from the Board to move. E.G. press 1 to move the pieces in location 1 :"); pieceNumber = Convert.ToInt32(Console.ReadLine()); if (Board.executeMove(Globals.Gcolour, pieceNumber, roll) == "Valid") { repeater = "Valid"; } else if (Board.executeMove(Globals.Gcolour, pieceNumber, roll) == "No available moves") { Console.WriteLine("No valid move available skipping turn"); return; } else { Console.WriteLine("Invalid input press enter to restart selection process"); Console.ReadKey(); } } while (repeater == "notValid"); BoardOutputter(); }
public void TestSafeCastingImplicit() { // This will succeed as we're allowing implicit flag combinations. Colours c = 19.ToEnum < Colours > (true); Assert.AreEqual(19, (int)c); }
// конструктор public StegoBitmap(StegoBitmap stgBitmap, byte[] changedColour, Colours c) { RedColour = stgBitmap.RedColour; GreenColour = stgBitmap.GreenColour; BlueColour = stgBitmap.BlueColour; if (c == Colours.Red) { RedColour = changedColour; } if (c == Colours.Green) { GreenColour = changedColour; } if (c == Colours.Blue) { BlueColour = changedColour; } sourceBitmap = new Bitmap(stgBitmap.sourceBitmap.Width, stgBitmap.sourceBitmap.Height); int ind = 0; for (int i = 0; i < sourceBitmap.Width; i++) { for (int j = 0; j < sourceBitmap.Height; j++) { sourceBitmap.SetPixel(i, j, Color.FromArgb(RedColour[ind], GreenColour[ind], BlueColour[ind])); // устанавливает пиксель в нужном месте в соответвии с переданным цветом ind++; } } }
public override void ReloadConfig() { JSONNode config = this.GetConfig(); secondsBetweenArticles = config["secondsBetweenArticles"]; logoColour = Colours.ToColour(config["logoColour"]); }
internal static List <string> FormatForecastResponse(ForecastWeatherModel.Forecast forecast, CurrentWeatherModel.Location location, bool shortWeather = false) { var b = IrcConstants.IrcBold; var n = IrcConstants.IrcNormal; var c = IrcConstants.IrcColor; var colours = new Colours(); List <string> response = new List <string>(); foreach (ForecastWeatherModel.ForecastDay day in forecast.ForecastDays) { if (shortWeather) { response.Add($"Forecast for {day.Date.ToShortDateString()}: {b}Avg:{n} {FormatTemperatureCelsius(day.Day.AvgTempCelsius)}°C; " + $"{b}Min:{n} {FormatTemperatureCelsius(day.Day.MinTempCelsius)}°C; " + $"{b}Max:{n} {FormatTemperatureCelsius(day.Day.MaxTempCelsius)}°C; " + //$"{b}Cond:{n} {day.Day.Condition.Text}; " + $"{b}Precip:{n} {day.Day.TotalPrecipMm} mm; " + $"{b}Avg Humidity:{n} {day.Day.AvgHumidity}%; " + $"{b}Astro:{n} Sunrise at {c}{colours.Blue}{day.Astro.Sunrise}{n}, sunset at {c}{colours.Orange}{day.Astro.Sunset}{n}"); continue; } response.Add($"Forecast for {day.Date.ToShortDateString()}: {b}Avg:{n} {FormatTemperatureCelsius(day.Day.AvgTempCelsius)}°C / {FormatTemperatureFahrenheit(day.Day.AvgTempFahrenheit)}°F; " + $"{b}Min:{n} {FormatTemperatureCelsius(day.Day.MinTempCelsius)}°C / {FormatTemperatureFahrenheit(day.Day.MinTempFahrenheit)}°F; " + $"{b}Max:{n} {FormatTemperatureCelsius(day.Day.MaxTempCelsius)}°C / {FormatTemperatureFahrenheit(day.Day.MaxTempFahrenheit)}°F; " + //$"{b}Condition:{n} {day.Day.Condition.Text}; " + $"{b}Wind (Max):{n} {day.Day.MaxWindKph} Kph / {day.Day.MaxWindMph} Mph; " + $"{b}Precipitation:{n} {day.Day.TotalPrecipMm} mm / {day.Day.TotalPrecipIn} in; " + $"{b}Avg Visibility:{n} {day.Day.AvgVisibilityKm} km / {day.Day.AvgVisibilityMiles} mi; " + $"{b}Avg Humidity:{n} {day.Day.AvgHumidity}%; " + $"{b}Astro:{n} Sunrise at {c}{colours.Blue}{day.Astro.Sunrise}{n}, sunset at {c}{colours.Orange}{day.Astro.Sunset}{n}"); } return(response); }
public Computer(double MonitorWidth, double MonitorHeight, string Brand, Colours Colour) { brand = Brand; this.Colour = Colour; monitorHeight = MonitorHeight; monitorWidth = MonitorWidth; }
public void ResetTurn() { turn = Colours.Black; // Change arrow colours and reset turn to white NextTurn(); }
public async Task <IActionResult> PutColours(ulong id, [FromBody] Colours colours) { if (!_authorizationService.ValidateJWTToken(Request)) { return(Unauthorized(new { errors = new { Token = new string[] { "Invalid token" } }, status = 401 })); } if (id != colours.Id) { return(BadRequest(new { errors = new { Id = new string[] { "ID sent does not match the one in the endpoint" } }, status = 400 })); } Colours currentColour = await _context.Colours.FindAsync(id); try { if (currentColour != null) { currentColour.ColourName = colours.ColourName; currentColour.ColourHash = colours.ColourHash; _context.Entry(currentColour).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); } catch (DbUpdateConcurrencyException) { return(StatusCode(500)); } }
public override INode FormatResult(Parser parser, ParseData data, State state, string scope, Dictionary <string, string> options, string text) { var before = "<" + Element; if (ElementClass != null) { before += " class=\"" + ElementClass + "\""; } if (options.ContainsKey("color") || options.ContainsKey("colour") || options.ContainsKey("size")) { before += " style=\""; if (options.ContainsKey("color") && Colours.IsValidColor(options["color"])) { before += "color: " + options["color"] + ";"; } else if (options.ContainsKey("colour") && Colours.IsValidColor(options["colour"])) { before += "color: " + options["colour"] + ";"; } if (options.ContainsKey("size") && IsValidSize(options["size"])) { before += "font-size: " + options["size"] + "px;"; } before += "\""; } before += ">"; var content = parser.ParseTags(data, text, scope, IsBlock ? "block" : "inline"); var after = "</" + Element + ">"; return(new HtmlNode(before, content, after)); }
public async Task <IActionResult> Edit(int id, [Bind("ColourId,Colour")] Colours colours) { if (id != colours.ColourId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(colours); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ColoursExists(colours.ColourId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(colours)); }
public void Execute_can_castle_both_side(Colours colour, bool side) { int rank = colour == Colours.White ? 1 : 8; var king = new KingEntity(colour); var kingStartFile = King.StartPositionFor(colour).X; var kingDestinationFile = side ? ChessFile.G : ChessFile.C; var kingStartLoc = $"{kingStartFile}{rank}".ToBoardLocation(); var kingDestination = $"{kingDestinationFile}{rank}".ToBoardLocation(); var rook = new RookEntity(colour); var rookStartFile = side ? ChessFile.H : ChessFile.A; var rookDestinationFile = side ? ChessFile.F : ChessFile.D; var rookStart = $"{rookStartFile}{rank}".ToBoardLocation(); var rookDestination = $"{rookDestinationFile}{rank}".ToBoardLocation(); var actualKingMove = new BoardMove(kingStartLoc, kingDestination, (int)DefaultActions.MoveOnly); var actualRookMove = new BoardMove(rookStart, rookDestination, (int)DefaultActions.MoveOnly); SetupLocationReturn(kingStartLoc, king); SetupLocationReturn(rookStart, rook); SetupMockActionForMoveType((int)DefaultActions.MoveOnly); Action.Execute(actualKingMove); VerifyActionWasCreated((int)DefaultActions.MoveOnly); VerifyActionWasExecuted(actualKingMove); VerifyActionWasExecuted(actualRookMove); }
protected int PipCount(Colours colour) { int counter = 0; int PipCount = 0; if (colour == Colours.Black) { for (int i = 0; i < 24; i++) { if (Board.Locations[i].Colour == colour) { counter = Board.Locations[i].Number * (i + 1); PipCount = PipCount + counter; } } } else if (colour == Colours.White) { for (int i = 0; i < 24; i++) { if (Board.Locations[i].Colour == colour) { counter = (24 - i) * Board.Locations[i].Number; PipCount = PipCount + counter; } } } return(PipCount); }
/// <summary> /// Deletes a colour by ID /// </summary> /// <param name="id">ID of the colour to be deleted</param> /// <exception cref="ResourceNotFoundException"> /// Thrown if the user with the corresponding <seealso cref="id"/> is not found /// </exception> /// <returns>Colour deleted</returns> public async Task <Colours> Delete(ulong id) { Colours colour = null; if (_context != null) { colour = await _context.Colours.FindAsync(id); if (colour != null) { _context.Colours.Remove(colour); await _context.SaveChangesAsync(); } else { throw new ResourceNotFoundException("Colour not found"); } } else { colour = Colours.Where(u => u.Id == id).FirstOrDefault(); if (colour != null) { Colours.Remove(colour); } else { throw new ResourceNotFoundException("Colour not found"); } } return(colour); }
GameObject CreateSwatch(Transform parent, string colour, int index) { var swatch = new GameObject(); swatch.AddComponent <RectTransform>(); swatch.AddComponent <Image>(); swatch.AddComponent <Button>(); swatch.name = "Swatch #" + colour; swatch.transform.SetParent(parent, false); var rect = swatch.GetComponent <RectTransform>(); rect.sizeDelta = new Vector2(100, 100); var x = (index % 5) * 120 - 240; var y = index < 5 ? 75 : -50; rect.anchoredPosition = new Vector2(x, y); var rgb = Colours.HexToRgb(colour); swatch.GetComponent <Image>().color = new Color(rgb[0] / 255.0f, rgb[1] / 255.0f, rgb[2] / 255.0f, 1); swatch.GetComponent <Image>().sprite = spriteSwatch; var listener = new SwatchClicked(this) { Swatch = swatch, Colour = colour }; swatch.GetComponent <Button>().onClick.AddListener(listener.Clicked); return(swatch); }
internal static string FormatPercentChange(double percentage) { var colours = new Colours(); string c = IrcConstants.IrcColor.ToString(); if (percentage < -10) { c += colours.LightRed; } else if (percentage < -7.5) { c += colours.Orange; } else if (percentage < 0) { c += colours.Yellow + "," + colours.Grey; } else if (percentage < 10) { c += colours.LightGreen; } else { c += colours.Green; } c += IrcConstants.IrcBold.ToString() + percentage + "%" + IrcConstants.IrcNormal; return(c); }
public void Apply() { var worksetLog = new TransactionLog(@"Workset Creation/Modifications"); if (WorksharingIsEnabled) { ModelSetupWizardUtilities.ApplyWorksetModifications(doc, Worksets.ToList(), ref worksetLog); } var projectInfoLog = new TransactionLog(@"Project Information Modifications"); ModelSetupWizardUtilities.ApplyProjectInfoModifications(doc, ProjectInformation.ToList(), ref projectInfoLog); var iniFile = IniIO.GetIniFile(doc); if (iniFile.Length > 0) { IniIO.WriteColours(iniFile, Colours.ToList()); } else { SCaddinsApp.WindowManager.ShowMessageBox(iniFile + " does not exist"); } string msg = "Summary" + System.Environment.NewLine + System.Environment.NewLine + worksetLog + System.Environment.NewLine + projectInfoLog; SCaddinsApp.WindowManager.ShowMessageBox("Model Setup Wizard - Summary", msg); TryClose(true); }
public Automobile(int engineSize, Colours colour, int doors, int seats) { this.EngineSize = engineSize; this.Colour = colour; this.Doors = doors; this.Seats = seats; }
// конструктор public StegoBitmap(Bitmap bmap, byte[,] newArr, Colours c) { sourceBitmap = new Bitmap(bmap.Width, bmap.Height); for (int i = 0; i < bmap.Width; i++) { for (int j = 0; j < bmap.Height; j++) { if (c == Colours.Red) { sourceBitmap.SetPixel(i, j, Color.FromArgb(newArr[i, j], bmap.GetPixel(i, j).G, bmap.GetPixel(i, j).B)); } else if (c == Colours.Green) { sourceBitmap.SetPixel(i, j, Color.FromArgb(bmap.GetPixel(i, j).R, newArr[i, j], bmap.GetPixel(i, j).B)); } else { sourceBitmap.SetPixel(i, j, Color.FromArgb(bmap.GetPixel(i, j).R, bmap.GetPixel(i, j).G, newArr[i, j])); } } } RedColour = ReadColour(sourceBitmap, Colours.Red); GreenColour = ReadColour(sourceBitmap, Colours.Green); BlueColour = ReadColour(sourceBitmap, Colours.Blue); }
static void Main(string[] args) { //Colours pal = (Colours)(0x1FF); //Console.WriteLine(pal); Colours AllColours = (Colours)(0x1FF); for (int i = 1; i < 0x200; i *= 2) { Console.WriteLine((Colours)i + " " + i); } Console.WriteLine("Pick up to 4 favorite colours"); Colours favoritColours = (Colours)0; favoritColours += int.Parse(Console.ReadLine()); favoritColours += int.Parse(Console.ReadLine()); favoritColours += int.Parse(Console.ReadLine()); favoritColours += int.Parse(Console.ReadLine()); Console.WriteLine(favoritColours); Colours unFavoriteColours = AllColours ^ favoritColours; Console.WriteLine(unFavoriteColours); }
public override void ReloadConfig() { JSONNode config = this.GetConfig(); clockText.color = GetTextColour(); dateText.color = Colours.ToColour(config["dateColour"]); }
public void Should_find_promotions(string sanText, string expectedMoveText, Colours toPlay, ChessPieceName promotionPiece) { var builder = new ChessBoardBuilder() .Board(" k " + " P" + " " + " " + " " + " " + " " + " K " ); var game = ChessFactory.CustomChessGame(builder.ToGameSetup(), toPlay); var move = new SanMoveFinder(game.BoardState) .Find(sanText.ToSan(), toPlay); Assert.NotNull(move, "No move found!"); Assert.That(move.ToChessCoords(), Is.EqualTo(expectedMoveText)); var moveExtraData = move.ExtraData; Assert.NotNull(moveExtraData); var data = ChessFactory.MoveExtraData(toPlay, promotionPiece); Assert.That(move.ToChessCoords(), Is.EqualTo(expectedMoveText)); Assert.That(data, Is.EqualTo(moveExtraData), $"Unexpected promotion: {moveExtraData}"); }
public void RemoveColour(Color c) { if (Colours.ContainsKey(c)) { Colours.Remove(c); } }
public void Print(string model, Colours colour) { switch (colour) { case Colours.Blue: { Console.ForegroundColor = ConsoleColor.Blue; Print(model); break; } case Colours.Red: { Console.ForegroundColor = ConsoleColor.Red; Print(model); break; } case Colours.White: { Console.ForegroundColor = ConsoleColor.White; Print(model); break; } case Colours.Green: { Console.ForegroundColor = ConsoleColor.Green; Print(model); break; } } Console.ResetColor(); }
public void TestEnumCasting() { // This is why traditional flag enums are bad! This cast should fail as it has undefined bits. Colours c = (Colours)256; Assert.AreEqual(256, (int)c); }
public static string Colourize(string line) { Match match = Regex.Match(line, @"^(\s*[<\[(\-]?[ +%@&!~]?)([A-}0-9-]+)([>\])\-]:?\s+.*)"); if (match.Success) { line = match.Groups[1].Value + Colours.NicknameColour(match.Groups[2].Value) + match.Groups[2].Value + "\u000F" + match.Groups[3].Value; } else { match = Regex.Match(line, @"^([ +%@&!~]?)([A-}0-9-]+)(:\s+.*)"); if (match.Success) { line = match.Groups[1].Value + Colours.NicknameColour(match.Groups[2].Value) + match.Groups[2].Value + "\u000F" + match.Groups[3].Value; } else { match = Regex.Match(line, @"^(\*+ )([A-}0-9-]+)(\s+(?!Now talking)(?!Topic)(?:Joins: |Parts: )?.*)"); if (match.Success) { line = match.Groups[1].Value + Colours.NicknameColour(match.Groups[2].Value) + match.Groups[2].Value + "\u000F" + match.Groups[3].Value; } } } return(line); }
public async Task Add_ReturnsColourAdded() { // Arrange _coloursContext = _db.SeedColoursContext(); int currentColoursCount = _db.Colours.Count; List <Colours> currentColours = _db.Colours; Colours expected = new Colours { Id = 3, ColourName = "Green", ColourHash = "#00FF00" }; // Act Colours actual = await _coloursContext.Add(expected); int updatedColoursCount = _db.Colours.Count; _db.Colours = new List <Colours>(currentColours); // Assert Assert.Equal(expected.Id, actual.Id); Assert.Equal(currentColoursCount + 1, updatedColoursCount); }
public async Task Edit_ReturnsTrue() { // Arrange _coloursContext = _db.SeedColoursContext(); ulong id = 2; List <Colours> currentColours = _db.Colours; Colours current = currentColours.FirstOrDefault(c => c.Id == id); Colours updated = current.ShallowCopy(); updated.ColourHash = "#2517c2"; Colours updatedColour = new Colours { Id = id, ColourName = updated.ColourName, ColourHash = updated.ColourHash }; bool expected = true; // Act bool actual = await _coloursContext.Edit(id, updatedColour); Colours u = _db.Colours.FirstOrDefault(c => c.Id == id); _db.Colours = new List <Colours>(currentColours); // Assert Assert.Equal(expected, actual); Assert.Equal(updatedColour.ColourName, updatedColour.ColourName); Assert.Equal(updatedColour.ColourHash, u.ColourHash); }
static unsafe int GetPixel(int penWidth, int *penData, float x, float y) { var left = (int)x; var right = x.Ceiling(); var top = (int)y; var bottom = y.Ceiling(); var i = left + top * penWidth; if (left - x == 0 && y - top == 0) { return(penData[i]); } var j = i + 1; var k = i + penWidth; var l = i + 1 + penWidth; var lt = penData[i]; var rt = penData[j]; var lb = penData[k]; var rb = penData[l]; return(Colours.Blend(lt, rt, lb, rb, x - left, y - top)); }
/// <summary> /// Gets the current colours of the cube pieces /// </summary> /// <returns>Current colours</returns> public Colours[] GetColours() { Colours[] col = new Colours[54]; for (int i = 0; i < centres.Length; i++) { col[i] = centres[i].colour; } int index = 0; for (int i = 0; i < edges.Length * 2; i += 2) { Colours[] cCol = edges[index].GetColours(); col[i + centres.Length] = cCol[0]; col[i + centres.Length + 1] = cCol[1]; index++; } index = 0; for (int i = 0; i < corners.Length * 3; i += 3) { Colours[] cCol = corners[index].GetColours(); col[i + centres.Length + edges.Length * 2] = cCol[0]; col[i + centres.Length + edges.Length * 2 + 1] = cCol[1]; col[i + centres.Length + edges.Length * 2 + 2] = cCol[2]; index++; } return(col); }
public void pileColourCards_init(Values value, Colours colour) { pileColourCards.Clear(); foreach (Card item in cardsToPlay) { if (item.colour == colour) pileColourCards.Add(item); } }
public IntPtr isPileColour(Colours colour) { foreach (Card item in cardsToPlay) { if (item.colour == colour) return new IntPtr(1); } return new IntPtr(0); }
public static void CountLightColors(Colours[] inputColourArray) { int lightColors = 0; foreach (var colour in colors) { if ((int)colour >= 6) { lightColors++; } } }
public Bishop(Colours colour, int x, int y, Types type = Types.Bishop) : base(type, colour, x, y) { for (int xc = 1; xc <= 7; xc++) { // diagonals Moves.Add(new Vector2i(xc, xc), 3); Moves.Add(new Vector2i(-xc, -xc), 3); Moves.Add(new Vector2i(-xc, xc), 3); Moves.Add(new Vector2i(xc, -xc), 3); } }
public Rook(Colours colour, int x, int y, Types type = Types.Rook) : base(type, colour, x, y) { for (int xc = 1; xc <= 7; xc++) { // horizontals Moves.Add(new Vector2i(xc, 0), 3); Moves.Add(new Vector2i(-xc, 0), 3); Moves.Add(new Vector2i(0, xc), 3); Moves.Add(new Vector2i(0, -xc), 3); } }
public King(Colours colour, int x, int y, Types type = Types.King) : base(type, colour, x, y) { Moves.Add(new Vector2i(-1, -1), 3); Moves.Add(new Vector2i(-1, 0), 3); Moves.Add(new Vector2i(-1, 1), 3); Moves.Add(new Vector2i(0, -1), 3); Moves.Add(new Vector2i(0, 0), 3); Moves.Add(new Vector2i(0, 1), 3); Moves.Add(new Vector2i(1, -1), 3); Moves.Add(new Vector2i(1, 0), 3); Moves.Add(new Vector2i(1, 1), 3); }
public Knight(Colours colour, int x, int y, Types type = Types.Knight) : base(type, colour, x, y) { Moves.Add(new Vector2i(-2, -1), 3); Moves.Add(new Vector2i(-1, -2), 3); Moves.Add(new Vector2i(2, -1), 3); Moves.Add(new Vector2i(1, -2), 3); Moves.Add(new Vector2i(2, 1), 3); Moves.Add(new Vector2i(1, 2), 3); Moves.Add(new Vector2i(-2, 1), 3); Moves.Add(new Vector2i(-1, 2), 3); }
public Piece(Types type, Colours colour, int x, int y) { Selected = false; // Assign info. Position = new Vector2i(x, y); Type = type; Colour = colour; // Load sprite Sprite = new Sprite(AssetManager.GetSprite(type, colour)); Sprite.Position = new Vector2f(Position.X * 65, Position.Y * 65); // Movement info. Moves = new Dictionary<Vector2i, int>(); }
public Pawn(Colours colour, int x, int y, Types type = Types.Pawn) : base (type, colour, x, y) { if (colour == Colours.Black) { Moves.Add(new Vector2i(0, 1), 1); Moves.Add(new Vector2i(-1, 1), 2); Moves.Add(new Vector2i(1, 1), 2); Moves.Add(new Vector2i(0, 2), 1); } else { Moves.Add(new Vector2i(0, -1), 1); Moves.Add(new Vector2i(-1, -1), 2); Moves.Add(new Vector2i(1, -1), 2); Moves.Add(new Vector2i(0, -2), 1); } }
public Queen(Colours colour, int x, int y, Types type = Types.Queen) : base(type, colour, x, y) { for (int xc = 1; xc <= 7; xc++) { // horizontals Moves.Add(new Vector2i(xc, 0), 3); Moves.Add(new Vector2i(-xc, 0), 3); Moves.Add(new Vector2i(0, xc), 3); Moves.Add(new Vector2i(0, -xc), 3); // diagonals Moves.Add(new Vector2i(xc, xc), 3); Moves.Add(new Vector2i(-xc, -xc), 3); Moves.Add(new Vector2i(-xc, xc), 3); Moves.Add(new Vector2i(xc, -xc), 3); } }
/// <summary> /// An alternate constructor with no co-ordinates /// </summary> /// <param name="colour"></param> /// <param name="value"></param> public Card(Colours colour, int value) : this(0,0, colour, value) { }
/// <summary> /// Creates a new Card /// </summary> /// <param name="colour">The colour of the Card</param> /// <param name="value">The value of the Card</param> public Card(int x, int y, Colours colour, int value) : base(x, y, colour) { this.Value = value; }
/// <summary> /// Creates a new trophy Card. /// </summary> /// <param name="colour">The colour of the Trophy</param> public Trophy(Colours colour) : base(0, 0, colour) { }
public static Texture GetSprite(Types type, Colours colour) { if (!Sprites.ContainsKey(colour)) return null; return Sprites[colour].ContainsKey(type) ? Sprites[colour][type] : null; }
public static string colouredText(Colours color, string text) { return colorChar + ((int) color) + text + colorChar; }
void OnMousePressed(object sender, MouseButtonEventArgs e) { // Get piece at coordinates. var place = _board[e.X / 65, e.Y / 65]; // Either move or take piece. if (SecondClick) { // toggle off if (place == _selectedPiece) { SecondClick = false; } // If second click is an empty space, try to move piece. will return false is failure. var moved = _selectedPiece.MoveTo(ref _board, e.X / 65, e.Y / 65); switch (moved) { case 3: if (_turnColour == Colours.White) { BlackNumberOfPieces--; UpdateTitle(); } else { WhiteNumberOfPieces--; UpdateTitle(); } break; case 1: return; } _turnColour = _turnColour == Colours.White ? Colours.Black : Colours.White; UpdateTitle(); } else { // Just piece selection. if (place != null) { // there is a piece here. if (place.Colour == _turnColour) { // its the turns type of piece. _selectedPiece = place; } else { // do nothing. return; } } else { // do nothing. return; } } SecondClick = !SecondClick; }
public static string colouredText(Colours color, Colours background, string text) { return colorChar + ((int)color) + "," + ((int)background) + text + colorChar; }
//constructor public HomingBulletEntity(double x, double y, double direction, double drawDirection, Colours colour, BulletType bulletType, Entity target) : base(x, y, direction, drawDirection, colour, bulletType) { _target = target; }
// Heavily modified from http://chironexsoftware.com/blog/?p=60 public static unsafe SonochromaticColourType CalculateDominantColorByEuclidianDistance(Colours colours) { List<Tuple<Colour, double>> colourDist = new List<Tuple<Colour, double>>(); int dimension = colours.dimension; double hue = 0; double saturation = 0; double light = 0; double sumDist = 0; Colour c1, c2; double dist; for (int x = 0; x < dimension; x += 6) { for (int y = 0; y < dimension; y += 6) { c1 = colours.pixels[x, y]; dist = 0; // Ignore any Near-Black/White pixels if ((c1.red > 25 && c1.green > 25 && c1.blue > 25) || (c1.red < 240 && c1.green < 240 && c1.blue < 240)) { for (int x2 = 0; x2 < dimension; x2 += 6) { for (int y2 = 0; y2 < dimension; y2 += 6) { c2 = colours.pixels[x2, y2]; dist += Math.Sqrt(Math.Pow(c2.red - c1.red, 2) + Math.Pow(c2.green - c1.green, 2) + Math.Pow(c2.blue - c1.blue, 2)); } } colourDist.Add(new Tuple<Colour, double>(c1, dist)); } } } var clrs = (from entry in colourDist orderby entry.Item2 ascending select new { colour = entry.Item1, Dist = 1.0 / Math.Max(1, entry.Item2) }).ToList().Take(Math.Max(1, (int)(colourDist.Count * 0.2))); sumDist = clrs.Sum(x => x.Dist); ColourTools.RGB2HSL((int)(clrs.Sum(x => x.colour.red * x.Dist) / sumDist), (int)(clrs.Sum(x => x.colour.green * x.Dist) / sumDist), (int)(clrs.Sum(x => x.colour.blue * x.Dist) / sumDist), out hue, out saturation, out light); return GetColourType(hue, saturation, light); }
//constructor /// <summary> /// BulletEntity, class constructor. /// </summary> /// <param name="x">X position of the bullet.</param> /// <param name="y">Y position of the bullet.</param> /// <param name="direction">Movement Direction of the bullet.</param> /// <param name="drawDirection">Draw Direction of the bullet.</param> /// <param name="colour">Colour of the bullet.</param> /// <param name="bulletType">Type of the bullet.</param> public BulletEntity(double x, double y, double direction, double drawDirection, Colours colour, BulletType bulletType) : base(x, y, new HitBox[] { new HitBox(x - (GameResources.GameImage(bulletType + colour.ToString()).Width / 2.0), y - (GameResources.GameImage(bulletType + colour.ToString()).Height / 2), GameResources.GameImage(bulletType + colour.ToString()).Width, GameResources.GameImage(bulletType + colour.ToString()).Height) }, 1, bulletType + colour.ToString()) { _drawDirection = drawDirection; _bulletColour = colour; _bulletType = bulletType; _movement = new VectorMovement(direction, 1.0); switch(bulletType) { case BulletType.Beam: _movement.Delta = 16.0; break; case BulletType.BigStar: _movement.Delta = 4.0; break; case BulletType.Crystal: _movement.Delta = 8.0; break; case BulletType.Dart: _movement.Delta = 8.0; break; case BulletType.HugeSphere: _movement.Delta = 5.0; break; case BulletType.LargeSphere: _movement.Delta = 6.0; break; case BulletType.Palse: _movement.Delta = 8.0; break; case BulletType.Ring: _movement.Delta = 8.0; break; case BulletType.Seed: _movement.Delta = 8.0; break; case BulletType.Shere: _movement.Delta = 7.0; break; case BulletType.SmallRing: _movement.Delta = 8.0; break; case BulletType.SmallSphere: _movement.Delta = 8.0; break; case BulletType.Star: _movement.Delta = 6.0; break; } }
public static unsafe SonochromaticColourType CalculateAverageColourByAveraging(Colours colours) { int dimension = colours.dimension; ulong pixelCount = 0; ulong red = 0; ulong green = 0; ulong blue = 0; double hue = 0; double saturation = 0; double light = 0; Colour colour; // Calculate the average (literally) colour in the target box // Steps of two for a speedup and hopefuly less junk for (int x = 0; x < dimension; x += 2) { for (int y = 0; y < dimension; y += 2) { colour = colours.pixels[x, y]; // Ignore any Near-Black/White pixels if ((colour.red > 25 && colour.green > 25 && colour.blue > 25) || (colour.red < 240 && colour.green < 240 && colour.blue < 240)) { red += colour.red; green += colour.green; blue += colour.blue; pixelCount++; } } } ColourTools.RGB2HSL((int)(red / pixelCount), (int)(green / pixelCount), (int)(blue / pixelCount), out hue, out saturation, out light); return GetColourType(hue, saturation, light); }
/// <summary> /// Creates a new CardShape with a certain size /// </summary> /// <param name="x">The x position of the CardShape</param> /// <param name="y">The y position of the CardShape</param> /// <param name="colour">The colour of the CardShape</param> public CardShape(int x, int y, Colours colour) : base(x, y, 48, 66, colour) { }