Пример #1
0
 void Awake()
 {
     awareness = GetComponent <CircleCollider2D>();
     Assert.IsNotNull(awareness, $"Missing circle collider component on gameObject {gameObject.name}");
     pulse = GetComponent <PulseColor>();
     Assert.IsNotNull(awareness, $"Missing PulseColor script on gameObject {gameObject.name}");
 }
Пример #2
0
        public bool SetBackgroundColor(PulseColor paramPulseColor, bool paramBoolean)
        {
            int colorIdx = WebColorHelper.RGBToWeb216Index(paramPulseColor);

            sbyte[] cmd = new sbyte[] { -86, 88, 2, (sbyte)colorIdx, (sbyte)(paramBoolean ? 1 : 0) };
            _bluetoothClient.Client.Send(cmd.Select(b => (byte)b).ToArray());

            return(true);
        }
Пример #3
0
        public bool SetCharacterPattern(char character, PulseColor foreground, PulseColor background, bool inlcudeSlave)
        {
            if (!IsConnectMasterDevice)
            {
                return(false);
            }
            int foregroundColor = WebColorHelper.RGBToWeb216Index(foreground);
            int backgroundColor = WebColorHelper.RGBToWeb216Index(background);

            SppCmdHelper.SetCharacterPattern(character, foregroundColor, backgroundColor, inlcudeSlave);
            return(Convert.ToBoolean(true));
        }
Пример #4
0
        public Bitmap SetImage(Bitmap destImage, int brightness)
        {
            BitmapData bData = destImage.LockBits(new Rectangle(0, 0, destImage.Width, destImage.Height), ImageLockMode.ReadWrite, destImage.PixelFormat);

            var bitsPerPixel = 24;

            /*the size of the image in bytes */
            int size = bData.Stride * bData.Height;

            /*Allocate buffer for image*/
            byte[] data = new byte[size];

            /*This overload copies data of /size/ into /data/ from location specified (/Scan0/)*/
            System.Runtime.InteropServices.Marshal.Copy(bData.Scan0, data, 0, size);

            PulseColor[] pulseColors = new PulseColor[destImage.Width * destImage.Height];
            for (int i = 0; i < destImage.Height; i++)
            {
                for (int j = 0; j < destImage.Width; j++)
                {
                    var index = i * destImage.Width + j;
                    pulseColors[index] = new PulseColor();
                    var pulseColor = pulseColors[index];

                    var index2 = (i * bData.Stride) / 3 + j;
                    pulseColor.blue  = (sbyte)data[index2 * 3];
                    pulseColor.green = (sbyte)data[index2 * 3 + 1];
                    pulseColor.red   = (sbyte)data[index2 * 3 + 2];
                }
            }

            /* This override copies the data back into the location specified */
            System.Runtime.InteropServices.Marshal.Copy(data, 0, bData.Scan0, data.Length);

            destImage.UnlockBits(bData);

            if (brightness < 0)
            {
                brightness = 0;
            }
            if (brightness > 255)
            {
                brightness = 255;
            }

            //_pulseHandler.SetBackgroundColor(c, true);
            _pulseHandler.SetColorImage(pulseColors);

            _pulseHandler.SetBrightness(brightness);

            return(destImage);
        }
Пример #5
0
        public void SetBitmap(Bitmap bmp, PulseColor c)
        {
            _bitmap?.Dispose();

            Rectangle cloneRect = new Rectangle(0, 0, bmp.Width, bmp.Height);

            System.Drawing.Imaging.PixelFormat format = bmp.PixelFormat;
            _bitmap = bmp.Clone(cloneRect, format);

            _b.Color = Color.FromArgb((byte)c.red, (byte)c.green, (byte)c.blue);

            Refresh();
        }