MCPcopy Index your code
hub / github.com/clips/pattern / text

Function text

pattern/canvas.js:2446–2464  ·  view source on GitHub ↗
(str, x, y, options)

Source from the content-addressed store, hash-verified

2444}
2445
2446function text(str, x, y, options) {
2447 /* Draws the string at the given position.
2448 * Lines of text will be split at \n.
2449 * The text will be displayed with the current state font(), fontsize(), fontweight().
2450 */
2451 var a1 = _colorMixin(options);
2452 var a2 = _fontMixin(options);
2453 if (a1[0] && a1[0].a > 0) {
2454 var f = a1[0]._get();
2455 if (_ctx.state._fill != f) {
2456 _ctx.fillStyle = _ctx.state._fill = f;
2457 }
2458 _ctx_font(a2[0], a2[1], a2[2]);
2459 var lines = str.toString().split("\n");
2460 for (var i=0; i<lines.length; i++) {
2461 _ctx.fillText(lines[i], x, y + i*a2[1]*a2[3]);
2462 }
2463 }
2464}
2465
2466function textmetrics(str, options) {
2467 /* Returns array [width, height] for the given text.

Callers

nothing calls this directly

Calls 4

_colorMixinFunction · 0.85
_fontMixinFunction · 0.85
_ctx_fontFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…