mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-01 04:30:49 +12:00
Added random rotate option
This commit is contained in:
parent
241a9f4eb3
commit
7017fee4a6
|
@ -54,6 +54,9 @@ public int ImageCount
|
|||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool RandomRotate { get; set; }
|
||||
|
||||
public DrawRandomImages()
|
||||
{
|
||||
this.ApplyDefaultPropertyValues();
|
||||
|
@ -86,7 +89,22 @@ public override Image Apply(Image img)
|
|||
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);
|
||||
|
||||
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);
|
||||
|
||||
if (RandomRotate)
|
||||
{
|
||||
g.ResetTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue