mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Added min/max range for random rotate
This commit is contained in:
parent
fba824e634
commit
32dd3cc77d
1 changed files with 43 additions and 32 deletions
|
@ -66,6 +66,12 @@ public int ImageCount
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
public bool RandomRotate { get; set; }
|
public bool RandomRotate { get; set; }
|
||||||
|
|
||||||
|
[DefaultValue(0)]
|
||||||
|
public int RandomRotateMin { get; set; }
|
||||||
|
|
||||||
|
[DefaultValue(360)]
|
||||||
|
public int RandomRotateMax { get; set; }
|
||||||
|
|
||||||
public DrawRandomImages()
|
public DrawRandomImages()
|
||||||
{
|
{
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
|
@ -93,6 +99,18 @@ public override Image Apply(Image img)
|
||||||
Image img2 = imageCache.GetImage(randomFile);
|
Image img2 = imageCache.GetImage(randomFile);
|
||||||
|
|
||||||
if (img2 != null)
|
if (img2 != null)
|
||||||
|
{
|
||||||
|
DrawImage(img, img2, g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawImage(Image img, Image img2, Graphics g)
|
||||||
{
|
{
|
||||||
int xOffset = img.Width - img2.Width - 1;
|
int xOffset = img.Width - img2.Width - 1;
|
||||||
int yOffset = img.Height - img2.Height - 1;
|
int yOffset = img.Height - img2.Height - 1;
|
||||||
|
@ -116,7 +134,7 @@ public override Image Apply(Image img)
|
||||||
float moveX = rect.X + (rect.Width / 2f);
|
float moveX = rect.X + (rect.Width / 2f);
|
||||||
float moveY = rect.Y + (rect.Height / 2f);
|
float moveY = rect.Y + (rect.Height / 2f);
|
||||||
g.TranslateTransform(moveX, moveY);
|
g.TranslateTransform(moveX, moveY);
|
||||||
g.RotateTransform(MathHelpers.Random(0, 360));
|
g.RotateTransform(MathHelpers.Random(Math.Min(RandomRotateMin, RandomRotateMax), Math.Max(RandomRotateMin, RandomRotateMax)));
|
||||||
g.TranslateTransform(-moveX, -moveY);
|
g.TranslateTransform(-moveX, -moveY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,10 +147,3 @@ public override Image Apply(Image img)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue