コード例 #1
0
        private IntRect GlyphArea;      // Total glyph-occupied region - doesn't change

        public GlyphStream(GlyphStreamConfig settings, Rectangle workingArea)
        {
            _workingArea = workingArea;
            _glyphConfig = settings.GlyphConfig;

            MAX_GLYPHS       = settings.MaxGlyphs;
            MIN_GLYPHS       = settings.MinGlyphs;
            MAX_MOVEMENTRATE = settings.MaxMovementRate;
            MIN_MOVEMENTRATE = settings.MinMovementRate;
            MIN_GLYPHSCALE   = settings.MinGlyphScale;
            MAX_GLYPHSCALE   = settings.MaxGlyphScale;
            MARGIN_SCALE     = settings.MarginScale;

            movementRate = GetRandom.Float(MIN_MOVEMENTRATE, MAX_MOVEMENTRATE);
            var numberOfGlyphs = GetRandom.Int(MIN_GLYPHS, MAX_GLYPHS);

            scale = GetRandom.Float(MIN_GLYPHSCALE, MAX_GLYPHSCALE);
            displayDurationMultipier = GetRandom.Float(0.5f / numberOfGlyphs, 1f);

            GlyphPosition = new Vector2f(
                GetRandom.Int((int)-GlyphSize.X, (int)(_workingArea.Width + GlyphSize.X)),
                GetRandom.Int((int)-GlyphSize.Y, (int)(_workingArea.Height + GlyphSize.Y)));

            ////TODO: refactor to a debugGlpyhStream class
            //if (Config.IsDebugGlyphStreams)
            //{
            //    // Just for debugging
            //    numberOfGlyphs = 6;
            //    GlyphPosition = new Vector2f(10,10);
            //    movementRate = 80;
            //    scale = 0.2f;
            //    displayDurationMultipier = 0.5f;
            //}

            _glyphs = new List <Glyph>();
            for (int i = 0; i < numberOfGlyphs; i++)
            {
                var y = GlyphPosition.Y + (i * Glyph.GLYPH_HEIGHT * scale * MARGIN_SCALE);

                if (y + Glyph.GLYPH_HEIGHT < 0)
                {
                    continue;
                }
                if (y > workingArea.Height)
                {
                    continue;
                }

                _glyphs.Add(new Glyph(new Vector2f(GlyphPosition.X, y), scale, _glyphConfig));
            }

            MaskPosition = new Vector2f(GlyphPosition.X, GlyphPosition.Y - MaskSize.Y);

            GlyphArea = new IntRect(
                (int)GlyphPosition.X,
                (int)GlyphPosition.Y,
                (int)GlyphSize.X,
                (int)GlyphSize.Y + (int)(GlyphSize.Y * MARGIN_SCALE * (_glyphs.Count - 1f))
                );
        }
コード例 #2
0
        public GlyphStream(GlyphStreamConfig settings, Rectangle workingArea)
        {
            _workingArea = workingArea;
            _glyphConfig = settings.GlyphConfig;

            MAX_GLYPHS = settings.MaxGlyphs;
            MIN_GLYPHS = settings.MinGlyphs;
            MAX_MOVEMENTRATE = settings.MaxMovementRate;
            MIN_MOVEMENTRATE = settings.MinMovementRate;
            MIN_GLYPHSCALE = settings.MinGlyphScale;
            MAX_GLYPHSCALE = settings.MaxGlyphScale;
            MARGIN_SCALE = settings.MarginScale;

            movementRate = GetRandom.Float(MIN_MOVEMENTRATE, MAX_MOVEMENTRATE);
            var numberOfGlyphs = GetRandom.Int(MIN_GLYPHS, MAX_GLYPHS);
            scale = GetRandom.Float(MIN_GLYPHSCALE, MAX_GLYPHSCALE);
            displayDurationMultipier = GetRandom.Float(0.5f / numberOfGlyphs, 1f);

            GlyphPosition = new Vector2f(
                GetRandom.Int((int)-GlyphSize.X, (int) (_workingArea.Width + GlyphSize.X)),
                GetRandom.Int((int)-GlyphSize.Y, (int)(_workingArea.Height + GlyphSize.Y)));

            ////TODO: refactor to a debugGlpyhStream class
            //if (Config.IsDebugGlyphStreams)
            //{
            //    // Just for debugging
            //    numberOfGlyphs = 6;
            //    GlyphPosition = new Vector2f(10,10);
            //    movementRate = 80;
            //    scale = 0.2f;
            //    displayDurationMultipier = 0.5f;
            //}

            _glyphs = new List<Glyph>();
            for (int i = 0; i < numberOfGlyphs; i++)
            {
                var y = GlyphPosition.Y + (i * Glyph.GLYPH_HEIGHT * scale * MARGIN_SCALE);

                if (y + Glyph.GLYPH_HEIGHT < 0) continue;
                if (y > workingArea.Height) continue;

                _glyphs.Add(new Glyph(new Vector2f(GlyphPosition.X, y), scale, _glyphConfig));
            }

            MaskPosition = new Vector2f(GlyphPosition.X, GlyphPosition.Y - MaskSize.Y);

            GlyphArea = new IntRect(
                (int)GlyphPosition.X,
                (int)GlyphPosition.Y,
                (int)GlyphSize.X,
                (int)GlyphSize.Y + (int)(GlyphSize.Y * MARGIN_SCALE * (_glyphs.Count - 1f))
                );
        }
コード例 #3
0
        public GlyphStreamNoise(GlyphStreamConfig settings, Rectangle workingArea)
        {
            _glyphs      = new List <Glyph>();
            _workingArea = workingArea;

            _movementRate = GetRandom.Float(settings.MinMovementRate, settings.MaxMovementRate);
            _scale        = GetRandom.Float(settings.MinGlyphScale, settings.MaxGlyphScale);
            var   glyphCount = GetRandom.Int(settings.MinGlyphs, settings.MaxGlyphs);
            float displayDurationMultipier = GetRandom.Float(0.5f, 2f);

            var glyphSize = new Vector2f(Glyph.GLYPH_WIDTH * _scale, Glyph.GLYPH_HEIGHT * _scale);

            _maskSize = new Vector2f(glyphSize.X, glyphSize.Y * _glyphs.Count * displayDurationMultipier); // TODO: incorporate margin

            GlyphPosition = new Vector2f(
                GetRandom.Int((int)-glyphSize.X, (int)(_workingArea.Width + glyphSize.X)),
                GetRandom.Int((int)-glyphSize.Y, (int)(_workingArea.Height + glyphSize.Y)));

            GlyphArea = new IntRect(
                (int)GlyphPosition.X,
                (int)GlyphPosition.Y,
                (int)glyphSize.X,
                (int)glyphSize.Y + (int)(glyphSize.Y * settings.MarginScale * (_glyphs.Count - 1f))
                );

            for (int i = 0; i < glyphCount; i++)
            {
                var y = GlyphPosition.Y + (i * Glyph.GLYPH_HEIGHT * _scale * settings.MarginScale);

                if (y + Glyph.GLYPH_HEIGHT < 0)
                {
                    continue;
                }
                if (y > workingArea.Height)
                {
                    continue;
                }

                _glyphs.Add(new Glyph(new Vector2f(GlyphPosition.X, y), _scale, settings.GlyphConfig));
            }

            MaskPosition = new Vector2f(GlyphPosition.X, GlyphPosition.Y - _maskSize.Y);
        }
コード例 #4
0
        private Vector2f MaskPosition; // Stream position - scrolls down the screen

        #endregion Fields

        #region Constructors

        public GlyphStreamNoise(GlyphStreamConfig settings, Rectangle workingArea)
        {
            _glyphs = new List<Glyph>();
            _workingArea = workingArea;

            _movementRate = GetRandom.Float(settings.MinMovementRate, settings.MaxMovementRate);
            _scale = GetRandom.Float(settings.MinGlyphScale, settings.MaxGlyphScale);
            var glyphCount = GetRandom.Int(settings.MinGlyphs, settings.MaxGlyphs);
            float displayDurationMultipier = GetRandom.Float(0.5f, 2f);

            var glyphSize = new Vector2f(Glyph.GLYPH_WIDTH * _scale, Glyph.GLYPH_HEIGHT * _scale);

            _maskSize = new Vector2f(glyphSize.X, glyphSize.Y * _glyphs.Count * displayDurationMultipier); // TODO: incorporate margin

            GlyphPosition = new Vector2f(
                GetRandom.Int((int)-glyphSize.X, (int)(_workingArea.Width + glyphSize.X)),
                GetRandom.Int((int)-glyphSize.Y, (int)(_workingArea.Height + glyphSize.Y)));

            GlyphArea = new IntRect(
                (int)GlyphPosition.X,
                (int)GlyphPosition.Y,
                (int)glyphSize.X,
                (int)glyphSize.Y + (int)(glyphSize.Y * settings.MarginScale * (_glyphs.Count - 1f))
                );

            for (int i = 0; i < glyphCount; i++)
            {
                var y = GlyphPosition.Y + (i * Glyph.GLYPH_HEIGHT * _scale * settings.MarginScale);

                if (y + Glyph.GLYPH_HEIGHT < 0) continue;
                if (y > workingArea.Height) continue;

                _glyphs.Add(new Glyph(new Vector2f(GlyphPosition.X, y), _scale, settings.GlyphConfig));
            }

            MaskPosition = new Vector2f(GlyphPosition.X, GlyphPosition.Y - _maskSize.Y);
        }