예제 #1
0
 public void Fade()
 {
     if (toWhite) {
         _currentColor = _currentColor + (_delta * _gap);
         if (_currentColor >= SiftColor.WHITE) {
             Log.Debug ("fading to White completed: let's go back!");
             toWhite = false;
         }
     } else {
         _currentColor = _currentColor - (_delta * _gap);
         if (_currentColor <= _color) {
             Log.Debug ("fading back completed: let's go up 'til white!");
             toWhite = true;
         }
     }
     _mgr.DisplayColor (_currentColor.ToSifteo ());
 }
예제 #2
0
        public static void DisplayMessage(Cube c, String msg, SiftColor color)
        {
            ImageSurface sr = new ImageSurface (Format.ARGB32, 128, 128);
            Cairo.Context context = new Cairo.Context (sr);

            context.Color = new Cairo.Color (0, 0, 0, 0);
            context.Paint ();
            Pango.Layout pango = Pango.CairoHelper.CreateLayout (context);

            pango.FontDescription = Pango.FontDescription.FromString ("Arial 16");
            pango.Alignment = Alignment.Center;
            pango.Wrap = WrapMode.WordChar;
            pango.Width = 128 * 1016;
            pango.SetText (msg);

            context.Color = color.ToCairo ();
            int pWidth = 0, pHeight = 0;
            pango.GetPixelSize (out pWidth, out pHeight);
            Log.Debug ("pango Pixel size: " + pWidth + "x" + pHeight);

            context.MoveTo (0, 64 - (pHeight / 2));
            CairoHelper.ShowLayout (context, pango);
            sr.Flush ();
            byte[] data = sr.Data;

            for (int i = 0, x = 0, y = 0; i < data.Length; i += 4, x++) {
                if (x >= 128) {
                    x = 0;
                    y++;
                }
                byte b = data [i],
                g = data [i + 1],
                r = data [i + 2],
                a = data [i + 3];
                if (a != 0 || r != 0 || g != 0 || b != 0) {
                    SiftColor sc = new SiftColor (r, g, b);
                    c.FillRect (sc.ToSifteo (), x, y, 1, 1);
                } else {
                    // we ignore it
                }
            }
            ((IDisposable)context).Dispose ();
            ((IDisposable)pango).Dispose ();
            ((IDisposable)sr).Dispose ();
        }
 private void FadeColor(String[] affectedCubes, Dictionary<string, object> param)
 {
     Dictionary<string, object> colors = JsonProtocolHelper.AssertTypeInDic<Dictionary<String, Object>> (
         param,
         "color"
     );
     SiftColor fadingColor =
     new SiftColor (
       JsonProtocolHelper.AssertTypeInDic<int> (colors, "r"),
       JsonProtocolHelper.AssertTypeInDic<int> (colors, "g"),
       JsonProtocolHelper.AssertTypeInDic<int> (colors, "b")
     );
     BrowseCubes (delegate(Cube c) {
         FaderHelper fh = FaderLookup.getFaderHelper (c);
         fh.Color = fadingColor;
         _onTick += fh.Fade;
     }, affectedCubes);
 }
        private void ShowMessage(String[] affectedCubes, Dictionary<string, object> param)
        {
            String text_msg = JsonProtocolHelper.AssertTypeInDic<String> (
                param,
                "text_msg"
            );
            Dictionary<string, object> colors = JsonProtocolHelper.AssertTypeInDic<Dictionary<String, Object>> (param, "color");
            SiftColor textColor = new SiftColor (colors);

            BrowseCubes (delegate(Cube c) {
                CubeScreenManager mgr = ScreenManagerLookup.getScreenManager (c);
                mgr.WriteText (text_msg, textColor.ToSifteo ());
            }, affectedCubes);
        }