Exemple #1
0
        private int handle(Action action, ref DataTypes.BitmapUnsafe image, ref int x, ref int y)
        {
            switch (action)
            {
                case Action.MoveLeft:
                    x--;
                    if (x < 0)
                    {
                        x += image.Width;
                        y--;
                        if (y < 0)
                        {
                            y += image.Height;
                        }
                    }
                    goto case Action.MoveNone;
                case Action.MoveRight:
                    x++;
                    if (x >= image.Width)
                    {
                        x -= image.Width;
                        y++;
                        if (y >= image.Height)
                        {
                            y -= image.Height;
                        }
                    }
                    goto case Action.MoveNone;
                case Action.MoveUp:
                    y--;
                    if (y < 0)
                    {
                        y += image.Height;
                    }
                    goto case Action.MoveNone;
                case Action.MoveDown:
                    y++;
                    if (y >= image.Height)
                    {
                        y -= image.Height;
                    }
                    goto case Action.MoveNone;
                case Action.MoveNone:
                    int subwrite = ColorValues.value_from_intcolor[image.GetPixel(x, y)] + magnitude;
                    while (subwrite >= maxstates) subwrite -= maxstates;
                    image.SetPixel(x, y, ColorValues.intcolor_from_value[subwrite]);
                    break;
                /*
                case Action.Reprogram:
                    return ColorValues.value_from_intcolor[image.GetPixel(x, y)] + magnitude;
                */
                case Action.readvalue:
                    int subread = ColorValues.value_from_intcolor[image.GetPixel(x, y)] + magnitude;

                    while (subread >= (int)Action.readvalue) subread -= (int)(Action.readvalue + 1);
                    handle((Action)subread, ref image, ref x, ref y);
                    break;
            }
            return -1;
        }
Exemple #2
0
        public int Handle(ref DataTypes.BitmapUnsafe image, ref int x, ref int y)
        {
            int retval = handle(action, ref image, ref x, ref y);
            if (retval >= 0) return -1 - retval;

            return ColorValues.value_from_intcolor[image.GetPixel(x, y)];
        }