zoukankan      html  css  js  c++  java
  • 使用Raphael 画图(三) 事件 (javascript)

    这章展示事件例子。

     下图是官方API的事件:

    例子:

    var butt1 = paper.set();
            var a1 = paper.circle(24.833, 26.917, 26.667).attr({fill: "#fff", opacity: 0});
            var a2 = paper.circle(24.833, 26.917, 26.667).attr({stroke: "black", fill: "#fff", "fill-opacity": .4, "stroke-width": 2}); 
            var a3 = paper.path("M12.582,9.551C3.251,16.237,0.921,29.021,7.08,38.564l-2.36,1.689l4.893,2.262l4.893,2.262l-0.568-5.36l-0.567-5.359l-2.365,1.694c-4.657-7.375-2.83-17.185,4.352-22.33c7.451-5.338,17.817-3.625,23.156,3.824c5.337,7.449,3.625,17.813-3.821,23.152l2.857,3.988c9.617-6.893,11.827-20.277,4.935-29.896C35.591,4.87,22.204,2.658,12.582,9.551z").attr({stroke: "none", fill: "#000"});
            butt1.push(a1,a2,a3);
            
            //为a2设置触发相应事件后做什么。
            butt1[1].click(function () {
                alert('where amazing happens!');
            }).mouseover(function () {
                butt1[2].stop().attr({fill: "orange"});
            }).mouseout(function () {
                butt1[2].animate({fill: "black"}, 300);
            });        
            
            butt1.translate(150,160);
            
            var butt2 = paper.set();
            var r = paper.rect(150,100,100,50);
            r.attr({stroke:'red','stroke-width':2,title:'模块一',fill:'#ccc'});
            var t = paper.text(200, 125, "where
     amazing
     happens!");//text
            t.attr({fill:'blue'});
            
            butt2.push(r,t);
            
            //这是另一种写法
            butt2[0].mouseover(function (event) {
                butt2[1].attr({fill: "green"});
            });
            
            butt2[0].mouseout(function (event) {
                butt2[1].attr({fill: "blue"});
            });

    运行效果图1:


    运行效果图2:


    运行效果图3:


     原文:http://czpae86.iteye.com/blog/819183

  • 相关阅读:
    【MySQL】:利用DCL管理用户和控制权限
    【MySQL】:事务四大特性与隔离级别
    JDBC概述及编程步骤详解
    【MySQL】:多表查询
    【MySQL】:MySQL中四大约束
    MySQL解决DOS窗口乱码问题
    【MySQL】:分组查询where和having
    【MySQL】:利用DQL查询表中的数据
    【MySQL】:利用DML操作表中数据
    【MySQL】:利用DDL操作数据库、表
  • 原文地址:https://www.cnblogs.com/kt520/p/4049605.html
Copyright © 2011-2022 走看看