Skip to content

Commit

Permalink
Merge pull request #1977 from xQwexx/fix/gradient-layer
Browse files Browse the repository at this point in the history
Fix for gradient layer default behavior change
  • Loading branch information
diogotr7 authored Apr 26, 2020
2 parents ab45073 + 4452a1b commit be03a80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Project-Aurora/Project-Aurora/EffectsEngine/EffectLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public EffectLayer(string name, Color color)
}
else
{
(brush as LinearGradientBrush).ScaleTransform(Effects.canvas_height, Effects.canvas_height);
(brush as LinearGradientBrush).ScaleTransform(Effects.canvas_height * 100 / effect_config.gradient_size, Effects.canvas_height * 100 / effect_config.gradient_size);
}

(brush as LinearGradientBrush).RotateTransform(effect_config.angle);
Expand Down Expand Up @@ -253,7 +253,7 @@ public EffectLayer(string name, Color color)
}
else
{
(brush as PathGradientBrush).ScaleTransform(Effects.canvas_height + x_offset, Effects.canvas_height + y_offset);
(brush as PathGradientBrush).ScaleTransform((Effects.canvas_height + x_offset) * 100 / effect_config.gradient_size, (Effects.canvas_height + y_offset) * 100 / effect_config.gradient_size);
}
}
else
Expand All @@ -265,7 +265,7 @@ public EffectLayer(string name, Color color)
}
else
{
(brush as PathGradientBrush).ScaleTransform(Effects.canvas_height, Effects.canvas_height);
(brush as PathGradientBrush).ScaleTransform(Effects.canvas_height * 100 / effect_config.gradient_size, Effects.canvas_height * 100 / effect_config.gradient_size);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,27 @@ public override EffectLayer Render(IGameState gamestate)
}
else
{
float x_pos = (float)Math.Round((Properties.Sequence.freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
float y_pos = (float)Math.Round((Properties.Sequence.freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);

float width = (float)Math.Round((double)(Properties.Sequence.freeform.Width * Effects.editor_to_canvas_width));
float height = (float)Math.Round((double)(Properties.Sequence.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);

temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig, rect);

if (Properties.Sequence.type == KeySequenceType.Sequence)
{
temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig);

foreach (var key in Properties.Sequence.keys)
gradient_layer.Set(key, Utils.ColorUtils.AddColors(gradient_layer.Get(key), temp_layer.Get(key)));
}
else
{
float x_pos = (float)Math.Round((Properties.Sequence.freeform.X + Effects.grid_baseline_x) * Effects.editor_to_canvas_width);
float y_pos = (float)Math.Round((Properties.Sequence.freeform.Y + Effects.grid_baseline_y) * Effects.editor_to_canvas_height);

float width = (float)Math.Round((double)(Properties.Sequence.freeform.Width * Effects.editor_to_canvas_width));
float height = (float)Math.Round((double)(Properties.Sequence.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);

temp_layer = new EffectLayer("Color Zone Effect", LayerEffects.GradientShift_Custom_Angle, Properties.GradientConfig, rect);

using (Graphics g = gradient_layer.GetGraphics())
{
Expand Down

0 comments on commit be03a80

Please sign in to comment.