-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from VisBOL/resolve-bugs
Resolve bugs
- Loading branch information
Showing
23 changed files
with
458 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
var Vec2 = require('../../lib/geom/vec2') | ||
var Rect = require('../../lib/geom/rect') | ||
|
||
function renderGlyph(design, glyphObject, boxSize) { | ||
|
||
var largeCircle = design.surface.circle(boxSize.x/2); | ||
var largeCircle2 = design.surface.circle(boxSize.x/2); | ||
var smallCircle = design.surface.circle(boxSize.x/4); | ||
var smallCircle2 = design.surface.circle(boxSize.x/4); | ||
var smallBox = design.surface.rect(boxSize.x/6,boxSize.y/9); | ||
var smallBox2 = design.surface.rect(boxSize.x/3,boxSize.y/7); | ||
var group = design.surface.group(); | ||
|
||
largeCircle.attr('stroke','black'); | ||
largeCircle.attr('fill', glyphObject.color || '#F1948A'); | ||
largeCircle.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
largeCircle.attr('stroke-linejoin', 'round'); | ||
largeCircle.attr({ cx: boxSize.x/2, cy: boxSize.y/2}) | ||
largeCircle.radius(20) | ||
|
||
largeCircle2.attr('stroke','black'); | ||
largeCircle2.attr('fill', glyphObject.color || '#F1948A'); | ||
largeCircle2.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
largeCircle2.attr('stroke-linejoin', 'round'); | ||
largeCircle2.attr({ cx: 0, cy: boxSize.y/2}) | ||
largeCircle2.radius(20) | ||
|
||
smallCircle.attr('stroke','black'); | ||
smallCircle.attr('fill', glyphObject.color || '#F1948A'); | ||
smallCircle.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
smallCircle.attr('stroke-linejoin', 'round'); | ||
smallCircle.attr({ cx: boxSize.x/5, cy: boxSize.y/1.1 }) | ||
|
||
smallCircle2.attr('stroke','black'); | ||
smallCircle2.attr('fill', glyphObject.color || '#F1948A'); | ||
smallCircle2.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
smallCircle2.attr('stroke-linejoin', 'round'); | ||
smallCircle2.attr({ cx: -boxSize.x/4, cy: boxSize.y/1.1 }) | ||
|
||
smallBox.attr('stroke','dark gray'); | ||
smallBox.attr('fill', glyphObject.color || '#F1948A'); | ||
smallBox.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
smallBox.attr('stroke-linejoin', 'round'); | ||
smallBox.attr({ x: boxSize.x/4.8, y: boxSize.y/1.32 }) | ||
|
||
smallBox2.attr('stroke','dark gray'); | ||
smallBox2.attr('fill', glyphObject.color || '#F1948A'); | ||
smallBox2.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
smallBox2.attr('stroke-linejoin', 'round'); | ||
smallBox2.attr({ x: -boxSize.x/3.5, y: boxSize.y/1.35 }) | ||
|
||
group.add(largeCircle); | ||
group.add(smallCircle); | ||
group.add(smallBox); | ||
group.add(largeCircle2); | ||
group.add(smallCircle2); | ||
group.add(smallBox2); | ||
|
||
|
||
if(glyphObject.uri){ | ||
group.attr('data-uri', glyphObject.uri) | ||
} | ||
|
||
return { | ||
glyph: group, | ||
backboneOffset: boxSize.y | ||
}; | ||
} | ||
|
||
module.exports = { | ||
|
||
render: renderGlyph | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
|
||
var Vec2 = require('../../lib/geom/vec2') | ||
var Rect = require('../../lib/geom/rect') | ||
|
||
function createGeometry(boxSize) { | ||
|
||
function createTangentLine(pointA, pointB) { | ||
|
||
var lengthX = pointB.x - pointA.x; | ||
var lengthY = pointB.y - pointA.y; | ||
|
||
return { | ||
length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)), | ||
angle: Math.atan2(lengthY, lengthX) | ||
}; | ||
|
||
} | ||
|
||
function createControlPoint(current, previous, next) { | ||
|
||
const smoothing = 0.2; | ||
var p = (previous === null) ? current : previous; | ||
var n = (next === null) ? current: next; | ||
|
||
var line = createTangentLine(n,p); | ||
|
||
return { | ||
x: current.x + (Math.cos(line.angle + Math.PI) * line.length * smoothing), | ||
y: current.y + (Math.sin(line.angle + Math.PI) * line.length * smoothing) | ||
}; | ||
} | ||
// Coordinates of Points to Connect | ||
var x = boxSize.x; | ||
var y = boxSize.y; | ||
var stepSize = 3*x/14 | ||
var pointA = Vec2(5*x/4, y); | ||
var pointB = Vec2(pointA.x - stepSize, 3*y/4); | ||
var pointC = Vec2(pointA.x - 2*stepSize, y ); | ||
var pointD = Vec2(pointA.x - 3*stepSize, 3*y/4); | ||
var pointE = Vec2(pointA.x - 4*stepSize, y ); | ||
var pointF = Vec2(pointA.x - 5*stepSize, 3*y/4); | ||
var pointG = Vec2(pointA.x - 6*stepSize, y ); | ||
var pointH = Vec2(pointA.x - 7*stepSize, 3*y/4); | ||
|
||
|
||
//Coordinates of Control Points | ||
var controlPoint1 = createControlPoint(pointA, pointB, null); | ||
var controlPoint2 = createControlPoint(pointB, pointC, pointA); | ||
var controlPoint3 = createControlPoint(pointC, pointD, pointB ); | ||
var controlPoint4 = createControlPoint(pointD, pointE, pointC); | ||
var controlPoint5 = createControlPoint(pointE, pointF, pointD); | ||
var controlPoint6 = createControlPoint(pointF, pointG, pointE); | ||
var controlPoint7 = createControlPoint(pointG, pointH, pointF); | ||
var controlPoint8 = createControlPoint(pointH, null, pointG); | ||
|
||
|
||
|
||
return { | ||
|
||
|
||
//coordinate of pick | ||
pointA: pointA, | ||
pointB: pointB, | ||
pointC: pointC, | ||
pointD: pointD, | ||
pointE: pointE, | ||
pointF: pointF, | ||
pointG: pointG, | ||
pointH: pointH, | ||
|
||
//coordiantes of control ponits | ||
controlPoint1: controlPoint1, | ||
controlPoint2: controlPoint2, | ||
controlPoint3: controlPoint3, | ||
controlPoint4: controlPoint4, | ||
controlPoint5: controlPoint5, | ||
controlPoint6: controlPoint6, | ||
controlPoint7: controlPoint7, | ||
controlPoint8: controlPoint8, | ||
|
||
|
||
|
||
}; | ||
} | ||
function renderGlyph(design, glyphObject, boxSize) { | ||
|
||
var largeCircle = design.surface.circle(boxSize.x/2); | ||
var smallCircle = design.surface.circle(boxSize.x/4); | ||
var smallBox = design.surface.rect(boxSize.x/3,boxSize.y/5.5); | ||
var group = design.surface.group(); | ||
|
||
largeCircle.attr('stroke','black'); | ||
largeCircle.attr('fill', glyphObject.color || '#F1948A'); | ||
largeCircle.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
largeCircle.attr('stroke-linejoin', 'round'); | ||
largeCircle.attr({ cx: boxSize.x/2, cy: 4*boxSize.y/5}) | ||
largeCircle.radius(20) | ||
|
||
smallCircle.attr('stroke','black'); | ||
smallCircle.attr('fill', glyphObject.color || '#F1948A'); | ||
smallCircle.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
smallCircle.attr('stroke-linejoin', 'round'); | ||
smallCircle.attr({ cx: boxSize.x/5, cy: 1.15*boxSize.y }) | ||
|
||
smallBox.attr('stroke','dark gray'); | ||
smallBox.attr('fill', glyphObject.color || '#F1948A'); | ||
smallBox.attr('stroke-width', glyphObject.thickness ||'2px'); | ||
smallBox.attr('stroke-linejoin', 'round'); | ||
smallBox.attr({ x: boxSize.x/6, y: 0.98*boxSize.y }) | ||
|
||
var geom = createGeometry(boxSize); | ||
|
||
|
||
var path = [ | ||
'M' + Vec2.toPathString(geom.pointA), | ||
'C' + Vec2.toPathString(geom.controlPoint1) + ' ' + Vec2.toPathString(geom.controlPoint2) + ' ' + Vec2.toPathString(geom.pointB), | ||
'S' + Vec2.toPathString(geom.controlPoint3) + ' ' + Vec2.toPathString(geom.pointC), | ||
'S' + Vec2.toPathString(geom.controlPoint4) + ' ' + Vec2.toPathString(geom.pointD), | ||
'S' + Vec2.toPathString(geom.controlPoint5) + ' ' + Vec2.toPathString(geom.pointE), | ||
'S' + Vec2.toPathString(geom.controlPoint6) + ' ' + Vec2.toPathString(geom.pointF), | ||
'S' + Vec2.toPathString(geom.controlPoint7) + ' ' + Vec2.toPathString(geom.pointG), | ||
'S' + Vec2.toPathString(geom.controlPoint8) + ' ' + Vec2.toPathString(geom.pointH), | ||
|
||
].join(''); | ||
|
||
var glyph = design.surface.path(path); | ||
var group = design.surface.group() | ||
|
||
glyph.attr('stroke', glyphObject.color || 'purple'); | ||
glyph.attr('stroke-width', glyphObject.thickness || '3px'); | ||
glyph.attr('stroke-linecap', 'round'); | ||
glyph.attr('fill-opacity', 0); | ||
|
||
group.add(largeCircle); | ||
group.add(smallCircle); | ||
group.add(smallBox); | ||
group.add(glyph); | ||
|
||
boundingBox = design.surface.rect(boxSize.x, boxSize.y); | ||
boundingBox.attr('fill-opacity', 0); | ||
|
||
if(glyphObject.uri) { | ||
boundingBox.attr('data-uri', glyphObject.uri); | ||
} | ||
group.add(boundingBox); | ||
|
||
return { | ||
glyph: group, | ||
backboneOffset: 1.2 * boxSize.y | ||
}; | ||
} | ||
|
||
module.exports = { | ||
|
||
render: renderGlyph | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.