Re: Как определить область круга ? (SVG)
On 19.08.2010 07:01, Игорь Чумак wrote:
R1=sqr([x1-x2]^2+[y1-y2]^2)
if ((R-R1)>0) {}
Спасибо за формулу.
Предварительный вариант js функции в конце письма.
Работает до первого скалирования.
Видимо, надо переписать с учетом рекомендации:
http://www.mail-archive.com/svg-developers@yahoogroups.com/msg11439.html
"evt.clientX wouldn't work with viewBoxes and after zooming in. You
should use SVGLocatable.getScreenCTM( ) for calculating the
coordinates."
----------------------------------------------------------------
function check_region(MouseUpEvent, element_id){
var r1 = document.getElementById(element_id).getAttribute("r");
var x1 = document.getElementById(element_id).getAttribute("cx");
var y1 = document.getElementById(element_id).getAttribute("cy");
var x2 = MouseUpEvent.clientX;
var y2 = MouseUpEvent.clientY;
r1 = r1*r1;
r2 = [x1-x2]*[x1-x2]+[y1-y2]*[y1-y2];
if ((r1-r2)>0) {alert('ok')}}
--
Sincerely,
Nicholas
Reply to: