void ChordLine::draw(QPainter* painter) const { qreal _spatium = spatium(); if (this->isStraight()) { painter->scale(_spatium, _spatium); painter->setPen(QPen(curColor(), .15, Qt::SolidLine)); painter->setBrush(Qt::NoBrush); QPainterPath pathOffset = path; float offset = 0.5; if (_chordLineType == ChordLineType::FALL) pathOffset.translate(offset, -offset); else if (_chordLineType == ChordLineType::DOIT) pathOffset.translate(offset, offset); else if (_chordLineType == ChordLineType::SCOOP) pathOffset.translate(-offset, offset); else if (_chordLineType == ChordLineType::PLOP) pathOffset.translate(-offset, -offset); painter->drawPath(pathOffset); painter->scale(1.0/_spatium, 1.0/_spatium); } else { painter->scale(_spatium, _spatium); painter->setPen(QPen(curColor(), .15, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter->setBrush(Qt::NoBrush); painter->drawPath(path); painter->scale(1.0/_spatium, 1.0/_spatium); } }
void SlurSegment::draw(QPainter* painter) const { QPen pen(curColor()); if (slurTie()->lineType() == 0) { painter->setBrush(QBrush(QColor(curColor()))); pen.setCapStyle(Qt::RoundCap); pen.setJoinStyle(Qt::RoundJoin); qreal lw = point(score()->styleS(ST_SlurEndWidth)); pen.setWidthF(lw); } else if (slurTie()->lineType() == 1) { painter->setBrush(Qt::NoBrush); qreal lw = point(score()->styleS(ST_SlurDottedWidth)); pen.setWidthF(lw); pen.setStyle(Qt::DotLine); } else if (slurTie()->lineType() == 2) { painter->setBrush(Qt::NoBrush); qreal lw = point(score()->styleS(ST_SlurDottedWidth)); pen.setWidthF(lw); pen.setStyle(Qt::DashLine); } painter->setPen(pen); painter->drawPath(path); }
void Ambitus::draw(QPainter* p) const { qreal _spatium = spatium(); qreal lw = lineWidth().val() * _spatium; p->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); drawSymbol(noteHead(), p, _topPos); drawSymbol(noteHead(), p, _bottomPos); if (_hasLine) p->drawLine(_line); // draw ledger lines (if not in a palette) if (segment() && track() > -1) { int tick = segment()->tick(); Staff* stf = score()->staff(staffIdx()); qreal lineDist = stf->lineDistance(tick); int numOfLines = stf->lines(tick); qreal step = lineDist * _spatium; qreal stepTolerance = step * 0.1; qreal ledgerOffset = score()->styleS(Sid::ledgerLineLength).val() * 0.5 * _spatium; p->setPen(QPen(curColor(), score()->styleS(Sid::ledgerLineWidth).val() * _spatium, Qt::SolidLine, Qt::RoundCap) ); if (_topPos.y()-stepTolerance <= -step) { qreal xMin = _topPos.x() - ledgerOffset; qreal xMax = _topPos.x() + headWidth() + ledgerOffset; for (qreal y = -step; y >= _topPos.y()-stepTolerance; y -= step) p->drawLine(QPointF(xMin, y), QPointF(xMax, y)); } if (_bottomPos.y()+stepTolerance >= numOfLines * step) { qreal xMin = _bottomPos.x() - ledgerOffset; qreal xMax = _bottomPos.x() + headWidth() + ledgerOffset; for (qreal y = numOfLines*step; y <= _bottomPos.y()+stepTolerance; y += step) p->drawLine(QPointF(xMin, y), QPointF(xMax, y)); } } }
void Stem::draw(QPainter* painter) const { Staff* st = staff(); bool useTab = st && st->isTabStaff(); if (useTab && st->staffType()->slashStyle()) return; qreal lw = lineWidth(); painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); painter->drawLine(line); if (!useTab) return; // TODO: adjust bounding rectangle in layout() for dots and for slash StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType()); qreal sp = spatium(); // slashed half note stem if (chord() && chord()->durationType().type() == TDuration::V_HALF && stt->minimStyle() == TAB_MINIM_SLASHED) { qreal wdt = sp * STAFFTYPE_TAB_SLASH_WIDTH; qreal sln = sp * STAFFTYPE_TAB_SLASH_SLANTY; qreal thk = sp * STAFFTYPE_TAB_SLASH_THICK; qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL; QPainterPath path; qreal y = stt->stemsDown() ? _len - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp : -_len + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp; for (int i = 0; i < 2; ++i) { path.moveTo( wdt*0.5-lw, y); // top-right corner path.lineTo( wdt*0.5-lw, y+thk); // bottom-right corner path.lineTo(-wdt*0.5, y+thk+sln);// bottom-left corner path.lineTo(-wdt*0.5, y+sln); // top-left corner path.closeSubpath(); y += displ; } // setbbox(path.boundingRect()); painter->setBrush(QBrush(curColor())); painter->setPen(Qt::NoPen); painter->drawPath(path); } // dots // NOT THE BEST PLACE FOR THIS? // with tablatures, dots are not drawn near 'notes', but near stems int nDots = chord()->dots(); if (nDots > 0) { qreal y = stemLen() - (stt->stemsDown() ? (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 ); symbols[score()->symIdx()][dotSym].draw(painter, magS(), QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots); } }
void Tremolo::draw(QPainter* painter) const { painter->setBrush(QBrush(curColor())); painter->setPen(Qt::NoPen); painter->drawPath(path); if ((parent() == 0) && !twoNotes()) { qreal x = 0.0; // bbox().width() * .25; QPen pen(curColor(), point(score()->styleS(ST_stemWidth))); painter->setPen(pen); qreal _spatium = spatium(); painter->drawLine(QLineF(x, -_spatium*.5, x, path.boundingRect().height() + _spatium)); } }
void Symbol::draw(QPainter* p) const { if (type() != NOTEDOT || !staff()->isTabStaff()) { p->setPen(curColor()); symbols[score()->symIdx()][_sym].draw(p, magS()); } }
void Stem::draw(QPainter* painter) const { bool useTab = false; Staff* st = staff(); if (st && st->isTabStaff()) { // stems used in palette do not have a staff if (st->staffType()->slashStyle()) return; useTab = true; } qreal lw = point(score()->styleS(ST_stemWidth)); painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); painter->drawLine(line); // NOT THE BEST PLACE FOR THIS? // with tablatures, dots are not drawn near 'notes', but near stems // TODO: adjust bounding rectangle in layout() if (useTab) { int nDots = chord()->dots(); if (nDots > 0) { qreal sp = spatium(); qreal y = stemLen() - ( ((StaffTypeTablature*)st->staffType())->stemsDown() ? (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 ); symbols[score()->symIdx()][dotSym].draw(painter, magS(), QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots); } } }
void TremoloBar::draw(QPainter* painter) const { if (staff() && !staff()->isTabStaff()) return; QPen pen(curColor(), _lw, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); painter->setPen(pen); painter->setBrush(QBrush(Qt::black)); qreal _spatium = spatium(); const TextStyle* st = &score()->textStyle(TEXT_STYLE_BENCH); QFont f = st->fontPx(_spatium); painter->setFont(f); int n = _points.size(); // int pt = 0; // qreal x = noteWidth; // qreal y = -_spatium * .8; // qreal x2, y2; for (int pt = 0; pt < n; ++pt) { if (pt == (n-1)) break; // int pitch = _points[pt].pitch; } //debug: painter->drawLine(QLineF(0.0, 0.0, _spatium*1.5, _spatium*3)); painter->drawLine(QLineF(_spatium*1.5, _spatium*3, _spatium*3, 0.0)); }
void TremoloBar::draw(QPainter* painter) const { if (staff() && !staff()->isTabStaff()) return; QPen pen(curColor(), _lw, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); painter->setPen(pen); painter->setBrush(QBrush(Qt::black)); qreal _spatium = spatium(); const TextStyle* st = &score()->textStyle(TextStyleType::BENCH); QFont f = st->fontPx(_spatium); painter->setFont(f); int n = _points.size(); int previousTime = _points[0].time; int previousPitch = _points[0].pitch; /* we place the tremolo bars starting slightly before the * notehead, and end it slightly after, drawing above the * note. The values specified in Guitar Pro are very large, too * large for the scale used in Musescore. We used the * timeFactor and pitchFactor below to reduce these values down * consistently to values that make sense to draw with the * Musescore scale. */ int timeFactor = 10; int pitchFactor = 25; for (int pt = 1; pt < n; ++pt) { painter->drawLine(QLineF(previousTime/timeFactor, -previousPitch/pitchFactor-_spatium*3, _points[pt].time/timeFactor, -_points[pt].pitch/pitchFactor-_spatium*3)); previousTime = _points[pt].time; previousPitch = _points[pt].pitch; } }
void Clef::draw(QPainter* painter) const { if (symId == SymId::noSym || (staff() && !staff()->staffType()->genClef())) return; painter->setPen(curColor()); drawSymbol(symId, painter); }
void NoteDot::draw(QPainter* p) const { if (!staff()->useTablature()) { p->setPen(curColor()); symbols[score()->symIdx()][dotSym].draw(p, magS()); } }
void Accidental::draw(QPainter* painter) const { if (staff() && staff()->isTabStaff()) //in TAB, accidentals are not shown return; painter->setPen(curColor()); foreach(const SymElement& e, el) score()->scoreFont()->draw(e.sym, painter, magS(), QPointF(e.x, 0.0)); }
// createTrans0 //--------------------------------------------------------------------------- void ColorTable::createTrans0( const int &color1Percent, const int &color2Percent, const char *filename) { init(256 * 256); if(FileSystem::exists(filename)) { try { loadTable(filename); return; } catch(Exception e) { LOG( ("Error while loading palette'%s': %s", filename, e.what()) ); } } LOG ( ("Creating colortable '%s'.", filename) ); float color1 = float(color1Percent) / 100.0f; float color2 = float(color2Percent) / 100.0f; //int totalColors = colorCount; //int curColorIndex = 0; //int num = 0; //int numInterval = (totalColors) / 100; // Since the file was not found, create the color tables and dump // it to a file. unsigned curOffset = 0; for (unsigned index = 0; index < 256; index++) { const RGBColor col = Palette::color[index]; for (unsigned indexPic = 0; indexPic < 256; indexPic++) { const RGBColor colPic = Palette::color[indexPic]; curOffset = (int(index) << 8) + indexPic; RGBColor curColor((int) (color1 * col.red + color2 * colPic.red), (int) (color1 * col.green + color2 * colPic.green), (int) (color1 * col.blue + color2 * colPic.blue)); // Makes the color table use color 0 as transparent. if (indexPic == 0) { setColor(curOffset, index); } else { setColor(curOffset, Palette::findNearestColor(curColor)); } } } try { saveTable(filename); } catch(Exception e) { LOG ( ("Caching of ColorTable '%s' failed: %s", filename, e.what()) ); } } // end ColorTable::createTrans0
//Alters p to be a particle newly produced by the fountain. void ParticleEngine::createParticle(Particle* p) { p->pos = Vector3D(0, 0, 0); p->velocity = curVelocity() + Vector3D(0.5f * randomFloat() - 0.25f, 0.5f * randomFloat() - 0.25f, 0.5f * randomFloat() - 0.25f); p->color = curColor(); p->timeAlive = 0; p->lifespan = randomFloat() + 1; }
void NoteDot::draw(QPainter* p) const { if (note() && note()->dotsHidden()) // don't draw dot if note is hidden return; if (!staff()->isTabStaff() || ((StaffTypeTablature*)staff()->staffType())->stemThrough()) { p->setPen(curColor()); drawSymbol(SymId::augmentationDot, p); } }
void ChordLine::draw(QPainter* painter) const { qreal _spatium = spatium(); painter->scale(_spatium, _spatium); painter->setPen(QPen(curColor(), .15, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter->setBrush(Qt::NoBrush); painter->drawPath(path); painter->scale(1.0/_spatium, 1.0/_spatium); }
void Lyrics::draw(QPainter* painter) const { Text::draw(painter); painter->setPen(curColor()); foreach(const Line* l, _separator) { painter->translate(l->pos()); l->draw(painter); painter->translate(-(l->pos())); }
void Arpeggio::draw(QPainter* p) const { qreal _spatium = spatium(); p->setPen(curColor()); qreal y1 = _spatium - _userLen1.val() * _spatium; qreal y2 = _height + (_userLen2.val() + .5) * _spatium; switch (subtype()) { case ARP_NORMAL: for (qreal y = y1; y < y2; y += _spatium) symbols[score()->symIdx()][arpeggioSym].draw(p, 1.0, QPointF(0.0, y)); break; case ARP_UP: symbols[score()->symIdx()][arpeggioarrowupSym].draw(p, 1.0, QPointF(0.0, y1)); for (qreal y = y1 + _spatium; y < y2; y += _spatium) symbols[score()->symIdx()][arpeggioSym].draw(p, 1.0, QPointF(0.0, y)); break; case ARP_DOWN: { qreal y = y1; for (; y < y2 - _spatium; y += _spatium) symbols[score()->symIdx()][arpeggioSym].draw(p, 1.0, QPointF(0.0, y)); symbols[score()->symIdx()][arpeggioarrowdownSym].draw(p, 1.0, QPointF(0.0, y)); } break; case ARP_BRACKET: { y1 = - _userLen1.val() * _spatium; y2 = _height + _userLen2.val() * _spatium; p->save(); p->setPen(QPen(curColor(), score()->styleS(ST_ArpeggioLineWidth).val() * _spatium, Qt::SolidLine, Qt::RoundCap)); qreal w = score()->styleS(ST_ArpeggioHookLen).val() * _spatium; p->drawLine(QLineF(0.0, y1, 0.0, y2)); p->drawLine(QLineF(0.0, y1, w, y1)); p->drawLine(QLineF(0.0, y2, w, y2)); p->restore(); } break; } }
void Symbol::draw(QPainter* p) const { if (!isNoteDot() || !staff()->isTabStaff(tick())) { p->setPen(curColor()); if (_scoreFont) _scoreFont->draw(_sym, p, magS(), QPointF()); else drawSymbol(_sym, p); } }
void Symbol::draw(QPainter* p) const { if (type() != NOTEDOT || !staff()->isTabStaff()) { p->setPen(curColor()); if (_scoreFont) _scoreFont->draw(_sym, p, magS(), QPointF()); else drawSymbol(_sym, p); } }
void Bracket::draw(QPainter* painter) const { if (h2 == 0.0) return; if (bracketType() == BRACKET_BRACE) { painter->setPen(Qt::NoPen); painter->setBrush(QBrush(curColor())); painter->drawPath(path); } else if (bracketType() == BRACKET_NORMAL) { qreal h = 2 * h2; qreal _spatium = spatium(); qreal w = score()->styleS(ST_bracketWidth).val() * _spatium; QPen pen(curColor(), w, Qt::SolidLine, Qt::FlatCap); painter->setPen(pen); qreal bd = _spatium * .25; painter->drawLine(QLineF(0.0, -bd, 0.0, h + bd)); qreal x = -w * .5; qreal y1 = -bd; qreal y2 = h + bd; drawSymbol(SymId::bracketTop, painter, QPointF(x, y1)); drawSymbol(SymId::bracketBottom, painter, QPointF(x, y2)); } else if (bracketType() == BRACKET_SQUARE) { qreal h = 2 * h2; qreal _spatium = spatium(); qreal w = score()->styleS(ST_staffLineWidth).val() * _spatium; QPen pen(curColor(), w, Qt::SolidLine, Qt::SquareCap); painter->setPen(pen); painter->drawLine(QLineF(0.0, 0.0, 0.0, h)); painter->drawLine(QLineF(0.0, 0.0, w + .5 *_spatium, 0.0)); painter->drawLine(QLineF(0.0, h , w + .5 *_spatium, h)); } else if (bracketType() == BRACKET_LINE) { qreal h = 2 * h2; qreal _spatium = spatium(); qreal w = 0.67 * score()->styleS(ST_bracketWidth).val() * _spatium; QPen pen(curColor(), w, Qt::SolidLine, Qt::FlatCap); painter->setPen(pen); qreal bd = _spatium * .25; painter->drawLine(QLineF(0.0, -bd, 0.0, h + bd)); } }
void Tremolo::draw(QPainter* painter) const { if (tremoloType() == TremoloType::BUZZ_ROLL) { painter->setPen(curColor()); drawSymbol(SymId::buzzRoll, painter); } else { painter->setBrush(QBrush(curColor())); painter->setPen(Qt::NoPen); painter->drawPath(path); } if ((parent() == 0) && !twoNotes()) { qreal x = 0.0; // bbox().width() * .25; QPen pen(curColor(), point(score()->styleS(Sid::stemWidth))); painter->setPen(pen); qreal _spatium = spatium() * mag(); painter->drawLine(QLineF(x, -_spatium*.5, x, path.boundingRect().height() + _spatium)); } }
void NoteDot::draw(QPainter* p) const { if (note() && note()->dotsHidden()) // don't draw dot if note is hidden return; int tick = note()->chord()->tick(); if (!staff()->isTabStaff(tick) || staff()->staffType(tick)->stemThrough()) { p->setPen(curColor()); drawSymbol(SymId::augmentationDot, p); } }
void Clef::addElement(Element* e, qreal x, qreal y) { e->setMag(mag()); e->setColor(curColor()); e->layout(); e->setPos(x, y); e->setParent(this); e->setSelected(selected()); elements.push_back(e); }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && ( !((StaffTypeTablature*)staff()->staffType())->showRests() || ((StaffTypeTablature*)staff()->staffType())->genDurations()) ) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->multiMeasure()) { Measure* m = measure(); int n = m->multiMeasure(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = _spatium; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); QFont font(fontId2font(0)); painter->setFont(font); QFontMetricsF fm(font); y = -_spatium * .5 - fm.ascent(); painter->drawText(QRectF(center(x1, x2), y, .0, .0), Qt::AlignHCenter|Qt::TextDontClip, QString("%1").arg(n)); } else { qreal mag = magS(); symbols[score()->symIdx()][_sym].draw(painter, mag); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symbols[score()->symIdx()][_sym].width(mag) + point(score()->styleS(ST_dotNoteDistance)) * i; symbols[score()->symIdx()][dotSym].draw(painter, mag, QPointF(x, y)); } } } }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && (!staff()->staffType()->showRests() || staff()->staffType()->genDurations())) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->isMMRest()) { //only on voice 1 if ((track() % VOICES) != 0) return; Measure* m = measure(); int n = m->mmRestCount(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = 0.0; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); painter->setFont(score()->scoreFont()->font()); QFontMetricsF fm(score()->scoreFont()->font()); QString s = toTimeSigString(QString("%1").arg(n)); y = -_spatium * 1.5 - staff()->height() *.5; qreal x = center(x1, x2); x -= symBbox(s).width() * .5; drawSymbols(s, painter, QPointF(x, y)); } else { drawSymbol(_sym, painter); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symWidth(_sym) + point(score()->styleS(StyleIdx::dotNoteDistance)) * i; drawSymbol(SymId::augmentationDot, painter, QPointF(x, y)); } } } }
void Accidental::draw(QPainter* painter) const { // don't show accidentals for tab or slash notation if ((staff() && staff()->isTabStaff()) || (note() && note()->fixed())) { return; } painter->setPen(curColor()); foreach(const SymElement& e, el) score()->scoreFont()->draw(e.sym, painter, magS(), QPointF(e.x, 0.0)); }
void KeySig::draw(QPainter* p) const { p->setPen(curColor()); for (const KeySym& ks: _sig.keySymbols()) drawSymbol(ks.sym, p, QPointF(ks.pos.x(), ks.pos.y())); if (!parent() && isCustom() && _sig.keySymbols().isEmpty()) { // atonal key signature - draw something for palette p->setPen(Qt::gray); drawSymbol(SymId::timeSigX, p, QPointF(symWidth(SymId::timeSigX) * -0.5, 2.0 * spatium())); } }
void Accidental::draw(QPainter* painter) const { Note* note = static_cast<Note*>(parent()); if ( note == 0 || !note->staff()->useTablature() ) { //in TAB, accidentals are not shown qreal m = magS(); if (_small) m *= score()->styleD(ST_smallNoteMag); painter->setPen(curColor()); foreach(const SymElement& e, el) symbols[score()->symIdx()][e.sym].draw(painter, m, QPointF(e.x, 0.0)); }
void Accidental::draw(QPainter* painter) const { if (staff() && staff()->isTabStaff()) //in TAB, accidentals are not shown return; qreal m = magS(); if (_small) m *= score()->styleD(ST_smallNoteMag); painter->setPen(curColor()); foreach(const SymElement& e, el) symbols[score()->symIdx()][e.sym].draw(painter, m, QPointF(e.x, 0.0)); }