<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; JavaScript: поворот элемента страницы на определенный угол]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=2432</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=2432&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «JavaScript: поворот элемента страницы на определенный угол».]]></description>
		<lastBuildDate>Fri, 02 Nov 2012 17:36:29 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: JavaScript: поворот элемента страницы на определенный угол]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=65364#p65364</link>
			<description><![CDATA[<p>Простенькие часы, набросанные на скорую руку с использованием -ms-Transform:rotate работали только в ИЕ9 (hta, поэтому без кроссбраузерных изысков). Знакомые попросили сделать и для ИЕ8, в связи с чем разыскал этот пример. Оказалось, что matrix вращает весьма забавно: верхняя и левая граница не смещаются, поэтому вращение получается, как если кубик крутить в углу коробки. Вот &quot;часы&quot;, в которых, кроме матричного фильтра используется смещение абсолютно позиционируемых элементов. Забавно, но в ИЕ9 рендерится гораздо хуже, чем в ИЕ8 (видимо, чтобы все переходили на -ms-Transform), на более старых не проверял. clock.hta:</p><div class="codebox"><pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
  &lt;title&gt;Sergeant&lt;/title&gt;
  &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=8&quot; /&gt;
  &lt;script language=&quot;JScript&quot;&gt;
    moveTo(screen.availWidth-250,0);
    self.resizeTo(250,250);
  &lt;/script&gt;
  &lt;hta:application
   applicationName=&quot;matrix-clock-IXc&quot;
   border=&quot;none&quot;
   caption=&quot;no&quot;
   icon=&quot;%SystemRoot%/system32/twext.dll&quot;
   innerBorder=&quot;no&quot;
   scroll=&quot;no&quot;
   selection=&quot;no&quot;
   singleInstance=&quot;yes&quot;
   version=&quot;0.5&quot;
   /&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;inactivecaption&quot;&gt;&lt;/body&gt;
&lt;script&gt;
  var
   g=Math.PI/180,
   h={        //hands
    h:{c:&#039;windowtext&#039;,i:&#039;dh&#039;,l:50,w:5},
    m:{c:&#039;windowtext&#039;,i:&#039;dm&#039;,l:80,w:3},
    s:{c:&#039;crimson&#039;,i:&#039;ds&#039;,l:100,w:1}
   },
   m=new Date(),
   r=100,    //radius
   t,
   x=~~document.documentElement.clientWidth/2,    //center position x
   y=~~document.documentElement.clientHeight/2;    //center position y
  t=document.createElement(&#039;DIV&#039;);
  t.id=&#039;dd&#039;;
  t.style.pixelLeft=100;
  t.style.pixelTop=0.65*r;
  t.style.position=&#039;absolute&#039;;
  t.style.textAlign=&#039;center&#039;
  t.style.width=&#039;50px&#039;;
  document.documentElement.appendChild(t);
  fh(h.h);
  fh(h.m);
  fh(h.s);
  fd(12,24,0,&#039;windowtext&#039;);
  fd(60,6,16,&#039;graytext&#039;);
  function fc(){    //clock
    t=new Date();
    if(t.getSeconds()==m.getSeconds())window.setTimeout(&#039;fc()&#039;,10);
    else{
    fr(ds,6*(m.getSeconds()+1));
    if(t.getMinutes()!=m.getMinutes()){
      fr(dm,6*(m.getMinutes()+1));
      fr(dh,30*m.getHours()+m.getMinutes()/2);
      if(t.getDate()!=m.getDate())ff();
    }
    m=t;
    window.setTimeout(&#039;fc()&#039;,990);
    }
  }
  function fd(a,b,e,f){    //digits a-number b-size e-intro f-color
    for(var i=0;i&lt;a;i++){
      t=document.createElement(&#039;DIV&#039;);
      t.innerText=i==59?0:i+1;
      t.style.color=(i+1)%5?f:&#039;windowtext&#039;;
      t.style.fontSize=t.style.height=t.style.lineHeight=t.style.width=b+&#039;px&#039;;
      t.style.pixelLeft=x-b/2 +Math.sin(360/a*g*(i+1))*(r-e);
      t.style.pixelTop=y-b/2 -Math.cos(360/a*g*(i+1))*(r-e);
      t.style.position=&#039;absolute&#039;;
      t.style.textAlign=&#039;center&#039;
      document.documentElement.appendChild(t);
    }
  }
  function ff(){    //date
    dd.innerText=
     m.getDate()+&#039;.&#039;+(m.getMonth()&gt;8?m.getMonth()+1:&#039;0&#039;+(m.getMonth()+1))+
     &#039;\n&#039;+m.getFullYear();
  }
  function fh(e){    //hands
    t=document.createElement(&#039;DIV&#039;);
    t.id=e.i;
    t.style.backgroundColor=e.c;
    t.style.height=e.l+&#039;px&#039;;
    t.style.position=&#039;absolute&#039;;
    t.style.width=e.w+&#039;px&#039;;
    t.style.filter=&#039;progid:DXImageTransform.Microsoft.Matrix(sizingMethod=&quot;auto expand&quot;)&#039;;
    document.documentElement.appendChild(t);
  }
  function fr(e,f){    //rotate
    var
     d=e.filters.item(0),
     c=Math.cos(f*g),
     s=Math.sin(f*g),
     l=~~e.style.height.substring(0,e.style.height.length-2),
     w=~~e.style.width.substring(0,e.style.width.length-2);
    d.M11=c,d.M12=-s,d.M21=s,d.M22=c;
    e.style.pixelTop=(y-l)+l*(c&gt;0?1-c:1)+(c&gt;0?1:0)-(w-1)/2;
    e.style.pixelLeft=(x-l)+l*(s&lt;0?1+s:1)+(s&lt;0?1:0)-(w-1)/2;
  }
  window.onload=function(){
    fr(ds,6*m.getSeconds());
    fr(dm,6*m.getMinutes());
    fr(dh,30*m.getHours()+m.getMinutes()/2);
    fc();ff();
  }
  document.oncontextmenu=function(){
    window.close();
  }
&lt;/script&gt;
&lt;/html&gt;</code></pre></div><p>Кроме того, поигравшись с преобразованиями, нашел решение давнишней проблемы: в головную контору периодически надо отправлять отсканированные в pdf документы с &quot;синими&quot; подписями в каждой строке. Отсканировать подпись - не проблема, но уж больно они одинаковые, когда подряд. Пример работает с дивами, но, кому надо, имг подставят... random.hta:</p><div class="codebox"><pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
  &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=8&quot; /&gt;
  &lt;hta:application
   id=&quot;HTApp&quot;
   /&gt;
  &lt;style type=&quot;text/css&quot;&gt;
   *{color:navy;font:normal 14px/16px Arial;margin:0;padding:0;}
   body{overflow:hidden;}
  &lt;/style&gt;
&lt;/head&gt;
&lt;body onkeydown=&quot;if(event.keyCode==27)window.close();&quot;&gt;
&lt;/body&gt;
&lt;script type=&quot;text/jscript&quot; language=&quot;JScript&quot;&gt;
  var t;
  for(var i=0;i&lt;10;i++){
    t=document.createElement(&#039;DIV&#039;);
    t.innerText=&#039;Подпись&#039;;
    t.style.filter=&#039;progid:DXImageTransform.Microsoft.Matrix(sizingMethod=&quot;auto expand&quot;)&#039;;
    t.style.margin=&#039;5px 0 5px 200px&#039;;
//    t.style.position=&#039;absolute&#039;;
    document.documentElement.appendChild(t);
  }
  var d=document.getElementsByTagName(&#039;DIV&#039;);
  for(var i=0;i&lt;d.length;i++){
    var f=d[i].filters.item(0);
    f.M11=0.6+Math.random()/3,
    f.M12=-0.5-Math.random()/10,
    f.M21=0.1-Math.random()/5,
    f.M22=0.9+Math.random()/25;
  }
&lt;/script&gt;
&lt;/html&gt;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Serge Yolkin)]]></author>
			<pubDate>Fri, 02 Nov 2012 17:36:29 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=65364#p65364</guid>
		</item>
		<item>
			<title><![CDATA[JavaScript: поворот элемента страницы на определенный угол]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=15787#p15787</link>
			<description><![CDATA[<p>HTML-документ, приведённый ниже, отобразит на экране красный квадрат. При щелчке по квадрату он плавно повернётся на 90 градусов. Работает только в Internet Explorer, применяется фильтр &quot;Matrix&quot;.<br /></p><div class="codebox"><pre><code>&lt;div style=&#039;width:100px;height:100px;position:absolute;background-color:red;top:200px;left:200px;
    filter:progid:DXImageTransform.Microsoft.Matrix(sizingMethod=&quot;auto expand&quot;);&#039; 
    onclick=&#039;Spin(this.filters.item(0), 0, 1)&#039;&gt;&lt;/div&gt;
&lt;script&gt;
function Spin(aFilter, aDeg, aInc) {
    aDeg += aInc * 4;
    var rad = aDeg * Math.PI * 2 / 360,
        costheta = Math.cos(rad),
        sintheta = Math.sin(rad);
    aFilter.M11 = costheta;
    aFilter.M12 = -sintheta;
    aFilter.M21 = sintheta;
    aFilter.M22 = costheta;
    if (aDeg &lt; 90) {
        window.setTimeout(function () {
                       Spin(aFilter, aDeg, aInc);
                   }, 10);
    }
}
&lt;/script&gt;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Mon, 10 Nov 2008 18:27:56 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=15787#p15787</guid>
		</item>
	</channel>
</rss>
