Beispiel #1
0
        private LedgerlineBlockMetrics CreateUpperLedgerlineBlock(List<HeadMetrics> topDownHeadsMetrics, float limbLength, float strokeWidth)
        {
            Debug.Assert(topDownHeadsMetrics != null);
            #region upper ledgerline block
            float minLeftX = float.MaxValue;
            float maxRightX = float.MinValue;
            foreach(HeadMetrics head in topDownHeadsMetrics)
            {
                if(head.OriginY <= _gap * 0.75F)
                {
                    minLeftX = minLeftX < head.LeftStemX ? minLeftX : head.LeftStemX;
                    maxRightX = maxRightX > head.RightStemX ? maxRightX : head.RightStemX;
                }
            }
            float left = minLeftX - limbLength;
            float right = maxRightX + limbLength;
            Metrics topHeadMetrics = topDownHeadsMetrics[0];
            LedgerlineBlockMetrics upperLedgerlineBlockMetrics = null;
            if(topHeadMetrics.OriginY < -(_gap * 0.75F))
            {
                upperLedgerlineBlockMetrics = new LedgerlineBlockMetrics(left, right, strokeWidth); // contains no ledgerlines

                float topLedgerlineY = topHeadMetrics.OriginY;
                if((topLedgerlineY % _gap) < 0)
                {
                    topLedgerlineY += (_gap / 2F);
                }
                for(float y = topLedgerlineY; y < 0; y += _gap)
                {
                    upperLedgerlineBlockMetrics.AddLedgerline(y, _gap);
                }
            }
            #endregion upper ledgerline block
            return upperLedgerlineBlockMetrics;
        }
Beispiel #2
0
        private LedgerlineBlockMetrics CreateLowerLedgerlineBlock(List<HeadMetrics> topDownHeadsMetrics, float limbLength, float strokeWidth)
        {
            Debug.Assert(topDownHeadsMetrics != null);
            float minLeftX = float.MaxValue;
            float maxRightX = float.MinValue;
            foreach(HeadMetrics head in topDownHeadsMetrics)
            {
                if(head.OriginY >= _gap * _nStafflines)
                {
                    minLeftX = minLeftX < head.LeftStemX ? minLeftX : head.LeftStemX;
                    maxRightX = maxRightX > head.RightStemX ? maxRightX : head.RightStemX;
                }
            }
            float leftX = minLeftX - limbLength;
            float rightX = maxRightX + limbLength;
            Metrics bottomHeadMetrics = topDownHeadsMetrics[topDownHeadsMetrics.Count - 1];
            LedgerlineBlockMetrics lowerLedgerlineBlockMetrics = null;
            if(bottomHeadMetrics.OriginY > (_gap * 4.75))
            {
                lowerLedgerlineBlockMetrics = new LedgerlineBlockMetrics(leftX, rightX, strokeWidth); // contains no ledgerlines

                float bottomLedgerlineY = bottomHeadMetrics.OriginY;
                if((bottomLedgerlineY % _gap) > 0)
                {
                    bottomLedgerlineY -= (_gap / 2F);
                }
                for(float y = (_gap * _nStafflines); y <= bottomLedgerlineY; y += _gap)
                {
                    lowerLedgerlineBlockMetrics.AddLedgerline(y, _gap);
                }
            }
            return lowerLedgerlineBlockMetrics;
        }
Beispiel #3
0
        public RestMetrics(Graphics graphics, RestSymbol rest, float gap, int numberOfStafflines, float ledgerlineStrokeWidth)
            : base(rest.DurationClass, true, rest.FontHeight)
        {
            float dy = 0;

            if (numberOfStafflines > 1)
            {
                dy = gap * (numberOfStafflines / 2);
            }

            _top            = _top + dy;
            _bottom        += dy;
            _originY       += dy;          // the staffline on which the rest is aligned
            _ledgerlineStub = gap * 0.75F;
            Move((Left - Right) / 2F, 0F); // centre the glyph horizontally
            switch (rest.DurationClass)
            {
            case DurationClass.breve:
            case DurationClass.semibreve:
                Move(gap * -0.25F, 0F);
                if (numberOfStafflines == 1)
                {
                    Move(0F, gap);
                }
                _ledgerline = new LedgerlineBlockMetrics(Left - _ledgerlineStub, Right + _ledgerlineStub, ledgerlineStrokeWidth);
                _ledgerline.AddLedgerline(_originY - gap, 0F);
                _ledgerline.Move(gap * 0.17F, 0F);
                _top -= (gap * 1.5F);
                break;

            case DurationClass.minim:
                Move(gap * 0.18F, 0);
                _ledgerline = new LedgerlineBlockMetrics(Left - _ledgerlineStub, Right + _ledgerlineStub - (gap * 0.3F), ledgerlineStrokeWidth);
                _ledgerline.AddLedgerline(_originY, 0F);
                _bottom += (gap * 1.5F);
                break;

            case DurationClass.quaver:
                _top    -= gap * 0.5F;
                _bottom += gap * 0.5F;
                break;

            case DurationClass.semiquaver:
                _top    -= gap * 0.5F;
                _bottom += gap * 0.5F;
                break;

            case DurationClass.threeFlags:
                _top    -= gap * 0.5F;
                _right  += gap * 0.2F;
                _bottom += gap * 0.5F;
                _left   -= gap * 0.2F;
                break;

            case DurationClass.fourFlags:
                _top     -= gap * 0.5F;
                _right   += gap * 0.1F;
                _bottom  += gap * 1.25F;
                _left    -= gap * 0.1F;
                _originY += gap;
                break;

            case DurationClass.fiveFlags:
                _top     -= gap * 1.5F;
                _right   += gap * 0.2F;
                _bottom  += gap * 1.25F;
                _left    -= gap * 0.2F;
                _originY += gap;
                break;
            }
        }
Beispiel #4
0
        public RestMetrics(Graphics graphics, RestSymbol rest, float gap, int numberOfStafflines, float ledgerlineStrokeWidth)
            : base(rest.DurationClass, true, rest.FontHeight)
        {
            float dy = 0;
            if(numberOfStafflines > 1)
                dy = gap * (numberOfStafflines / 2);

            _top = _top + dy;
            _bottom += dy;
            _originY += dy; // the staffline on which the rest is aligned
            _ledgerlineStub = gap * 0.75F;
            Move((Left - Right) / 2F, 0F); // centre the glyph horizontally
            switch(rest.DurationClass)
            {
                case DurationClass.breve:
                case DurationClass.semibreve:
                    Move(gap * -0.25F, 0F);
                    if(numberOfStafflines == 1)
                        Move(0F, gap);
                    _ledgerline = new LedgerlineBlockMetrics(Left - _ledgerlineStub, Right + _ledgerlineStub, ledgerlineStrokeWidth);
                    _ledgerline.AddLedgerline(_originY - gap, 0F);
                    _ledgerline.Move(gap * 0.17F, 0F);
                    _top -= (gap * 1.5F);
                    break;
                case DurationClass.minim:
                    Move(gap * 0.18F, 0);
                    _ledgerline = new LedgerlineBlockMetrics(Left - _ledgerlineStub, Right + _ledgerlineStub - (gap * 0.3F), ledgerlineStrokeWidth);
                    _ledgerline.AddLedgerline(_originY, 0F);
                    _bottom += (gap * 1.5F);
                    break;
                case DurationClass.quaver:
                    _top -= gap * 0.5F;
                    _bottom += gap * 0.5F;
                    break;
                case DurationClass.semiquaver:
                    _top -= gap * 0.5F;
                    _bottom += gap * 0.5F;
                    break;
                case DurationClass.threeFlags:
                    _top -= gap * 0.5F;
                    _right += gap * 0.2F;
                    _bottom += gap * 0.5F;
                    _left -= gap * 0.2F;
                    break;
                case DurationClass.fourFlags:
                    _top -= gap * 0.5F;
                    _right += gap * 0.1F;
                    _bottom += gap * 1.25F;
                    _left -= gap * 0.1F;
                    _originY += gap;
                    break;
                case DurationClass.fiveFlags:
                    _top -= gap * 1.5F;
                    _right += gap * 0.2F;
                    _bottom += gap * 1.25F;
                    _left -= gap * 0.2F;
                    _originY += gap;
                    break;
            }
        }
Beispiel #5
0
        public RestMetrics(Graphics graphics, RestSymbol rest, double gap, int numberOfStafflines, double ledgerlineStrokeWidth)
            : base(rest.DurationClass, rest.FontHeight, CSSObjectClass.rest)
        {
            double dy = 0;

            if (numberOfStafflines > 1)
            {
                dy = gap * (numberOfStafflines / 2);
            }

            _top            = _top + dy;
            _bottom        += dy;
            _originY       += dy;         // the staffline on which the rest is aligned
            _ledgerlineStub = gap * 0.75;
            Move((Left - Right) / 2, 0F); // centre the glyph horizontally
            CSSObjectClass llBlockClass = CSSObjectClass.ledgerlines;

            switch (rest.DurationClass)
            {
            case DurationClass.breve:
            case DurationClass.semibreve:
                Move(gap * -0.25, 0F);
                if (numberOfStafflines == 1)
                {
                    Move(0, gap);
                }
                _ledgerlineBlockMetrics = new LedgerlineBlockMetrics(Left - _ledgerlineStub, Right + _ledgerlineStub, ledgerlineStrokeWidth, llBlockClass);
                _ledgerlineBlockMetrics.AddLedgerline(_originY - gap, 0F);
                _ledgerlineBlockMetrics.Move(gap * 0.17, 0F);
                _top -= (gap * 1.5F);
                break;

            case DurationClass.minim:
                Move(gap * 0.18, 0);
                _ledgerlineBlockMetrics = new LedgerlineBlockMetrics(Left - _ledgerlineStub, Right + _ledgerlineStub - (gap * 0.3F), ledgerlineStrokeWidth, llBlockClass);
                _ledgerlineBlockMetrics.AddLedgerline(_originY, 0F);
                _bottom += (gap * 1.5F);
                break;

            case DurationClass.quaver:
                _top    -= gap * 0.5;
                _bottom += gap * 0.5;
                break;

            case DurationClass.semiquaver:
                _top    -= gap * 0.5;
                _bottom += gap * 0.5;
                break;

            case DurationClass.threeFlags:
                _top    -= gap * 0.5;
                _right  += gap * 0.2;
                _bottom += gap * 0.5;
                _left   -= gap * 0.2;
                break;

            case DurationClass.fourFlags:
                _top     -= gap * 0.5;
                _right   += gap * 0.1;
                _bottom  += gap * 1.25;
                _left    -= gap * 0.1;
                _originY += gap;
                break;

            case DurationClass.fiveFlags:
                _top     -= gap * 1.5;
                _right   += gap * 0.2;
                _bottom  += gap * 1.25;
                _left    -= gap * 0.2;
                _originY += gap;
                break;
            }
        }