Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript (http://www.flasher.ru/forum/forumdisplay.php?f=5)
-   -   Пунктирная линия ????? (http://www.flasher.ru/forum/showthread.php?t=64592)

kalenik 07.11.2004 16:12

Пунктирная линия ?????
 
Застрял на мелочи! Никак не могу нарисовать (программно) пунктирную линию - в lineTo и стиле линии че-то я такого свойства не увидел :-((. Если кто знает помогите! Буду очень благодарен!!!!

Sh@man 07.11.2004 16:16

Вложений: 1
Вот держи

kalenik 07.11.2004 19:00

Спасибо!!! Но я ничего не понял! Нельзя ли по-понятнее, плиз.
Поясню: у меня есть два мувиклипа. Я хочу, чтобы между ними всегда рисовалась пунктирная линия, показывающая расстояние между ними. Ну, скажем, это что-то подобное графику - для указания кординаты точки используют перпендикуляры (пунктирные линии) на оси координат.

Штрек 07.11.2004 22:59

Цитата:

Оригинал написал(а) kalenik
Спасибо!!! Но я ничего не понял! Нельзя ли по-понятнее, плиз.
.

Для непонятливых разжевываю -

MovieClip.prototype.dashTo = function(startx, starty, endx, endy, len, gap) {
// ==============
// mc.dashTo() - by Ric Ewing (ric@formequalsfunction.com) - version 1.2 - 5.3.2002
//
// startx, starty = beginning of dashed line
// endx, endy = end of dashed line
// len = length of dash
// gap = length of gap between dashes
// ==============
//
// if too few arguments, bail
if (arguments.length < 6) {
return false;
}
trace(startx)
// init vars
var seglength, deltax, deltay, segs, cx, cy;
// calculate the legnth of a segment
seglength = len + gap;
// calculate the length of the dashed line
deltax = endx - startx;
deltay = endy - starty;
delta = Math.sqrt((deltax * deltax) + (deltay * deltay));
// calculate the number of segments needed
segs = Math.floor(Math.abs(delta / seglength));
// get the angle of the line in radians
radians = Math.atan2(deltay,deltax);
// start the line here
cx = startx;
cy = starty;
// add these to cx, cy to get next seg start
deltax = Math.cos(radians)*seglength;
deltay = Math.sin(radians)*seglength;
// loop through each seg
for (var n = 0; n < segs; n++) {
this.moveTo(cx,cy);
this.lineTo(cx+Math.cos(radians)*len,cy+Math.sin(radians)*len);
cx += deltax;
cy += deltay;
}
// handle last segment as it is likely to be partial
this.moveTo(cx,cy);
delta = Math.sqrt((endx-cx)*(endx-cx)+(endy-cy)*(endy-cy));
if(delta>len){
// segment ends in the gap, so draw a full dash
this.lineTo(cx+Math.cos(radians)*len,cy+Math.sin(radians)*len);
} else if(delta>0) {
// segment is shorter than dash so only draw what is needed
this.lineTo(cx+Math.cos(radians)*delta,cy+Math.sin(radians)*delta);
}
// move the pen to the end position
this.moveTo(endx,endy);
};
_root.lineStyle(2,0x6688AA);
_root.dashTo(100,100,300,200,4,4)

nuran 10.11.2004 05:30

Извращенец! :D


Часовой пояс GMT +4, время: 08:25.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.