1
0
Fork 0

feat(core): Add support for injecting sample styles

This allows you to override the (path) styles when we
sample the pattern by setting `settings.sample.styles`.

This closes #380
This commit is contained in:
Joost De Cock 2020-05-30 14:02:37 +02:00
parent 803dd112ed
commit 673743faae
2 changed files with 7 additions and 5 deletions

View file

@ -182,7 +182,9 @@ Pattern.prototype.sampleRun = function (parts, anchors, run, runs, extraClass =
for (let j in this.parts[i].paths) {
parts[i].paths[j + '_' + run] = this.parts[i].paths[j]
.clone()
.attr('style', sampleStyle(run, runs))
.attr('style', sampleStyle(run, runs, this.settings.sample.styles))
.attr('data-sample-run', run)
.attr('data-sample-runs', runs)
if (this.parts[i].points.anchor)
parts[i].paths[j + '_' + run] = parts[i].paths[j + '_' + run].translate(dx, dy)
if (extraClass !== false) parts[i].paths[j + '_' + run].attributes.add('class', extraClass)