public void ColorImageCorner(Brush color, corners corner) { Bitmap editedImg = new Bitmap(pbCard.Image); //get a new bitmap image based on the picturebox image Graphics flagGraphics = Graphics.FromImage(editedImg); //create a new graphic to edit based on the bitmap Point topLeft = new Point(); int rectWidth = 20; int rectHeight = 20; //select top left of corner to edit based on selection if (corner == corners.TL) { topLeft = new Point(2, 2); } else if (corner == corners.TR) { topLeft = new Point(218, 2); } else if (corner == corners.BL) { topLeft = new Point(2, 314); } else if (corner == corners.BR) { topLeft = new Point(218, 314); } flagGraphics.DrawRectangle(new Pen(color, 1), new Rectangle(topLeft.X, topLeft.Y, rectWidth, rectHeight)); //flagGraphics.FillRectangle(color, topLeft.X, topLeft.Y, rectWidth, rectHeight);//do area fill on selected corner pbCard.Image = editedImg;//save the edited graphic to the picturebox image }
public bool isOverCorner(Point P, corners c) { if (c == corners.leftBottom) { if ((P.X >= 0 && P.X <= 20) && P.Y <= height && P.Y >= Height - 20) { return(true); } } else if (c == corners.leftTop) { if ((P.X >= 0 && P.X <= 5) && P.Y >= 0 && P.Y <= 5) { return(true); } } else if (c == corners.rightBottom) { if ((P.X <= width && P.X >= width - 20) && P.Y <= height && P.Y >= Height - 20) { return(true); } } else if (c == corners.rightTop) { if ((P.X <= width && P.X >= width - 5) && P.Y >= 0 && P.Y <= 5) { return(true); } } return(false); }
public bool isOverRotaPoint(Point P, corners c) { Rectangle bound = bounds(); if (c == corners.leftBottom) { if ((P.X >= bound.Left - 20 && P.X <= bound.Left - 5) && P.Y <= bound.Top + height + 20 && P.Y >= bound.Top + Height + 5) { return(true); } } else if (c == corners.leftTop) { if ((P.X >= bound.Left - 20 && P.X <= bound.Left - 5) && P.Y <= bound.Top - 5 && P.Y >= bound.Top - 20) { return(true); } } else if (c == corners.rightBottom) { if ((P.X <= bound.Left + width + 20 && P.X >= bound.Left + width + 5) && P.Y <= bound.Top + height + 20 && P.Y >= bound.Top + Height + 5) { return(true); } } else if (c == corners.rightTop) { if ((P.X <= bound.Left + width + 20 && P.X >= bound.Left + width + 5) && P.Y <= bound.Top - 5 && P.Y >= bound.Top - 20) { return(true); } } return(false); }
private void Awake() { GeneratePlanesList.generatedPlanes.Add(gameObject); /* foreach(GameObject G in GeneratePlanesList.generatedPlanes) * { * i++; * print(G + " " + i); * }*/ _corners = new corners(); xSize = Random.Range(5, 15); ySize = Random.Range(5, 15); _corners.downLeftCorner = transform.position; _corners.downRightCorner = new Vector3(xSize, 0, 0) + transform.position; _corners.upperRightCorner = new Vector3(xSize, ySize, 0) + transform.position; _corners.upperLeftCorner = new Vector3(0, ySize, 0) + transform.position; _corners.middle = new Vector3(xSize * 0.5f, ySize * 0.5f, 0) + transform.position; Generate(); }
private void UpdateConnections(object sender, EventArgs e) { ComboBox selected = (ComboBox)sender; Brush color = Brushes.Red; corners c1 = corners.TL; if (selected.SelectedIndex == 0) { color = Brushes.Red; } else if (selected.SelectedIndex == 1) { color = Brushes.Blue; } else if (selected.SelectedIndex == 2) { color = Brushes.Green; } else if (selected.SelectedIndex == 3) { color = Brushes.Yellow; } if (selected == cbTopLeft) { c1 = corners.TL; } else if (selected == cbTopRight) { c1 = corners.TR; } else if (selected == cbBottomLeft) { c1 = corners.BL; } else if (selected == cbBottomRight) { c1 = corners.BR; } ColorImageCorner(color, c1); }