コード例 #1
0
ファイル: Util.cs プロジェクト: folterj/ProMISE2
        public static Color CMYKtoColor(CMYKa cmyka)
        {
            float r = (1 - cmyka.c) * (1 - cmyka.k);
            float g = (1 - cmyka.m) * (1 - cmyka.k);
            float b = (1 - cmyka.y) * (1 - cmyka.k);
            float a = cmyka.a;

            return(Color.FromScRgb(a, r, g, b));
        }
コード例 #2
0
        UIElement createComp(float vx, float vy, float vw, float vh, float vthick, Brush fill)
        {
            Ellipse ellipse = new Ellipse();
            float   rad     = vw * 0.75f;
            int     n       = controlparams.comps.Count;
            CMYKa   cmyka   = new CMYKa();
            float   c       = 0;
            float   m       = 0;
            float   y       = 0;
            float   k       = 0;
            float   a       = 0;

            ellipse.Width  = convVSizeX(rad);
            ellipse.Height = convVSizeX(rad);
            SetLeft(ellipse, convVX(vx + (vw - rad) / 2));
            SetTop(ellipse, convVY(vy + vh / 2) - convVSizeX(rad / 2));

            if (n > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    cmyka = Util.ColorToCMYK(Util.colorRange(i, n));
                    c    += cmyka.c;
                    m    += cmyka.m;
                    y    += cmyka.y;
                    k    += cmyka.k;
                    a    += cmyka.a;
                }
                cmyka.c      = c / n;
                cmyka.m      = m / n;
                cmyka.y      = y / n;
                cmyka.k      = k / n + n / 10.0f;                       // make darker
                cmyka.a      = a / n;
                ellipse.Fill = new SolidColorBrush(Util.CMYKtoColor(cmyka));
            }
            return(ellipse);
        }