コード例 #1
0
        private void AddRectangle(int progress, int max, double totalWidth, double totalHeight, double padding, Canvas c)
        {
            Rectangle rect = new Rectangle();

            c.Children.Add(rect);

            Canvas.SetLeft(rect, padding + progress * totalWidth / max);
            Canvas.SetBottom(rect, padding);

            rect.Fill   = new SolidColorBrush(HSVtoRGB.Convert((float)progress / (float)max, 1.0f, 1.0f, 1.0f));
            rect.Width  = totalWidth / max;
            rect.Height = totalHeight;
        }
コード例 #2
0
                public void ChangeColour(int index, int max)
                {
                    int x = Loadings[index];

                    if (x == 0)
                    {
                        L.Stroke          = Brushes.Black;
                        L.StrokeThickness = EmptyLineThickness;
                    }

                    else
                    {
                        double ratio = Math.Log(x) / Math.Log(max);
                        Color  col   = HSVtoRGB.Convert((float)ratio, 1.0f, 1.0f, 1.0f);

                        L.Stroke          = new SolidColorBrush(col);
                        L.StrokeThickness = EmptyLineThickness + (LineExpansion * ratio * ratio); // squared to get more obvious expansion
                    }
                }