MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / paint

Function paint

packages/alphatab/src/rendering/glyphs/TieGlyph.ts:252–301  ·  view source on GitHub ↗
(cx: number, cy: number, canvas: ICanvas)

Source from the content-addressed store, hash-verified

250 }
251
252 public override paint(cx: number, cy: number, canvas: ICanvas): void {
253 if (!this._shouldPaint) {
254 return;
255 }
256
257 const isDown = this.tieDirection === BeamDirection.Down;
258
259 if (this.shouldDrawBendSlur()) {
260 TieGlyph.drawBendSlur(
261 canvas,
262 cx + this._startX,
263 cy + this._startY,
264 cx + this._endX,
265 cy + this._endY,
266 isDown,
267 this.renderer.smuflMetrics.tieHeight
268 );
269 } else {
270 TieGlyph.paintTie(
271 canvas,
272 1,
273 cx + this._startX,
274 cy + this._startY,
275 cx + this._endX,
276 cy + this._endY,
277 isDown,
278 this._tieHeight,
279 this.renderer.smuflMetrics.tieMidpointThickness
280 );
281 }
282
283 if (this._resolvedLabelCount > 0) {
284 const ta = canvas.textAlign;
285 const tb = canvas.textBaseline;
286 canvas.textAlign = TextAlign.Center;
287 canvas.textBaseline = TextBaseline.Top;
288 const res = this.renderer.resources;
289 let lastElement = -1;
290 for (let i = 0; i < this._resolvedLabelCount; i++) {
291 const label = this._resolvedLabels[i];
292 if (label.element !== lastElement) {
293 canvas.font = res.getFontForNotationElement(label.element);
294 lastElement = label.element;
295 }
296 canvas.fillText(label.text, cx + label.x, cy + label.y + this._labelBaselineOffset);
297 }
298 canvas.textAlign = ta;
299 canvas.textBaseline = tb;
300 }
301 }
302
303 /**
304 * Returns the labels to paint along this slur, or `null` when there

Callers

nothing calls this directly

Calls 4

drawBendSlurMethod · 0.80
fillTextMethod · 0.65
shouldDrawBendSlurMethod · 0.45

Tested by

no test coverage detected