Exemple #1
0
        public ColorPicker(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder)
            : base(screen, info, drawOrder)
        {
            info.BackgroundColor = () => Color.Black;
            info.ForegroundColor = () => Color.White;
            info.AlignX = HorizontalAlignment.Left;
            info.AlignY = VerticalAlignment.Top;
            // colors
            colors = new List<Color> (CreateColors (64));
            colors.Sort (Utilities.ColorHelper.SortColorsByLuminance);
            tiles = new List<Vector2> (CreateTiles (colors));

            // create a new SpriteBatch, which can be used to draw textures
            spriteBatch = new SpriteBatch (screen.device);

            info.RelativePosition = () => (Vector2.One - info.RelativeSize ()) / 2;
            info.RelativeSize = () => {
                float sqrt = (float)Math.Ceiling (Math.Sqrt (colors.Count));
                return tileSize * sqrt;
            };
        }