Exemplo n.º 1
0
        /// <summary>
        /// Draws a FreeFormObject on the layer bitmap using a specified color.
        /// </summary>
        /// <param name="freeform">The FreeFormObject that will be filled with a color</param>
        /// <param name="color">The color to be used</param>
        public void DrawFreeForm(Settings.FreeFormObject freeform, Color color)
        {
            using (Graphics g = Graphics.FromImage(colormap))
            {
                float x_pos  = (float)Math.Round((freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
                float y_pos  = (float)Math.Round((freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);
                float width  = (float)Math.Round(freeform.Width * Effects.editor_to_canvas_width);
                float height = (float)Math.Round(freeform.Height * Effects.editor_to_canvas_height);

                if (width < 3)
                {
                    width = 3;
                }
                if (height < 3)
                {
                    height = 3;
                }

                Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)width, (int)height);

                PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                Matrix myMatrix = new Matrix();
                myMatrix.RotateAt(freeform.Angle, rotatePoint, MatrixOrder.Append);

                g.Transform = myMatrix;
                g.FillRectangle(new SolidBrush(color), rect);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Draws a percent effect on the layer bitmap using a FreeFormObject and a ColorSpectrum.
        /// </summary>
        /// <param name="spectrum">The ColorSpectrum to be used as a "Progress bar"</param>
        /// <param name="freeform">The FreeFormObject that the progress effect will be drawn on</param>
        /// <param name="value">The current progress value</param>
        /// <param name="total">The maxiumum progress value</param>
        /// <param name="percentEffectType">The percent effect type</param>
        public void PercentEffect(ColorSpectrum spectrum, Settings.FreeFormObject freeform, double value, double total, PercentEffectType percentEffectType = PercentEffectType.Progressive)
        {
            double progress_total = value / total;

            if (progress_total < 0.0)
            {
                progress_total = 0.0;
            }
            else if (progress_total > 1.0)
            {
                progress_total = 1.0;
            }

            using (Graphics g = Graphics.FromImage(colormap))
            {
                float x_pos  = (float)Math.Round((freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
                float y_pos  = (float)Math.Round((freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);
                float width  = (float)(freeform.Width * Effects.editor_to_canvas_width);
                float height = (float)(freeform.Height * Effects.editor_to_canvas_height);

                if (width < 3)
                {
                    width = 3;
                }
                if (height < 3)
                {
                    height = 3;
                }

                if (percentEffectType == PercentEffectType.AllAtOnce)
                {
                    Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)width, (int)height);

                    PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                    Matrix myMatrix = new Matrix();
                    myMatrix.RotateAt(freeform.Angle, rotatePoint, MatrixOrder.Append);

                    g.Transform = myMatrix;
                    g.FillRectangle(new SolidBrush(spectrum.GetColorAt((float)progress_total)), rect);
                }
                else
                {
                    double progress = progress_total * width;

                    Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)progress, (int)height);

                    PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                    Matrix myMatrix = new Matrix();
                    myMatrix.RotateAt(freeform.Angle, rotatePoint, MatrixOrder.Append);

                    g.Transform = myMatrix;
                    LinearGradientBrush brush = spectrum.ToLinearGradient(width, 0, x_pos, 0);
                    g.FillRectangle(brush, rect);
                }
            }
        }
Exemplo n.º 3
0
        private void freeform_updated(Settings.FreeFormObject newfreeform)
        {
            if (newfreeform != null)
            {
                Sequence.freeform = newfreeform;

                if (SequenceUpdated != null)
                {
                    SequenceUpdated(this, new EventArgs());
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///  Draws a percent effect on the layer bitmap using a FreeFormObject and a ColorSpectrum.
        /// </summary>
        /// <param name="spectrum">The ColorSpectrum to be used as a "Progress bar"</param>
        /// <param name="freeform">The FreeFormObject that the progress effect will be drawn on</param>
        /// <param name="value">The current progress value</param>
        /// <param name="total">The maxiumum progress value</param>
        /// <param name="percentEffectType">The percent effect type</param>
        /// <returns>Itself</returns>
        public EffectLayer PercentEffect(ColorSpectrum spectrum, Settings.FreeFormObject freeform, double value, double total, PercentEffectType percentEffectType = PercentEffectType.Progressive, double flash_past = 0.0, bool flash_reversed = false)
        {
            double progress_total = value / total;

            if (progress_total < 0.0)
            {
                progress_total = 0.0;
            }
            else if (progress_total > 1.0)
            {
                progress_total = 1.0;
            }

            double flash_amount = 1.0;

            if (flash_past > 0.0)
            {
                if ((flash_reversed && progress_total >= flash_past) || (!flash_reversed && progress_total <= flash_past))
                {
                    flash_amount = Math.Sin((Utils.Time.GetMillisecondsSinceEpoch() % 1000.0D) / 1000.0D * Math.PI);
                }
            }

            using (Graphics g = Graphics.FromImage(colormap))
            {
                float x_pos  = (float)Math.Round((freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
                float y_pos  = (float)Math.Round((freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);
                float width  = (float)(freeform.Width * Effects.editor_to_canvas_width);
                float height = (float)(freeform.Height * Effects.editor_to_canvas_height);

                if (width < 3)
                {
                    width = 3;
                }
                if (height < 3)
                {
                    height = 3;
                }

                if (percentEffectType == PercentEffectType.AllAtOnce)
                {
                    Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)width, (int)height);

                    PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                    Matrix myMatrix = new Matrix();
                    myMatrix.RotateAt(freeform.Angle, rotatePoint, MatrixOrder.Append);

                    g.Transform = myMatrix;
                    g.FillRectangle(new SolidBrush(spectrum.GetColorAt((float)progress_total, 1.0f, flash_amount)), rect);
                }
                else
                {
                    double progress = progress_total * width;

                    Rectangle rect = new Rectangle((int)x_pos, (int)y_pos, (int)progress, (int)height);

                    PointF rotatePoint = new PointF(x_pos + (width / 2.0f), y_pos + (height / 2.0f));

                    Matrix myMatrix = new Matrix();
                    myMatrix.RotateAt(freeform.Angle, rotatePoint, MatrixOrder.Append);

                    g.Transform = myMatrix;
                    LinearGradientBrush brush = spectrum.ToLinearGradient(width, 0, x_pos, 0, flash_amount);
                    g.FillRectangle(brush, rect);
                }

                return(this);
            }
        }