mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Added random size option
This commit is contained in:
parent
7017fee4a6
commit
fba824e634
1 changed files with 25 additions and 4 deletions
|
@ -54,6 +54,15 @@ public int ImageCount
|
|||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool RandomSize { get; set; }
|
||||
|
||||
[DefaultValue(64)]
|
||||
public int RandomSizeMin { get; set; }
|
||||
|
||||
[DefaultValue(128)]
|
||||
public int RandomSizeMax { get; set; }
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool RandomRotate { get; set; }
|
||||
|
||||
|
@ -85,10 +94,22 @@ public override Image Apply(Image img)
|
|||
|
||||
if (img2 != null)
|
||||
{
|
||||
int widthOffset = img.Width - img2.Width - 1;
|
||||
int heightOffset = img.Height - img2.Height - 1;
|
||||
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);
|
||||
int xOffset = img.Width - img2.Width - 1;
|
||||
int yOffset = img.Height - img2.Height - 1;
|
||||
int width, height;
|
||||
|
||||
if (RandomSize)
|
||||
{
|
||||
width = height = MathHelpers.Random(Math.Min(RandomSizeMin, RandomSizeMax), Math.Max(RandomSizeMin, RandomSizeMax));
|
||||
}
|
||||
else
|
||||
{
|
||||
width = img2.Width;
|
||||
height = img2.Height;
|
||||
}
|
||||
|
||||
Rectangle rect = new Rectangle(MathHelpers.Random(Math.Min(0, xOffset), Math.Max(0, xOffset)),
|
||||
MathHelpers.Random(Math.Min(0, yOffset), Math.Max(0, yOffset)), width, height);
|
||||
|
||||
if (RandomRotate)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue