Created
August 23, 2012 17:19
-
-
Save matthiasak/3438934 to your computer and use it in GitHub Desktop.
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
// text coords | |
texts.push({x: Building.width/2, y:Building.length/2, obj: {name:Building.name}, attr:{'font-size':'15px'} }); | |
texts.push({x: Building.width/2, y:Building.length, obj: _.find(Building.surfaces, function(el){ return el.swa; }), attr:{'font-size':'10px'} }); | |
texts.push({x: 0, y:Building.length/2, obj: _.find(Building.surfaces, function(el){ return el.ewb; }), attr:{'font-size':'10px', rotate:-90} }); | |
texts.push({x: Building.width/2, y:0, obj: _.find(Building.surfaces, function(el){ return el.swc; }), attr:{'font-size':'10px'} }); | |
texts.push({x: Building.width, y:Building.length/2, obj: _.find(Building.surfaces, function(el){ return el.ewd; }), attr:{'font-size':'10px', rotate:90} }); | |
/// later used in | |
_.forEach(polygonCollection.texts, function(text){ | |
var path = raphael.text(text.x, text.y, text.obj.name).attr(text.attr || {}), | |
_minX = text.x - padding, | |
_maxX = text.x + padding, | |
_minY = text.y - padding, | |
_maxY = text.x + padding; | |
if(text.attr.rotate){ | |
path.rotate(text.attr.rotate); | |
} | |
bounds.minX = _minX < bounds.minX ? _minX : bounds.minX; | |
bounds.maxX = _maxX > bounds.maxX ? _maxX : bounds.maxX; | |
bounds.minY = _minY < bounds.minY ? _minY : bounds.minY; | |
bounds.maxY = _maxY > bounds.maxY ? _maxY : bounds.maxY; | |
set.push(path); | |
}) | |
var width = Math.abs(bounds.maxX - bounds.minX), | |
height = Math.abs(bounds.maxY - bounds.minY), | |
scale = (canvasWidth*0.99)/width, | |
newWidth = width * scale, | |
newHeight = height * scale, | |
transform = { | |
x : (newWidth - width)/2 + width, | |
y : (newHeight - height)/2 + height | |
}, | |
transformString = "s"+scale+","+scale+",0,0t1,1"; | |
set.transform(transformString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment