mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Added random rotate option
This commit is contained in:
parent
241a9f4eb3
commit
7017fee4a6
1 changed files with 18 additions and 0 deletions
|
@ -54,6 +54,9 @@ public int ImageCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DefaultValue(false)]
|
||||||
|
public bool RandomRotate { get; set; }
|
||||||
|
|
||||||
public DrawRandomImages()
|
public DrawRandomImages()
|
||||||
{
|
{
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
|
@ -86,7 +89,22 @@ public override Image Apply(Image img)
|
||||||
int heightOffset = img.Height - img2.Height - 1;
|
int heightOffset = img.Height - img2.Height - 1;
|
||||||
Rectangle rect = new Rectangle(MathHelpers.Random(Math.Min(0, widthOffset), Math.Max(0, widthOffset)),
|
Rectangle rect = new Rectangle(MathHelpers.Random(Math.Min(0, widthOffset), Math.Max(0, widthOffset)),
|
||||||
MathHelpers.Random(Math.Min(0, heightOffset), Math.Max(0, heightOffset)), img2.Width, img2.Height);
|
MathHelpers.Random(Math.Min(0, heightOffset), Math.Max(0, heightOffset)), img2.Width, img2.Height);
|
||||||
|
|
||||||
|
if (RandomRotate)
|
||||||
|
{
|
||||||
|
float moveX = rect.X + (rect.Width / 2f);
|
||||||
|
float moveY = rect.Y + (rect.Height / 2f);
|
||||||
|
g.TranslateTransform(moveX, moveY);
|
||||||
|
g.RotateTransform(MathHelpers.Random(0, 360));
|
||||||
|
g.TranslateTransform(-moveX, -moveY);
|
||||||
|
}
|
||||||
|
|
||||||
g.DrawImage(img2, rect);
|
g.DrawImage(img2, rect);
|
||||||
|
|
||||||
|
if (RandomRotate)
|
||||||
|
{
|
||||||
|
g.ResetTransform();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue