Efekt Konturu z Wypełnieniem Koloru

Efekt Konturu z Wypełnieniem Koloru

Ten artykuł demonstruje, jak renderować efekt konturu z wypełnieniem koloru. Efekt konturu służy do dodawania obramowań i konturów do warstw i kształtów. Może być używany do tworzenia jednokolorowych linii, kolorowych gradientów oraz wzorowanych obramowań.

Kroki do renderowania efektu konturu z wypełnieniem koloru są proste:

Poniższy fragment kodu pokazuje, jak renderować efekt konturu z wypełnieniem koloru.

// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_PSD();
// Implement rendering of Stroke effect with Color Fill for export
string sourceFileName = dataDir + "StrokeComplex.psd";
string exportPath = dataDir + "StrokeComplexRendering.psd";
string exportPathPng = dataDir + "StrokeComplexRendering.png";
var loadOptions = new PsdLoadOptions()
{
LoadEffectsResource = true
};
using (var im = (PsdImage)Image.Load(sourceFileName, loadOptions))
{
for (int i = 0; i < im.Layers.Length; i++)
{
var effect = (StrokeEffect)im.Layers[i].BlendingOptions.Effects[0];
var settings = (ColorFillSettings)effect.FillSettings;
settings.Color = Color.DeepPink;
}
// Save psd
im.Save(exportPath, new PsdOptions());
// Save png
im.Save(exportPathPng, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}