RigidShape.prototype.collidedRectCirc = function(rect1Shape, circ2Shape) {
var rect1Pos = rect1Shape.getPosition();
var circ2Pos = circ2Shape.getPosition();
if (rect1Shape.containsPos(circ2Pos) || (circ2Shape.containsPos(rect1Pos))) {
return true;
}
var vFrom1to2 = [0, 0];
vec2.subtract(vFrom1to2, circ2Pos, rect1Pos);
var vec = vec2.clone(vFrom1to2);
var alongX = rect1Shape.getWidth() / 2;
var alongY = rect1Shape.getHeight() / 2;
vec[0] = this.clamp(vec[0], -alongX, alongX);
vec[1] = this.clamp(vec[1], -alongY, alongY);
var normal = [0, 0];
vec2.subtract(normal, vFrom1to2, vec);
var distSqr = vec2.squaredLength(normal);
var rSqr = circ2Shape.getRadius() * circ2Shape.getRadius();
return (distSqr < rSqr);
};
function setObjNewCoordinates(сoords) {
// отправляем эти сoords куда-нибудь по аякс
}
<input type="text" size="30" maxlength="10">
p {
width: 200px; /* ширина блока */
white-space: initial;
overflow: hidden;
}
pname.innerHTML = goods[nomer].name.substr(0, 50);