コード例 #1
0
        static void Main(string[] args)
        {
            PointColor dima  = new PointColor();
            PointColor sania = new PointColor();

            dima.Input();
            dima.Output();
            sania.Input();
            sania.Output();

            PointColor p = dima + sania;

            p.Output();

            Console.ReadKey();
        }
コード例 #2
0
        public static PointColor operator +(PointColor first, PointColor second)
        {
            if (first == null || second == null)
            {
                throw new Exception();
            }
            PointColor point = new PointColor();

            point.dotColor.Red   = (first.dotColor.Red + second.dotColor.Red) / 2;
            point.dotColor.Green = (first.dotColor.Green + second.dotColor.Green) / 2;
            point.dotColor.Blue  = (first.dotColor.Blue + second.dotColor.Blue) / 2;

            point.X = first.X + second.X;
            if (point.X > 799)
            {
                point.X = 799;
            }
            point.Y = first.Y + second.Y;
            if (point.Y > 599)
            {
                point.Y = 599;
            }
            return(point);
        }