1
0
Fork 0
This commit is contained in:
Wouter van Wageningen 2023-04-19 14:48:03 +00:00
parent 5dcaa15f32
commit 2a3c0d1126
2 changed files with 9 additions and 1 deletions

View file

@ -88,7 +88,9 @@ Defs.prototype.set = function (name, value) {
* @return {Defs} this - The Defs instance * @return {Defs} this - The Defs instance
*/ */
Defs.prototype.setIfUnset = function (name, value) { Defs.prototype.setIfUnset = function (name, value) {
// console.log({defsSetIfUnset:{name:name,value:value}})
if (typeof this.list[name] === 'undefined') this.list[name] = [value] if (typeof this.list[name] === 'undefined') this.list[name] = [value]
// console.log({list:JSON.parse(JSON.stringify(this.list))})
// console.log({defs:this.render()})
return this return this
} }

View file

@ -46,6 +46,8 @@ export function Svg(pattern) {
* @return {string} svg - The rendered SVG output * @return {string} svg - The rendered SVG output
*/ */
Svg.prototype.render = function () { Svg.prototype.render = function () {
// console.log('render')
this.idPrefix = this.pattern?.settings?.[0]?.idPrefix || 'fs-' this.idPrefix = this.pattern?.settings?.[0]?.idPrefix || 'fs-'
this.__runHooks('preRender') this.__runHooks('preRender')
if (!this.pattern.settings[0].embed) { if (!this.pattern.settings[0].embed) {
@ -214,8 +216,10 @@ Svg.prototype.__renderCircle = function (point) {
* @return {string} svg - The SVG markup for the defs block * @return {string} svg - The SVG markup for the defs block
*/ */
Svg.prototype.__renderDefs = function () { Svg.prototype.__renderDefs = function () {
console.log('__renderDefs')
let svg = '<defs>' let svg = '<defs>'
this.__indent() this.__indent()
// console.log({defs:this.defs.render()})
svg += this.__nl() + this.defs.render() svg += this.__nl() + this.defs.render()
this.__outdent() this.__outdent()
svg += this.__nl() + '</defs>' + this.__nl() svg += this.__nl() + '</defs>' + this.__nl()
@ -230,6 +234,7 @@ Svg.prototype.__renderDefs = function () {
* @return {string} svg - The SVG markup for the head section * @return {string} svg - The SVG markup for the head section
*/ */
Svg.prototype.__renderHead = function () { Svg.prototype.__renderHead = function () {
// console.log('__renderHead')
let svg = this.__renderStyle() let svg = this.__renderStyle()
svg += this.__renderDefs() svg += this.__renderDefs()
svg += this.__openGroup(this.idPrefix + 'container') svg += this.__openGroup(this.idPrefix + 'container')
@ -291,6 +296,7 @@ Svg.prototype.__renderPart = function (part) {
`${this.idPrefix}stack-${this.activeStack}-part-${part.name}`, `${this.idPrefix}stack-${this.activeStack}-part-${part.name}`,
part.attributes part.attributes
) )
svg += this.__openGroup(`${this.idPrefix}stack-${this.activeStack}-part-${part.name}`, part.defs)
for (let key in part.paths) { for (let key in part.paths) {
let path = part.paths[key] let path = part.paths[key]
if (!path.hidden) svg += this.__renderPath(path) if (!path.hidden) svg += this.__renderPath(path)