예제 #1
0
        public void Avatar(WebData data, string text = null, long?id = null)
        {
            if (!id.HasValue)
            {
                if (text == null)
                {
                    id = DefaultRNG.UInt32;
                }
                else
                {
                    var crc = (CRC32)crc32.Clone();
                    crc.Update(Encoding.UTF8.GetBytes(text));
                    id = crc.Value;
                }
            }

            int color = (int)(id & 0xFF);

            id >>= 8;
            int nose = (int)(id & 0x1F);

            id >>= 5;
            int eyes = (int)(id & 0x1F);

            id >>= 5;
            int mouth = (int)(id & 0x1F);

            id >>= 5;
            int face = (int)(id & 0x1F);

            id >>= 5;
            int rotate = (int)(id & 0x0F);

            id >>= 4;

            // 32 bit used
            Draw(data, color, nose, eyes, mouth, face, rotate);
        }