コード例 #1
0
ファイル: Pattern.cs プロジェクト: SweetTini/FrogWorks
        protected override void Draw(RendererBatch batch)
        {
            for (int i = 0; i < _mapSize.X * _mapSize.Y; i++)
            {
                var x      = i % _mapSize.X;
                var y      = i / _mapSize.X;
                var origin = Origin - new Vector2(
                    x * Texture.Width,
                    y * Texture.Height);

                var width = x < _mapSize.X - 1 || _remaining.X == 0
                    ? Texture.Width
                    : _remaining.X;
                var height = y < _mapSize.Y - 1 || _remaining.Y == 0
                    ? Texture.Height
                    : _remaining.Y;

                var bounds = new Rectangle(
                    Texture.Bounds.X,
                    Texture.Bounds.Y,
                    width,
                    height);

                Texture.Draw(
                    batch,
                    DrawPosition,
                    bounds,
                    origin,
                    Scale,
                    Angle,
                    Color * Opacity.Clamp(0f, 1f),
                    SpriteEffects);
            }
        }
コード例 #2
0
ファイル: AbstractBrush.cs プロジェクト: piechade/RGB.NET
        /// <summary>
        /// Finalizes the color by appliing the overall brightness and opacity.<br/>
        /// This method should always be the last call of a <see cref="GetColorAtPoint" /> implementation.
        /// </summary>
        /// <param name="color">The color to finalize.</param>
        /// <returns>The finalized color.</returns>
        protected virtual Color FinalizeColor(Color color)
        {
            if (ColorCorrections.Count > 0)
            {
                foreach (IColorCorrection colorCorrection in ColorCorrections)
                {
                    color = colorCorrection.ApplyTo(color);
                }
            }

            // Since we use HSV to calculate there is no way to make a color 'brighter' than 100%
            // Be carefull with the naming: Since we use HSV the correct term is 'value' but outside we call it 'brightness'
            // THIS IS NOT A HSB CALCULATION!!!
            if (Brightness < 1)
            {
                color = color.MultiplyHSV(value: Brightness.Clamp(0, 1));
            }

            if (Opacity < 1)
            {
                color = color.MultiplyA(Opacity.Clamp(0, 1));
            }

            return(color);
        }
コード例 #3
0
ファイル: Image.cs プロジェクト: SweetTini/FrogWorks
 protected override void Draw(RendererBatch batch)
 {
     Texture.Draw(
         batch,
         DrawPosition,
         Origin,
         Scale,
         Angle,
         Color * Opacity.Clamp(0f, 1f),
         SpriteEffects);
 }
コード例 #4
0
        protected sealed override void Draw(RendererBatch batch)
        {
            for (int i = 0; i < DrawRegion.Width * DrawRegion.Height; i++)
            {
                var x        = DrawRegion.Left + (i % DrawRegion.Width);
                var y        = DrawRegion.Top + (i / DrawRegion.Width);
                var position = DrawPosition.Floor() + new Vector2(x * TileWidth, y * TileHeight);

                GetTile(x, y)?.Draw(
                    batch,
                    position,
                    Vector2.Zero,
                    Vector2.One,
                    0f,
                    Color * Opacity.Clamp(0f, 1f),
                    SpriteEffects);
            }
        }