AutoPatientInfoRecorder/src/AntdUI/Lib/SVG/Painting/SvgColourServer.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// THIS FILE IS PART OF SVG PROJECT
// THE SVG PROJECT IS AN OPENSOURCE LIBRARY LICENSED UNDER THE MS-PL License.
// COPYRIGHT (C) svg-net. ALL RIGHTS RESERVED.
// GITHUB: https://github.com/svg-net/SVG

using System;
using System.Drawing;

namespace AntdUI.Svg
{
    public sealed class SvgColourServer : SvgPaintServer
    {
        /// <summary>
        /// An unspecified <see cref="SvgPaintServer"/>.
        /// </summary>
        public static readonly SvgPaintServer NotSet = new SvgColourServer();
        /// <summary>
        /// A <see cref="SvgPaintServer"/> that should inherit from its parent.
        /// </summary>
        public static readonly SvgPaintServer Inherit = new SvgColourServer();

        public SvgColourServer() : this(System.Drawing.Color.Black)
        {
        }

        public SvgColourServer(Color colour)
        {
            _colour = colour;
        }

        private Color _colour;

        public Color Colour
        {
            get { return _colour; }
            set { _colour = value; }
        }

        public override Brush GetBrush(SvgVisualElement styleOwner, ISvgRenderer renderer, float opacity, bool forStroke = false)
        {
            // is none?
            if (this == SvgPaintServer.None) return new SolidBrush(System.Drawing.Color.Transparent);

            // default fill color is black, default stroke color is none
            if (this == SvgColourServer.NotSet && forStroke) return new SolidBrush(System.Drawing.Color.Transparent);

            int alpha = (int)Math.Round((opacity * (Colour.A / 255.0)) * 255);
            Color colour = System.Drawing.Color.FromArgb(alpha, Colour);

            return new SolidBrush(colour);
        }

        public override string ToString()
        {
            if (this == SvgPaintServer.None)
                return "none";
            else if (this == SvgColourServer.NotSet)
                return string.Empty;
            else if (this == SvgColourServer.Inherit)
                return "inherit";
后面还有 33 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。