コード例 #1
0
 public SketchShadow(bool isEnabled, SketchColor color, SketchPoint offset, double blurRadius, double spread)
 {
     IsEnabled  = isEnabled;
     Color      = color;
     Offset     = offset;
     BlurRadius = blurRadius;
     Spread     = spread;
 }
コード例 #2
0
ファイル: UXBuilder.cs プロジェクト: mortend/sketch2fuse
 UxFloat4 SketchColorToFloat4(SketchColor color)
 {
     return(new UxFloat4(
                (float)color.Red,
                (float)color.Green,
                (float)color.Blue,
                (float)color.Alpha
                ));
 }
コード例 #3
0
        SketchStringAttribute ParseAttribute(NSDictionary attributeDict)
        {
            var fontDescriptorAttributes = attributeDict
                                           .GetAs <NSDictionary>("MSAttributedStringFontAttribute")
                                           .GetAs <NSDictionary>("NSFontDescriptorAttributes");

            var alignment = SketchTextAlignment.Left;

            if (attributeDict.ContainsKey("NSParagraphStyle"))
            {
                var paragraphStyle = attributeDict.GetAs <NSDictionary>("NSParagraphStyle");
                if (paragraphStyle.ContainsKey("NSAlignment"))
                {
                    alignment = ParseAlignment(paragraphStyle.GetAs <NSNumber>("NSAlignment"));
                }
            }

            // Looks like the color format of text objects in Sketch has changed between version 91 and 93
            // I've only found MSAttributedStringColorDictionaryAttribute in version 93. 2018-01-05 anette
            var sketchColor = SketchColor.Black;

            if (attributeDict.ContainsKey("NSColor"))
            {
                var nsDictionaryColor = attributeDict.GetAs <NSDictionary>("NSColor");
                sketchColor = ParseColor(nsDictionaryColor);
            }
            else if (attributeDict.ContainsKey("MSAttributedStringColorDictionaryAttribute"))
            {
                var components = attributeDict.GetAs <NSDictionary>("MSAttributedStringColorDictionaryAttribute");
                sketchColor = new SketchColor(
                    double.Parse(components["red"].ToString()),
                    double.Parse(components["green"].ToString()),
                    double.Parse(components["blue"].ToString()),
                    components.ContainsKey("alpha") ? double.Parse(components["alpha"].ToString()) : 1.0);
            }
            else
            {
                _log.Warning("Could not find color property for text object. Default to black.");
            }
            var fontSize = (double)fontDescriptorAttributes.GetAs <NSNumber>("NSFontSizeAttribute");

            return(new SketchStringAttribute
                   (
                       sketchColor,
                       fontSize,
                       alignment
                   ));
        }
コード例 #4
0
 public SketchStringAttribute(SketchColor color, double fontSize, SketchTextAlignment alignment)
 {
     Color     = color;
     FontSize  = fontSize;
     Alignment = alignment;
 }
コード例 #5
0
 public SketchGradientStop(SketchColor color, double position)
 {
     Color    = color;
     Position = position;
 }
コード例 #6
0
 public SketchSolidColorBrush(SketchColor color)
 {
     Color = color;
 }