Ejemplo n.º 1
0
        private void F2(Point point)
        {
            MapFill m = new MapFill();

            m.Fill(g, point, p.Color, ref bmp);
            pictureBox2.Image = bmp;
        }
Ejemplo n.º 2
0
Archivo: Form1.cs Proyecto: rruss/PP2_
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     firstPoint = e.Location;
     if (activeTool == Tools.Fill)
     {
         MapFill mf = new MapFill();
         mf.Fill(gfx, firstPoint, pen.Color, ref bmp);
         SetupPictureBox(BmpCreationMode.AfterFill, "");
     }
 }
Ejemplo n.º 3
0
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     prevPoint = e.Location;
     if (mode == Mode.Fill)
     {
         MapFill mf = new MapFill();
         mf.Fill(gfx, e.Location, p.Color, ref bmp);
         pictureBox1.Image = bmp;
         gfx = Graphics.FromImage(bmp);
     }
 }
Ejemplo n.º 4
0
        public static Bitmap PaintMap(Bitmap map, int[] a, int[] r, int[] g, int[] b, int[] x, int[] y)
        {
            Color    old = map.GetPixel(x[0], y[0]);
            Graphics gr  = Graphics.FromImage(map);

            for (int i = 0; i < r.Length; i++)
            {
                Point p = new Point(x[i], y[i]);
                MapFill.FloodFill(gr, p, Color.FromArgb(a[i], r[i], g[i], b[i]), ref map);
            }
            gr.Dispose();
            return(map);
        }
Ejemplo n.º 5
0
    // Items Procs

    public void addMapItem(GameObject Container, mapItem infoItem)
    {
        GameObject newMenu   = Instantiate(infoItemMap, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)) as GameObject;
        MapFill    mapScript = newMenu.GetComponent <MapFill> ();

        smprocSetCustomButton(newMenu.transform.FindChild("update").gameObject, () => mapScript.UpdateMap());
        Image         mapImg = newMenu.transform.FindChild("mapImage").gameObject.GetComponent <Image> ();
        RectTransform menuRT = newMenu.GetComponent <RectTransform> ();

        FillItemRectTransform(menuRT, infoItem.Height, Container.transform);
        float aspect = menuRT.rect.height / menuRT.rect.width;
        float width  = 600;
        float height = width * aspect;

        if (height > 450)
        {
            height = 450;
            width  = height / aspect;
        }
        StartCoroutine(mapScript.LoadMap(infoItem.CenterCoord, infoItem.MarkCoord, Mathf.RoundToInt(width), Mathf.RoundToInt(height), mapImg));
    }
Ejemplo n.º 6
0
    //Could gen 3 at once
    //once middle of middle is reached
    //disable 1st
    //create new after 3rd

    public void SpawnEntered(int SpawnID)
    {
        Vector3 spawnVector = new Vector3(spawnPos, 0, 0);
        //Create next collider in sequence (+ width which is currently 60)
        GameObject spawnCollider = Instantiate(newColliderPrefab, spawnVector, Quaternion.identity);

        spawnCollider.transform.SetParent(this.gameObject.transform);
        spawnPoints.Add(spawnCollider);
        spawnCollider.GetComponent <SpawnPoint>().SetID(spawnPoints.Count);

        objList.Clear();
        GameObject mapSpawn = pool.GetPooledObject("MapGenerator");

        if (!mapSpawn)
        {
            return;
        }
        MapFill mapfill = mapSpawn.GetComponent <MapFill>();

        mapfill.seed                = seedNum;
        mapfill.spawnIndex          = mapIndex;
        mapSpawn.transform.position = new Vector3(spawnPoints[SpawnID - 1].transform.position.x,
                                                  spawnPoints[SpawnID - 1].transform.position.y, 0.0f);
        mapSpawn.SetActive(true);
        objList = pool.ReturnActiveObjects("MapGenerator");

        foreach (GameObject map in objList)
        {
            if (map.GetComponent <MapFill>().spawnIndex == SpawnID - 3)
            {
                map.SetActive(false);
            }
        }

        spawnPos += 60;
        seedNum++;
        mapIndex++;
    }
Ejemplo n.º 7
0
        private void pictureBoxImage_MouseMove(object sender, MouseEventArgs e)
        {
            if (draw)
            {
                Bitmap   bitmapLocalDraw   = null;
                Graphics graohicsLocalDraw = null;

                int       x1 = x < e.X ? x : e.X;
                int       x2 = x > e.X ? x : e.X;
                int       y1 = y < e.Y ? y : e.Y;
                int       y2 = y > e.Y ? y : e.Y;
                Rectangle rectanglePositionDraw = new Rectangle(x1, y1, x2 - x1, y2 - y1);

                switch (currItem)
                {
                case Item.Bucket:
                    /// МЫШКУ УДЕРЖИВАТЬ ВНУТРИ ФИГУРЫ НАЖАТОЙ ДОЛГО ОБРАБАТЫВАЕТ!!!!
                    MapFill gd    = new MapFill();
                    Point   point = new Point(e.X, e.Y);
                    bitmapLocalDraw   = (Bitmap)pictureBoxImage.Image;
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    gd.Fill(graohicsLocalDraw, point, painColor1, ref bitmapLocalDraw);

                    break;

                case Item.Triangle:
                    Point[] points   = { new Point(x1, y1), new Point(x2, y2), new Point(x1, y2) };
                    Pen     blackPen = new Pen(new SolidBrush(painColor1), brushSize);
                    bitmapLocalDraw   = (Bitmap)globalBitmap.Clone();
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.DrawPolygon(blackPen, points);

                    break;

                case Item.Pencil:
                    bitmapLocalDraw   = (Bitmap)pictureBoxImage.Image;
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.FillEllipse(new SolidBrush(painColor1), e.X - brushSize / 2, e.Y - brushSize / 2,
                                                  brushSize, brushSize);
                    break;

                case Item.Text:
                    bitmapLocalDraw   = (Bitmap)pictureBoxImage.Image;
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    String       drawString = text;
                    Font         drawFont   = new Font("Arial", 16);
                    SolidBrush   drawBrush  = new SolidBrush(painColor1);
                    PointF       drawPoint  = new PointF(x, y);
                    StringFormat drawFormat = new StringFormat();
                    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
                    graohicsLocalDraw.DrawString(drawString, drawFont, drawBrush, drawPoint);
                    textBox1.Visible = false;
                    break;

                case Item.line:
                    bitmapLocalDraw   = (Bitmap)globalBitmap.Clone();
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.DrawLine(new Pen(new SolidBrush(painColor1), brushSize),
                                               new Point(x, y), new Point(e.X, e.Y));
                    break;

                case Item.Rectangle:
                    bitmapLocalDraw   = (Bitmap)globalBitmap.Clone();
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.DrawRectangle(new Pen(painColor1, brushSize), rectanglePositionDraw);
                    break;

                case Item.FillRectangle:
                    bitmapLocalDraw   = (Bitmap)globalBitmap.Clone();
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.FillRectangle(new SolidBrush(paintColor2), rectanglePositionDraw);
                    graohicsLocalDraw.DrawRectangle(new Pen(painColor1, brushSize), rectanglePositionDraw);
                    break;

                case Item.Ellipse:
                    bitmapLocalDraw   = (Bitmap)globalBitmap.Clone();
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.DrawEllipse(new Pen(painColor1, brushSize), rectanglePositionDraw);
                    break;

                case Item.FillEllipse:
                    bitmapLocalDraw   = (Bitmap)globalBitmap.Clone();
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.FillEllipse(new SolidBrush(paintColor2), rectanglePositionDraw);
                    graohicsLocalDraw.DrawEllipse(new Pen(painColor1, brushSize), rectanglePositionDraw);
                    break;

                case Item.Brush:
                    bitmapLocalDraw   = (Bitmap)pictureBoxImage.Image;
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.FillEllipse(new SolidBrush(painColor1), e.X - brushSize / 2, e.Y - brushSize / 2,
                                                  brushSize, brushSize);
                    break;

                case Item.Eraser:
                    bitmapLocalDraw   = (Bitmap)pictureBoxImage.Image;
                    graohicsLocalDraw = Graphics.FromImage(bitmapLocalDraw);
                    graohicsLocalDraw.FillEllipse(new SolidBrush(pictureBoxImage.BackColor), e.X - brushSize / 2, e.Y - brushSize / 2,
                                                  brushSize, brushSize);
                    pictureBoxImage.Invalidate();
                    break;
                }

                pictureBoxImage.Image = bitmapLocalDraw;
            }
        }