コード例 #1
0
 private void lightSourceColorPictureBox_Click(object sender, EventArgs e)
 {
     if (colorDialog1.ShowDialog() == DialogResult.OK)
     {
         Color color = colorDialog1.Color;
         (sender as PictureBox).BackColor = color;
         PaintingManager.SetLightColor(color);
         this.DrawNewPicture();
     }
 }
コード例 #2
0
 private void constantObjectColorPictureBox_Click(object sender, EventArgs e)
 {
     if (colorDialog1.ShowDialog() == DialogResult.OK)
     {
         Color color = colorDialog1.Color;
         (sender as PictureBox).BackColor = color;
         if (ConstantObjectRadioButton.Checked)
         {
             PaintingManager.SetBaseObject(color);
             this.DrawNewPicture();
         }
     }
 }
コード例 #3
0
        private void CheckRadioButtonsAndDrawNewPicture()
        {
            PaintingManager.SetLightColor(lightSourceColorPictureBox.BackColor);

            if (ConstantObjectRadioButton.Checked)
            {
                PaintingManager.SetBaseObject(constantObjectColorPictureBox.BackColor);
            }
            else
            {
                PaintingManager.SetBaseObject(textureObjectPictureBox.Image as Bitmap);
            }

            if (constantNormalVectorRadioButton.Checked)
            {
                PaintingManager.SetNormalVector(new Vector3(0, 0, 1));
            }
            else
            {
                PaintingManager.SetNormalVector(textureVectorPictureBox.Image as Bitmap);
            }

            if (noDisorderRadioButton.Checked)
            {
                PaintingManager.SetDisorder(new Vector3(0, 0, 0));
            }
            else
            {
                PaintingManager.SetDisorder(textureDisoderPictureBox.Image as Bitmap, fDisorderTextbox.Text);
            }

            if (constantLightSourceVectorRadioButton.Checked)
            {
                timer.Stop();
                PaintingManager.SetLightVector(new Vector3(0, 0, 1), true);
            }
            else
            {
                if (!int.TryParse(radiusLightSourceVectorTextBox.Text, out int radius))
                {
                    return;
                }
                PaintingManager.SetLightVector(new Vector3(radius, 0, 0), false);
                timer.Start();
            }

            PaintingManager.SetLights(redLightToolStripMenuItem.Checked, greenLightToolStripMenuItem.Checked, blueLightToolStripMenuItem.Checked);

            this.DrawNewPicture();
        }
コード例 #4
0
 private void textureVectorPictureBox_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog dlg = new OpenFileDialog())
     {
         dlg.Title  = "Choose Texture Image";
         dlg.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp";
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             Bitmap image = new Bitmap(dlg.FileName);
             (sender as PictureBox).Image = image;
             if (textureNormalVectorRadioButton.Checked)
             {
                 PaintingManager.SetNormalVector(image);
                 this.DrawNewPicture();
             }
         }
     }
 }
コード例 #5
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (!int.TryParse(radiusLightSourceVectorTextBox.Text, out int radius))
            {
                return;
            }
            if (lightX >= radius + screenMiddle.X - lightMove)
            {
                lightX = screenMiddle.X - radius + lightMove;
            }
            else
            {
                lightX += lightMove;
            }

            int     z      = (int)Math.Sqrt(radius * radius - Math.Pow(screenMiddle.X - lightX, 2));
            Vector3 vector = new Vector3(lightX - screenMiddle.X, 0, z);

            PaintingManager.SetLightVector(vector, false);
            this.DrawNewPicture();
        }
コード例 #6
0
 private void DrawScanLine(Bitmap bitmap, int xStart, int xEnd, int y)
 {
     if (y < 0 || y >= bitmap.Height)
     {
         return;
     }
     if (xStart < 0)
     {
         xStart = 0;
     }
     using (Graphics g = Graphics.FromImage(bitmap))
     {
         for (int x = xStart; x <= xEnd; x++)
         {
             if (x >= bitmap.Width)
             {
                 return;
             }
             Color color = PaintingManager.GetColor(x, y);
             bitmap.SetPixel(x, y, color);
         }
     }
 }
コード例 #7
0
        public FillAndCropPolygonForm()
        {
            InitializeComponent();

            Polygon.BitmapWidth  = pictureBox.Width;
            Polygon.BitmapHeight = pictureBox.Height;
            polygonsList         = new List <Polygon>();
            polygon      = new Polygon();
            stableBitmap = temporaryBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);

            pictureBox.MouseClick               += new MouseEventHandler(PictureBox_MouseClick);
            pictureBox.MouseDown                += new MouseEventHandler(PictureBox_MouseDown);
            pictureBox.MouseUp                  += new MouseEventHandler(PictureBox_MouseUp);
            pictureBox.MouseMove                += new MouseEventHandler(PictureBox_MouseMove);
            pictureBox.MouseDoubleClick         += new MouseEventHandler(PictureBox_MouseDoubleClick);
            addNewVertexToolStripMenuItem.Click += new EventHandler(AddNewVertexToolStripMenuItem_Click);

            lightSourceColorPictureBox.Click    += new EventHandler(lightSourceColorPictureBox_Click);
            constantObjectColorPictureBox.Click += new EventHandler(constantObjectColorPictureBox_Click);
            textureObjectPictureBox.Click       += new EventHandler(textureObjectPictureBox_Click);
            textureDisoderPictureBox.Click      += new EventHandler(textureDisoderPictureBox_Click);
            textureVectorPictureBox.Click       += new EventHandler(textureVectorPictureBox_Click);

            // Default
            timer           = new Timer();
            timer.Tick     += new EventHandler(timer_Tick);
            timer.Interval += interval;
            screenMiddle    = new Point(pictureBox.Width / 2, pictureBox.Height / 2);
            lightX          = screenMiddle.X;

            Polygon pol1 = new Polygon();

            pol1.Vertices.Add(new Vertex(new Point(200, 200)));
            pol1.Vertices.Add(new Vertex(new Point(200, 400)));
            pol1.Vertices.Add(new Vertex(new Point(400, 400)));
            pol1.Vertices.Add(new Vertex(new Point(400, 200)));
            polygonsList.Add(pol1);

            Polygon pol2 = new Polygon();

            pol2.Vertices.Add(new Vertex(new Point(300, 150)));
            pol2.Vertices.Add(new Vertex(new Point(150, 300)));
            pol2.Vertices.Add(new Vertex(new Point(450, 300)));
            polygonsList.Add(pol2);

            lightSourceColorPictureBox.BackColor = Color.White;

            textureObjectPictureBox.BackColor = Color.White;
            ConstantObjectRadioButton.Checked = true;

            constantNormalVectorRadioButton.Checked = true;

            fDisorderTextbox.Text         = "0,1";
            noDisorderRadioButton.Checked = true;

            radiusLightSourceVectorTextBox.Text          = "1000";
            constantLightSourceVectorRadioButton.Checked = true;

            PaintingManager.InitializeLanterns(
                new Vector3(0, pictureBox.Height, lanternHeight),
                new Vector3(pictureBox.Width, pictureBox.Height, lanternHeight),
                new Vector3(pictureBox.Width / 2, 0, lanternHeight),
                new Vector3(pictureBox.Width / 2, pictureBox.Height / 2, 0));

            this.CheckRadioButtonsAndDrawNewPicture();

            ConstantObjectRadioButton.CheckedChanged            += new EventHandler(radioButton_CheckedChanged);
            TextureObjectRadioButton.CheckedChanged             += new EventHandler(radioButton_CheckedChanged);
            constantNormalVectorRadioButton.CheckedChanged      += new EventHandler(radioButton_CheckedChanged);
            textureNormalVectorRadioButton.CheckedChanged       += new EventHandler(radioButton_CheckedChanged);
            noDisorderRadioButton.CheckedChanged                += new EventHandler(radioButton_CheckedChanged);
            textureDisorderRadioButton.CheckedChanged           += new EventHandler(radioButton_CheckedChanged);
            constantLightSourceVectorRadioButton.CheckedChanged += new EventHandler(radioButton_CheckedChanged);
            radiusLightSourceVectorRadioButton.CheckedChanged   += new EventHandler(radioButton_CheckedChanged);
            fDisorderTextbox.TextChanged               += new EventHandler(radioButton_CheckedChanged);
            redLightToolStripMenuItem.CheckedChanged   += new EventHandler(radioButton_CheckedChanged);
            greenLightToolStripMenuItem.CheckedChanged += new EventHandler(radioButton_CheckedChanged);
            blueLightToolStripMenuItem.CheckedChanged  += new EventHandler(radioButton_CheckedChanged);
        }