Fix reference box render glitches [#33]

This commit is contained in:
David Evans 2018-02-03 12:45:48 +00:00
parent 37fb6b9139
commit ec24433366
13 changed files with 134 additions and 43 deletions

View File

@ -3936,6 +3936,7 @@ define('sequence/components/BaseComponent',[],() => {
render(/*stage, { render(/*stage, {
topY, topY,
primaryY, primaryY,
fillLayer,
blockLayer, blockLayer,
shapeLayer, shapeLayer,
labelLayer, labelLayer,
@ -4149,12 +4150,23 @@ define('sequence/components/Block',[
const agentInfoL = env.agentInfos.get(left); const agentInfoL = env.agentInfos.get(left);
const agentInfoR = env.agentInfos.get(right); const agentInfoR = env.agentInfos.get(right);
blockInfo.hold.appendChild(config.boxRenderer({ let shapes = config.boxRenderer({
x: agentInfoL.x, x: agentInfoL.x,
y: blockInfo.startY, y: blockInfo.startY,
width: agentInfoR.x - agentInfoL.x, width: agentInfoR.x - agentInfoL.x,
height: env.primaryY - blockInfo.startY, height: env.primaryY - blockInfo.startY,
})); });
if(!shapes.shape) {
shapes = {shape: shapes};
}
blockInfo.hold.appendChild(shapes.shape);
if(shapes.fill) {
env.fillLayer.appendChild(shapes.fill);
}
if(shapes.mask) {
env.maskLayer.appendChild(shapes.mask);
}
return env.primaryY + config.margin.bottom + env.theme.actionMargin; return env.primaryY + config.margin.bottom + env.theme.actionMargin;
} }
@ -5686,6 +5698,7 @@ define('sequence/Renderer',[
'maskUnits': 'userSpaceOnUse', 'maskUnits': 'userSpaceOnUse',
}); });
this.maskReveal = svg.make('rect', {'fill': '#FFFFFF'}); this.maskReveal = svg.make('rect', {'fill': '#FFFFFF'});
this.backgroundFills = svg.make('g');
this.agentLines = svg.make('g', { this.agentLines = svg.make('g', {
'mask': 'url(#' + this.namespace + 'LineMask)', 'mask': 'url(#' + this.namespace + 'LineMask)',
}); });
@ -5695,6 +5708,7 @@ define('sequence/Renderer',[
this.base.appendChild(this.buildMetadata()); this.base.appendChild(this.buildMetadata());
this.base.appendChild(this.themeDefs); this.base.appendChild(this.themeDefs);
this.base.appendChild(this.defs); this.base.appendChild(this.defs);
this.base.appendChild(this.backgroundFills);
this.base.appendChild(this.agentLines); this.base.appendChild(this.agentLines);
this.base.appendChild(this.blocks); this.base.appendChild(this.blocks);
this.base.appendChild(this.actionShapes); this.base.appendChild(this.actionShapes);
@ -5900,6 +5914,7 @@ define('sequence/Renderer',[
const env = { const env = {
topY, topY,
primaryY: topY + topShift, primaryY: topY + topShift,
fillLayer: this.backgroundFills,
blockLayer: this.blocks, blockLayer: this.blocks,
shapeLayer: this.actionShapes, shapeLayer: this.actionShapes,
labelLayer: this.actionLabels, labelLayer: this.actionLabels,
@ -6034,6 +6049,7 @@ define('sequence/Renderer',[
this.currentHighlight = -1; this.currentHighlight = -1;
svg.empty(this.defs); svg.empty(this.defs);
svg.empty(this.mask); svg.empty(this.mask);
svg.empty(this.backgroundFills);
svg.empty(this.agentLines); svg.empty(this.agentLines);
svg.empty(this.blocks); svg.empty(this.blocks);
svg.empty(this.actionShapes); svg.empty(this.actionShapes);
@ -6611,6 +6627,21 @@ define('sequence/themes/BaseTheme',[
}, attrs)); }, attrs));
}; };
BaseTheme.renderRef = (options, position) => {
return {
shape: SVGShapes.renderBox(Object.assign({}, options, {
'fill': 'none',
}), position),
mask: SVGShapes.renderBox(Object.assign({}, options, {
'fill': '#000000',
'stroke': 'none',
}), position),
fill: SVGShapes.renderBox(Object.assign({}, options, {
'stroke': 'none',
}), position),
};
};
BaseTheme.WavePattern = class WavePattern { BaseTheme.WavePattern = class WavePattern {
constructor(width, height) { constructor(width, height) {
if(Array.isArray(height)) { if(Array.isArray(height)) {
@ -7063,7 +7094,7 @@ define('sequence/themes/Basic',[
top: 0, top: 0,
bottom: 0, bottom: 0,
}, },
boxRenderer: SVGShapes.renderBox.bind(null, { boxRenderer: BaseTheme.renderRef.bind(null, {
'fill': '#FFFFFF', 'fill': '#FFFFFF',
'stroke': '#000000', 'stroke': '#000000',
'stroke-width': 1.5, 'stroke-width': 1.5,
@ -7451,7 +7482,7 @@ define('sequence/themes/Monospace',[
top: 0, top: 0,
bottom: 0, bottom: 0,
}, },
boxRenderer: SVGShapes.renderBox.bind(null, { boxRenderer: BaseTheme.renderRef.bind(null, {
'fill': '#FFFFFF', 'fill': '#FFFFFF',
'stroke': '#000000', 'stroke': '#000000',
'stroke-width': 2, 'stroke-width': 2,
@ -7839,7 +7870,7 @@ define('sequence/themes/Chunky',[
top: 0, top: 0,
bottom: 0, bottom: 0,
}, },
boxRenderer: SVGShapes.renderBox.bind(null, { boxRenderer: BaseTheme.renderRef.bind(null, {
'fill': '#FFFFFF', 'fill': '#FFFFFF',
'stroke': '#000000', 'stroke': '#000000',
'stroke-width': 4, 'stroke-width': 4,
@ -8969,7 +9000,7 @@ define('sequence/themes/Sketch',[
return shape; return shape;
} }
renderBox({x, y, width, height}, {fill = null, thick = false} = {}) { boxNodes({x, y, width, height}) {
const lT = this.lineNodes( const lT = this.lineNodes(
{x, y}, {x, y},
{x: x + width, y}, {x: x + width, y},
@ -8991,12 +9022,14 @@ define('sequence/themes/Sketch',[
{var1: 0, var2: 0.3, move: false} {var1: 0, var2: 0.3, move: false}
); );
const shape = svg.make('path', Object.assign({ return lT.nodes + lR.nodes + lB.nodes + lL.nodes;
'd': lT.nodes + lR.nodes + lB.nodes + lL.nodes, }
renderBox(position, {fill = null, thick = false} = {}) {
return svg.make('path', Object.assign({
'd': this.boxNodes(position),
'fill': fill || '#FFFFFF', 'fill': fill || '#FFFFFF',
}, thick ? PENCIL.thick : PENCIL.normal)); }, thick ? PENCIL.thick : PENCIL.normal));
return shape;
} }
renderNote({x, y, width, height}) { renderNote({x, y, width, height}) {
@ -9235,18 +9268,26 @@ define('sequence/themes/Sketch',[
}, PENCIL.normal)); }, PENCIL.normal));
} }
renderRefBlock({x, y, width, height}) { renderRefBlock(position) {
return this.renderBox( const nodes = this.boxNodes(position);
{x, y, width, height}, return {
{fill: '#FFFFFF', thick: true} shape: svg.make('path', Object.assign({
); 'd': nodes,
'fill': 'none',
}, PENCIL.thick)),
mask: svg.make('path', {
'd': nodes,
'fill': '#000000',
}),
fill: svg.make('path', {
'd': nodes,
'fill': '#FFFFFF',
}),
};
} }
renderBlock({x, y, width, height}) { renderBlock(position) {
return this.renderBox( return this.renderBox(position, {fill: 'none', thick: true});
{x, y, width, height},
{fill: 'none', thick: true}
);
} }
renderTag({x, y, width, height}) { renderTag({x, y, width, height}) {

File diff suppressed because one or more lines are too long

View File

@ -125,6 +125,7 @@ define([
'maskUnits': 'userSpaceOnUse', 'maskUnits': 'userSpaceOnUse',
}); });
this.maskReveal = svg.make('rect', {'fill': '#FFFFFF'}); this.maskReveal = svg.make('rect', {'fill': '#FFFFFF'});
this.backgroundFills = svg.make('g');
this.agentLines = svg.make('g', { this.agentLines = svg.make('g', {
'mask': 'url(#' + this.namespace + 'LineMask)', 'mask': 'url(#' + this.namespace + 'LineMask)',
}); });
@ -134,6 +135,7 @@ define([
this.base.appendChild(this.buildMetadata()); this.base.appendChild(this.buildMetadata());
this.base.appendChild(this.themeDefs); this.base.appendChild(this.themeDefs);
this.base.appendChild(this.defs); this.base.appendChild(this.defs);
this.base.appendChild(this.backgroundFills);
this.base.appendChild(this.agentLines); this.base.appendChild(this.agentLines);
this.base.appendChild(this.blocks); this.base.appendChild(this.blocks);
this.base.appendChild(this.actionShapes); this.base.appendChild(this.actionShapes);
@ -339,6 +341,7 @@ define([
const env = { const env = {
topY, topY,
primaryY: topY + topShift, primaryY: topY + topShift,
fillLayer: this.backgroundFills,
blockLayer: this.blocks, blockLayer: this.blocks,
shapeLayer: this.actionShapes, shapeLayer: this.actionShapes,
labelLayer: this.actionLabels, labelLayer: this.actionLabels,
@ -473,6 +476,7 @@ define([
this.currentHighlight = -1; this.currentHighlight = -1;
svg.empty(this.defs); svg.empty(this.defs);
svg.empty(this.mask); svg.empty(this.mask);
svg.empty(this.backgroundFills);
svg.empty(this.agentLines); svg.empty(this.agentLines);
svg.empty(this.blocks); svg.empty(this.blocks);
svg.empty(this.actionShapes); svg.empty(this.actionShapes);

View File

@ -48,6 +48,7 @@ define(() => {
render(/*stage, { render(/*stage, {
topY, topY,
primaryY, primaryY,
fillLayer,
blockLayer, blockLayer,
shapeLayer, shapeLayer,
labelLayer, labelLayer,

View File

@ -165,12 +165,23 @@ define([
const agentInfoL = env.agentInfos.get(left); const agentInfoL = env.agentInfos.get(left);
const agentInfoR = env.agentInfos.get(right); const agentInfoR = env.agentInfos.get(right);
blockInfo.hold.appendChild(config.boxRenderer({ let shapes = config.boxRenderer({
x: agentInfoL.x, x: agentInfoL.x,
y: blockInfo.startY, y: blockInfo.startY,
width: agentInfoR.x - agentInfoL.x, width: agentInfoR.x - agentInfoL.x,
height: env.primaryY - blockInfo.startY, height: env.primaryY - blockInfo.startY,
})); });
if(!shapes.shape) {
shapes = {shape: shapes};
}
blockInfo.hold.appendChild(shapes.shape);
if(shapes.fill) {
env.fillLayer.appendChild(shapes.fill);
}
if(shapes.mask) {
env.maskLayer.appendChild(shapes.mask);
}
return env.primaryY + config.margin.bottom + env.theme.actionMargin; return env.primaryY + config.margin.bottom + env.theme.actionMargin;
} }

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -5,5 +5,6 @@ define([], [
'Asynchronous.svg', 'Asynchronous.svg',
'Block.svg', 'Block.svg',
'Reference.svg', 'Reference.svg',
'ReferenceLayering.svg',
'Markdown.svg', 'Markdown.svg',
]); ]);

View File

@ -124,6 +124,21 @@ define([
}, attrs)); }, attrs));
}; };
BaseTheme.renderRef = (options, position) => {
return {
shape: SVGShapes.renderBox(Object.assign({}, options, {
'fill': 'none',
}), position),
mask: SVGShapes.renderBox(Object.assign({}, options, {
'fill': '#000000',
'stroke': 'none',
}), position),
fill: SVGShapes.renderBox(Object.assign({}, options, {
'stroke': 'none',
}), position),
};
};
BaseTheme.WavePattern = class WavePattern { BaseTheme.WavePattern = class WavePattern {
constructor(width, height) { constructor(width, height) {
if(Array.isArray(height)) { if(Array.isArray(height)) {

View File

@ -237,7 +237,7 @@ define([
top: 0, top: 0,
bottom: 0, bottom: 0,
}, },
boxRenderer: SVGShapes.renderBox.bind(null, { boxRenderer: BaseTheme.renderRef.bind(null, {
'fill': '#FFFFFF', 'fill': '#FFFFFF',
'stroke': '#000000', 'stroke': '#000000',
'stroke-width': 1.5, 'stroke-width': 1.5,

View File

@ -248,7 +248,7 @@ define([
top: 0, top: 0,
bottom: 0, bottom: 0,
}, },
boxRenderer: SVGShapes.renderBox.bind(null, { boxRenderer: BaseTheme.renderRef.bind(null, {
'fill': '#FFFFFF', 'fill': '#FFFFFF',
'stroke': '#000000', 'stroke': '#000000',
'stroke-width': 4, 'stroke-width': 4,

View File

@ -244,7 +244,7 @@ define([
top: 0, top: 0,
bottom: 0, bottom: 0,
}, },
boxRenderer: SVGShapes.renderBox.bind(null, { boxRenderer: BaseTheme.renderRef.bind(null, {
'fill': '#FFFFFF', 'fill': '#FFFFFF',
'stroke': '#000000', 'stroke': '#000000',
'stroke-width': 2, 'stroke-width': 2,

View File

@ -546,7 +546,7 @@ define([
return shape; return shape;
} }
renderBox({x, y, width, height}, {fill = null, thick = false} = {}) { boxNodes({x, y, width, height}) {
const lT = this.lineNodes( const lT = this.lineNodes(
{x, y}, {x, y},
{x: x + width, y}, {x: x + width, y},
@ -568,12 +568,14 @@ define([
{var1: 0, var2: 0.3, move: false} {var1: 0, var2: 0.3, move: false}
); );
const shape = svg.make('path', Object.assign({ return lT.nodes + lR.nodes + lB.nodes + lL.nodes;
'd': lT.nodes + lR.nodes + lB.nodes + lL.nodes, }
renderBox(position, {fill = null, thick = false} = {}) {
return svg.make('path', Object.assign({
'd': this.boxNodes(position),
'fill': fill || '#FFFFFF', 'fill': fill || '#FFFFFF',
}, thick ? PENCIL.thick : PENCIL.normal)); }, thick ? PENCIL.thick : PENCIL.normal));
return shape;
} }
renderNote({x, y, width, height}) { renderNote({x, y, width, height}) {
@ -812,18 +814,26 @@ define([
}, PENCIL.normal)); }, PENCIL.normal));
} }
renderRefBlock({x, y, width, height}) { renderRefBlock(position) {
return this.renderBox( const nodes = this.boxNodes(position);
{x, y, width, height}, return {
{fill: '#FFFFFF', thick: true} shape: svg.make('path', Object.assign({
); 'd': nodes,
'fill': 'none',
}, PENCIL.thick)),
mask: svg.make('path', {
'd': nodes,
'fill': '#000000',
}),
fill: svg.make('path', {
'd': nodes,
'fill': '#FFFFFF',
}),
};
} }
renderBlock({x, y, width, height}) { renderBlock(position) {
return this.renderBox( return this.renderBox(position, {fill: 'none', thick: true});
{x, y, width, height},
{fill: 'none', thick: true}
);
} }
renderTag({x, y, width, height}) { renderTag({x, y, width, height}) {