Html画组织架构图

/**
 * Created with JetBrains PhpStorm.
 * User: kathleen
 * Date: 12-12-16
 * Time: 下午1:10
 * To change this template use File | Settings | File Templates.
 */
function Cire(config,values){
    this.x = config.x ? config.x:0;
    this.y = config.y ? config.y:0;
    this.w = config.w ? config.w :80;
    this.h = config.h ? config.h :40;
    this.c_x = this.x;
    this.c_y = this.y+this.h/2;
    this.name = values.name? values.name:"name";
    this.id = values.id? values.id:"id";
    cxt = document.getElementById("canvas");
    cxt = cxt.getContext("2d");
    this.draw = function(h){
        if(this.l_w){
            cxt.moveTo(this.x,this.y);
            cxt.clearRect(this.x-this.l_w,this.y-this.l_w,this.w+ 2*this.l_w,this.h+ 2*this.l_w);
        }
        if(h){
            this.y = this.y + h;
        }
        this.l_w = cxt.lineWidth;
        cxt.beginPath();
        cxt.moveTo(this.x,this.y);
        cxt.rect(this.x,this.y,this.w,this.h);
        cxt.stroke();
        cxt.fillStyle = "red";
        cxt.font = "normal 20px 宋体";
        cxt.textAlign="center";
        cxt.textBaseline="middle";
        cxt.fillText(this.name, this.x+ this.w/2,this.y+ this.h/2);
        cxt.closePath();
        return this.h;
    }
    this.clear = function(){
    	  	cxt.moveTo(this.x,this.y);
            cxt.clearRect(this.x-this.l_w,this.y-this.l_w,this.w+ 2*this.l_w,this.h+ 2*this.l_w);
    }
    this.isBelong= function(x,y){
        var s_x = this.x;
        var s_y = this.y;
        var e_x = this.x + this.w;
        var e_y  = this.y + th
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值