MCPcopy Create free account
hub / github.com/melonjs/melonJS / setLineDash

Method setLineDash

packages/melonjs/src/video/renderer.js:652–666  ·  view source on GitHub ↗

* Set the line dash pattern for stroke operations. * @param {number[]} segments - an array of numbers specifying distances to alternately draw a line and a gap. An empty array clears the dash pattern (solid lines). * @example * // draw a dashed line * renderer.setLineDash([10, 5]); * rende

(segments)

Source from the content-addressed store, hash-verified

650 * renderer.setLineDash([]);
651 */
652 setLineDash(segments) {
653 // skip allocation if the pattern hasn't changed
654 const current = this.renderState.lineDash;
655 if (
656 segments.length === current.length &&
657 segments.every((v, i) => {
658 return v === current[i];
659 })
660 ) {
661 return;
662 }
663 this.renderState.lineDash = segments.filter((v) => {
664 return Number.isFinite(v) && v >= 0;
665 });
666 }
667
668 /**
669 * Get the current line dash pattern.

Callers 5

bezier.spec.jsFile · 0.45
linedash.spec.jsFile · 0.45
drawFrameGraphFunction · 0.45
drawMethod · 0.45
drawMethod · 0.45

Calls 1

isFiniteMethod · 0.45

Tested by

no test coverage detected