矢量标记语言 --- Vector Markup Language

运行它的代码需要打开IE的兼容性视图

如有疑问请参考:http://msdn.microsoft.com/en-us/library/bb264280(VS.85).aspx

代码如下:

<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
    <!-- VML requires VML namespace and behavior. -->
    <style>
        v\:* { behavior: url(#default#VML); }
    </style>
    <script type="text/javascript">
        // Your JavaScript code will go here.

        //Flag to stop rectangle from spinning.
        var spin;
        //Flag to first call makeRect function
        var first = true;
        // Make rectangle.
        function makeRect() {
            //if not first call, return.
            if(first == false)
                return;
            first = false;

            // Create element in memory.
            var r = document.createElement("v:rect");

            // Define width, height, color, and unique ID.
            r.style.width = 100;
            r.style.height = 100;
            r.fillcolor = "purple";
            r.id = "myRect";

            // Attach rectangle to the document at the the specified Div.
            var anchorDiv = document.getElementById('anchorDiv');
            anchorDiv.appendChild(r);
        }

        // Set up the rotation.
        function rotateRect() {
            // Call spinRect function every 10 milliseconds.
            // The spin variable allows us to clear the call to setInterval.
            spin = setInterval("spinRect()", 10);
        }

        // Spin the rectangle by specified increment every time function called.
        function spinRect() {
            // Increment rectangle rotation by 1 degrees.
            var myRect = document.getElementById('myRect');
            myRect.rotation += 1;
        }
    </script>
</head>
<body>

<br><br>
<!-- Button to create rectangle. -->
<input type="BUTTON" value="Make Rectangle" onclick="makeRect()">
<!-- Button to rotate rectangle. -->
<input type="BUTTON" value="Rotate Rectangle" onclick="rotateRect()">
<!-- Button to close webpage. -->
<input type="BUTTON" value="Stop!" onclick="clearInterval(spin)">
<br><br>
<!-- Node where new rectangle will be attached. -->
<div id="anchorDiv" style="border: dotted"></div>

</body>
</html>

运行结果如下:

html --- VML --- javascript --- 旋转矩形的更多相关文章

  1. html --- SVG --- javascript --- 旋转矩形

    可缩放矢量图形(英语:Scalable Vector Graphics,SVG)是基于可扩展标记语言(XML), 用于描述二维矢量图形的一种图形格式.SVG由W3C制定,是一个开放标准. 在 Inte ...

  2. cocos2d 判断旋转矩形是否包含某个点

    本来想画个图演示一下,但是折腾了一会发现画不好,我的win10系统没有安装office,以后再看的话再补上吧.不废话了. 如图所以,如果判断点P是否被矩形A所包含,非常容易.那么如果矩形A以中心点逆时 ...

  3. css3+javascript旋转的3d盒子

    今天写点css3,3d属性写的3d盒子,结合javascript让盒子随鼠标旋转起来 今天带了css3新属性3d <!DOCTYPE html> <html> <head ...

  4. 旋转矩形碰撞检测 OBB方向包围盒算法

    在cocos2dx中进行矩形的碰撞检测时需要对旋转过的矩形做碰撞检查,由于游戏没有使用Box2D等物理引擎,所以采用了OBB(Oriented bounding box)方向包围盒算法,这个算法是基于 ...

  5. RotateRect(旋转矩形)的倾斜旋转变换矫正

    在Opencv中的图像处理中,经常要用到minAreaRect()函数求最小外接矩形,该函数的返回值就是一个RotatedRect类对象. RotatedRect类定义如下: class CV_EXP ...

  6. javascript中矩形的碰撞检测---- 计算碰撞部分的面积

    今天在做一个拖拽改变元素排序的东西的时候,在做被拖动元素同时碰撞到两个元素时,究竟应该与哪个元素交换位置的问题上,纠结到崩溃,实在是想不到别的办法去做了,只能去想办法计算碰撞的面积. 这应该不是最合适 ...

  7. opencv HSV找颜色,找轮廓用最小旋转矩形框出

    #include <opencv2/opencv.hpp> #include<iostream> #include<string> using namespace ...

  8. 矩形旋转碰撞,OBB方向包围盒算法实现

    怎样进行2D旋转矩形的碰撞检測.能够使用一种叫OBB的检測算法(Oriented bounding box)方向包围盒.这个算法是基于SAT(Separating Axis Theorem)分离轴定律 ...

  9. 实现Canvas2D绘图 使元素绕中心居中旋转

    我之前用canvas写了个头像剪切的demo,但是关于让载入的图片旋转是个问题,虽然通过其它方法实现了,但是感觉并不太好,于是查了些资料,想试着重新做一下canvas的旋转. 在开始之前,先让我们来做 ...

随机推荐

  1. JSP相对路径与绝对路径探秘

    浏览器端 带杠的 一开始浏览器的地址http://localhost:8080/example/index.jsp 如果写成 <a href="/servlet/TestDBSvl&q ...

  2. 解决 ko mapping 数组无法添加新对象的问题

    这两天页面模板化的进程有些放缓,使用 ko mapping 插件的情形多了起来.组员经常问到的问题即是往 ko mapping 数组添加新对象时,报找不到方法的错误:而使用 ko.observable ...

  3. 【转】Java中==、equals、hashcode的区别与重写equals以及hashcode方法实例

    原文地址:http://www.cnblogs.com/luankun0214/p/4421770.html 感谢网友的分享,记录下来只为学习. 1.重写equals方法实例   部分代码参考http ...

  4. 《Linux内核设计与实现》读书笔记(七)- 中断处理【转】

    转自:http://www.cnblogs.com/wang_yb/archive/2013/04/19/3030345.html 中断处理一般不是纯软件来实现的,需要硬件的支持.通过对中断的学习有助 ...

  5. 第一个Linux驱动-流水灯【转】

    转自:http://www.xuebuyuan.com/1856562.html 水平有限,描述不当之处请指出,转载请注明出处http://blog.csdn.net/vanbreaker/artic ...

  6. (二)javascript中int和string转换

    在javascript里怎么样才能把int型转换成string型 (1)var x=100 a = x.toString() (2)var x=100; a = x +""; // ...

  7. URAL1410. Crack

    1410 dp水题 题意读了好一会 是不能连续读两个及以上单词 #include <iostream> #include<cstdio> #include<cstring ...

  8. 转载 近期微博吐槽言论存档,涉及“性能优化”、C++陋习等

    http://blog.csdn.net/solstice/article/details/9923615 近期微吐槽博言论存档,涉及“性能优化”.C++陋习等 写C++程序的几个陋习:class 名 ...

  9. 【转载】关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation

    原文在: https://yq.aliyun.com/articles/40353 这里有转载:http://www.cnblogs.com/zhao1949/p/5652167.html 先来一段S ...

  10. linux下gitflow辅助工具安装和使用

    gitflow是一个确保nvie推荐的git branch分支策略最佳模型得到有效实施的辅助工具.它作为git的一个子命令而存在. http://nvie.com/posts/a-successful ...