Class GradientOverlayEffect
अंतर्वस्तु
[
छिपाना
]GradientOverlayEffect class
ढाल परत प्रभाव
public class GradientOverlayEffect : ILayerEffect
गुण
नाम | विवरण |
---|---|
BlendMode { get; set; } | ब्लेंड मोड प्राप्त या सेट करता है। |
EffectType { get; } | एक प्रकार का प्रभाव प्राप्त करता है |
IsVisible { get; set; } | एक मान प्राप्त करता है या सेट करता है जो दर्शाता है कि यह उदाहरण दृश्यमान है या नहीं। |
Opacity { get; set; } | अस्पष्टता प्राप्त या सेट करता है। |
Settings { get; set; } | सेटिंग्स प्राप्त करता है या सेट करता है। |
उदाहरण
निम्न कोड ग्रेडिएंट ओवरले प्रभाव के समर्थन को प्रदर्शित करता है।
[C#]
void AssertIsTrue(bool condition, string message)
{
if (!condition)
{
throw new FormatException(message);
}
}
void AssertAreEqual(object expected, object actual, string message = null)
{
if (!object.Equals(expected, actual))
{
throw new FormatException(message ?? "Objects are not equal.");
}
}
string sourceFileName = "GradientOverlay.psd";
string exportPath = "GradientOverlayChanged.psd";
var loadOptions = new PsdLoadOptions()
{
LoadEffectsResource = true
};
using (var im = (PsdImage)Image.Load(sourceFileName, loadOptions))
{
var gradientOverlay = (GradientOverlayEffect)im.Layers[1].BlendingOptions.Effects[0];
AssertAreEqual(BlendMode.Normal, gradientOverlay.BlendMode);
AssertAreEqual((byte)255, gradientOverlay.Opacity);
AssertAreEqual(true, gradientOverlay.IsVisible);
var settings = gradientOverlay.Settings;
AssertAreEqual(Color.Empty, settings.Color);
AssertAreEqual(FillType.Gradient, settings.FillType);
AssertAreEqual(true, settings.AlignWithLayer);
AssertAreEqual(GradientType.Linear, settings.GradientType);
AssertIsTrue(Math.Abs(33 - settings.Angle) < 0.001, "Angle is incorrect");
AssertAreEqual(false, settings.Dither);
AssertIsTrue(Math.Abs(129 - settings.HorizontalOffset) < 0.001, "Horizontal offset is incorrect");
AssertIsTrue(Math.Abs(156 - settings.VerticalOffset) < 0.001, "Vertical offset is incorrect");
AssertAreEqual(false, settings.Reverse);
// रंग बिंदु
var colorPoints = settings.ColorPoints;
AssertAreEqual(3, colorPoints.Length);
AssertAreEqual(Color.FromArgb(9, 0, 178), colorPoints[0].Color);
AssertAreEqual(0, colorPoints[0].Location);
AssertAreEqual(50, colorPoints[0].MedianPointLocation);
AssertAreEqual(Color.Red, colorPoints[1].Color);
AssertAreEqual(2048, colorPoints[1].Location);
AssertAreEqual(50, colorPoints[1].MedianPointLocation);
AssertAreEqual(Color.FromArgb(255, 252, 0), colorPoints[2].Color);
AssertAreEqual(4096, colorPoints[2].Location);
AssertAreEqual(50, colorPoints[2].MedianPointLocation);
// पारदर्शिता बिंदु
var transparencyPoints = settings.TransparencyPoints;
AssertAreEqual(2, transparencyPoints.Length);
AssertAreEqual(0, transparencyPoints[0].Location);
AssertAreEqual(50, transparencyPoints[0].MedianPointLocation);
AssertAreEqual(100.00, transparencyPoints[0].Opacity);
AssertAreEqual(4096, transparencyPoints[1].Location);
AssertAreEqual(50, transparencyPoints[1].MedianPointLocation);
AssertAreEqual(100.00, transparencyPoints[1].Opacity);
// परीक्षण संपादन
settings.Color = Color.Green;
gradientOverlay.Opacity = 193;
gradientOverlay.BlendMode = BlendMode.Lighten;
settings.AlignWithLayer = false;
settings.GradientType = GradientType.Radial;
settings.Angle = 45;
settings.Dither = true;
settings.HorizontalOffset = 15;
settings.VerticalOffset = 11;
settings.Reverse = true;
// नया रंग बिंदु जोड़ें
var colorPoint = settings.AddColorPoint();
colorPoint.Color = Color.Green;
colorPoint.Location = 4096;
colorPoint.MedianPointLocation = 75;
// पिछले बिंदु का स्थान बदलें
settings.ColorPoints[2].Location = 3000;
// नया पारदर्शिता बिंदु जोड़ें
var transparencyPoint = settings.AddTransparencyPoint();
transparencyPoint.Opacity = 25;
transparencyPoint.MedianPointLocation = 25;
transparencyPoint.Location = 4096;
// पिछले पारदर्शिता बिंदु का स्थान बदलें
settings.TransparencyPoints[1].Location = 2315;
im.Save(exportPath);
}
// संपादन के बाद परीक्षण फ़ाइल
using (var im = (PsdImage)Image.Load(exportPath, loadOptions))
{
var gradientOverlay = (GradientOverlayEffect)im.Layers[1].BlendingOptions.Effects[0];
AssertAreEqual(BlendMode.Lighten, gradientOverlay.BlendMode);
AssertAreEqual((byte)193, gradientOverlay.Opacity);
AssertAreEqual(true, gradientOverlay.IsVisible);
var fillSettings = gradientOverlay.Settings;
AssertAreEqual(Color.Empty, fillSettings.Color);
AssertAreEqual(FillType.Gradient, fillSettings.FillType);
// रंग बिंदुओं की जाँच करें
AssertAreEqual(4, fillSettings.ColorPoints.Length);
var point = fillSettings.ColorPoints[0];
AssertAreEqual(50, point.MedianPointLocation);
AssertAreEqual(Color.FromArgb(9, 0, 178), point.Color);
AssertAreEqual(0, point.Location);
point = fillSettings.ColorPoints[1];
AssertAreEqual(50, point.MedianPointLocation);
AssertAreEqual(Color.Red, point.Color);
AssertAreEqual(2048, point.Location);
point = fillSettings.ColorPoints[2];
AssertAreEqual(50, point.MedianPointLocation);
AssertAreEqual(Color.FromArgb(255, 252, 0), point.Color);
AssertAreEqual(3000, point.Location);
point = fillSettings.ColorPoints[3];
AssertAreEqual(75, point.MedianPointLocation);
AssertAreEqual(Color.Green, point.Color);
AssertAreEqual(4096, point.Location);
// पारदर्शी बिंदुओं की जाँच करें
AssertAreEqual(3, fillSettings.TransparencyPoints.Length);
var transparencyPoint = fillSettings.TransparencyPoints[0];
AssertAreEqual(50, transparencyPoint.MedianPointLocation);
AssertAreEqual(100.0, transparencyPoint.Opacity);
AssertAreEqual(0, transparencyPoint.Location);
transparencyPoint = fillSettings.TransparencyPoints[1];
AssertAreEqual(50, transparencyPoint.MedianPointLocation);
AssertAreEqual(100.0, transparencyPoint.Opacity);
AssertAreEqual(2315, transparencyPoint.Location);
transparencyPoint = fillSettings.TransparencyPoints[2];
AssertAreEqual(25, transparencyPoint.MedianPointLocation);
AssertAreEqual(25.0, transparencyPoint.Opacity);
AssertAreEqual(4096, transparencyPoint.Location);
}
यह सभी देखें
- interface ILayerEffect
- नाम स्थान Aspose.PSD.FileFormats.Psd.Layers.LayerEffects
- सभा Aspose.PSD