예제 #1
0
        public List <EPointF> GenerateLocList(string text, int maxWidth, float kerningStrength, float lineSpacingFactor)
        {
            List <EPointF> locs = new List <EPointF>();

            //TODO: only works for certain charsets!!
            int bottomOfG  = this['g'].SourceRectangle.Height - this['g'].Offset.Y;
            int topOfAuml  = -this['Å'].Offset.Y;
            int lineHeight = bottomOfG - topOfAuml;

            lineHeight = (int)(lineSpacingFactor * lineHeight);

            float   extraSpace = 0;
            EPointF loc        = new EPointF(0, 0);

            for (int i = 0; i < text.Length; i++)
            {
                PicRef p = this[text[i]];
                if (p == null)
                {
                    loc.X += 0.2f * lineHeight; //TODO: define space width!
                    locs.Add(loc.Copy());
                    loc.X += extraSpace;
                }
                else
                {
                    int kern = 0;
                    if (i > 0)
                    {
                        kern = this.GetKerningBetween(text[i - 1], text[i]);
                    }
                    loc.X -= kerningStrength * kern;
                    locs.Add(loc.Copy());
                    loc.X += (int)p.SourceRectangle.Width + extraSpace;
                }
                if (loc.X > maxWidth)
                {
                    //TODO: go back to last whitespace or hypen and break there
                    loc.Y += lineHeight;
                    loc.X  = 0;
                }
            }
            return(locs);
        }
예제 #2
0
        public override void Start()
        {
            if (_lastStart == -1)
            {
                _lastStart = DateTime.Now.Ticks;
            }

            long diff   = DateTime.Now.Ticks - _lastStart;
            int  msDiff = (int)diff / 10000;

            //Random rnd = new Random();
            //this.Interactor.Loc = new EPointF(rnd.Next(400), rnd.Next(400));
            this.Interactor.Loc = _lastLoc.Copy();
            _lastLoc.X         += msDiff / 5;

            if (_lastLoc.X > 600)
            {
                _lastLoc.X = 100;
            }
            _lastStart = DateTime.Now.Ticks;
        }
예제 #3
0
        public List<EPointF> GenerateLocList(string text, int maxWidth, float kerningStrength, float lineSpacingFactor)
        {
            List<EPointF> locs = new List<EPointF>();

            //TODO: only works for certain charsets!!
            int bottomOfG = this['g'].SourceRectangle.Height-this['g'].Offset.Y;
            int topOfAuml = -this['Å'].Offset.Y;
            int lineHeight = bottomOfG-topOfAuml;
            lineHeight=(int)(lineSpacingFactor*lineHeight);

            float extraSpace = 0;
            EPointF loc = new EPointF(0,0);
            for (int i=0; i<text.Length;i++)
            {
                PicRef p = this[text[i]];
                if (p == null)
                {
                    loc.X += 0.2f * lineHeight; //TODO: define space width!
                    locs.Add(loc.Copy());
                    loc.X += extraSpace;
                }
                else
                {
                    int kern = 0;
                    if (i > 0)
                        kern = this.GetKerningBetween(text[i - 1], text[i]);
                    loc.X -= kerningStrength * kern;
                    locs.Add(loc.Copy());
                    loc.X += (int)p.SourceRectangle.Width + extraSpace;
                }
                if (loc.X > maxWidth)
                {
                    //TODO: go back to last whitespace or hypen and break there
                    loc.Y+=lineHeight;
                    loc.X = 0;
                }
            }
            return locs;
        }