/*
* zr has been init like this, just use it!
*
* var zrender = require(‘zrender’);
* var zr = zrender.init(document.getElementById(‘main’));
*/
zr.clear();
function Cross() {
this.type = ‘cross’;
}
var id = zr.getId();
alert(id);
Cross.prototype = {
brush : function(ctx, e, isHighlight) {
var style = e.style || {};
if (isHighlight) {
// 根据style扩展默认高亮样式
style = e.highlightStyle || {};
for (var k in e.style) {
style[k] = e.style[k];
}
}
ctx.save();
ctx.beginPath();
ctx.strokeStyle = style.strokeColor || style.color;
ctx.moveTo(style.x - style.width / 2, style.y);
ctx.lineTo(style.x + style.width / 2, style.y);
ctx.moveTo(style.x, style.y - style.height / 2);
ctx.lineTo(style.x, style.y + style.height / 2);
ctx.closePath();
ctx.stroke();
ctx.restore();
return;
},

drift : function(e, dx, dy) {e.style.x += dx;e.style.y += dy;
},isCover : function(e, x, y) {if (x >= (e.style.x - e.style.width / 2)&& x <= (e.style.x + e.style.width / 2)&& y >= e.style.y - e.style.height / 2&& y <= (e.style.y + e.style.height / 2)) {return true;}return false;
}

}
alert();
var shape = require(‘zrender/shape’);
shape.define(‘cross’, new Cross());
zr.addShape({
shape : ‘cross’,
style : {
x : 100,
y : 100,
width : 50,
height : 50,
color : ‘red’
},
draggable : true
});

function Audi() {
this.type = ‘auid’;
this.brushTypeOnly = ‘stroke’;
}
Audi.prototype = {
buildPath : function(ctx, style) {
var x = style.x;
var y = style.y;
var r = style.r;
for (var i = 0; i < 4; i++) {
ctx.arc(x, y, r, 0, Math.PI * 2, true);
ctx.moveTo(x + 5 * r / 2, y);
x += r * 3 / 2;
}
return;
},

/*** 返回矩形区域,用于局部刷新和文字定位* @param {Object} style*/
getRect : function(style) {return {x : Math.round(style.x - style.r),y : Math.round(style.y - style.r),width : style.r * 6.5,height : style.r * 2};
}

}
var base = require(‘zrender/shape/base’);
base.derive(Audi);
shape.define(‘audi’, new Audi());
zr.addShape({
shape : ‘audi’,
style : {
x : 200,
y : 100,
r : 50,
color : ‘#1e90ff’,
text : ‘Audi’
},
draggable : true
});
zr.render();

zrender自定义图形相关推荐

  1. 如何提取Tableau打包工作簿中的自定义图形和数据集

    最近学习了一下Robert关于如何提取Tableau中自定义图形的文章,方法非常简单,只需使用大神提供的excel文件,就可以轻松完成. 文章地址:https://www.clearlyandsimp ...

  2. C# 绘制PDF图形——基本图形、自定义图形、色彩透明度

    引言 在PDF中我们可以通过C#程序代码来添加非常丰富的元素来呈现我们想要表达的内容,如绘制表格.文字,添加图形.图像等等.在本篇文章中,我将介绍如何在PDF中绘制图形,并设置图形属性的操作. 文章中 ...

  3. OSG使用OpenGL(以及glad库)绘制自定义图形

    简单记录一下在OSG中使用OpenGL函数(以及glad库)绘制自定义图形. 源码: #include <osgViewer/viewer> #include <osg/Geode& ...

  4. visio自己画的图怎么填充_VISIO自定义图形填充

    有时候我们需要画一些特殊图形,比如以下这个 当然,如果你不嫌麻烦的画,可以画好一个之后复制粘贴,但显然这不是好主意,这时候就需要掌握VISIO自定义图形填充技巧. 第一步:打开绘图资源管理器(基于20 ...

  5. Python数据分析(三)matplotlib折线图应用实例——自定义图形风格

    往期推荐: Python数据分析(一)matplotlib基础绘图和调整x轴刻度 Python数据分析(二)matplotlib折线图应用实例--绘制10点到12点的气温 Python数据分析(四)m ...

  6. Qt使用C++封装qml自定义图形控件(QQuickPaintedItem)

    C++封装qml自定义图形控件 QtWidget.qml简介 通过继承QQuickPaintedItem封装控件 描述 公用接口定义 代码示例 效果图 QtWidget.qml简介 Qt提供了2套UI ...

  7. python如何画贝塞尔曲线_Python使用matplotlib实现绘制自定义图形功能示例

    本文实例讲述了Python使用matplotlib实现绘制自定义图形功能.分享给大家供大家参考,具体如下: 一 代码 from matplotlib.path importPath from matp ...

  8. ArcGIS JS 版军事标绘图(燕尾箭头、钳击箭头、集结地)扇形等自定义图形

    ArcGIS API for JavaScript  版本的自定义图形标绘. 支持: arcgis js 3.x arcgis js 4.x 百度地图 高德地图 openlayer 离线地图 实例代码 ...

  9. 【幻灯片动画制作】Focusky教程 | 自定义图形形状

    在Focusky(以下简称"FS软件")中,你可以利用软件自带的图形素材或者自己有的相关素材在画布中进行编辑组合.之后通过把这些素材添加到自己的素材库中,就可以变成自己的自定义图形 ...

最新文章

  1. 5篇CVPR 各路大佬显身手 点云分割、姿态估计、物体检测、生成重建
  2. 网络配置——Linux入门到精通的难关之一
  3. 自建ES迁移至阿里云ES(使用脚本及logstash同步)
  4. 知乎:中国工商银行南宁分行丢失2.5亿,工作人员个人行为,与银行无关
  5. 为 springboot 添加 debug功能
  6. 夏利车电动窗功能设定
  7. mil跟踪算法matlab,几种目标跟踪算法性能比较
  8. Yarn在MapReduce中的工作机制
  9. python easygui_Python里的easygui库
  10. 消息称苹果斥资2亿美元收购Xnor.ai;华为2000万英镑投资,加速发展HMS手机生态系统;国产SSD将迎来爆发……...
  11. (王道408考研操作系统)第二章进程管理-第三节1:进程同步与互斥的基本概念
  12. 使用.htaccess文件为站点文件夹设置密码保护
  13. mysql 唯一 标识符_mysql – 获取唯一标识符而不插入
  14. AngularJS Eclipse——新手入门【翻译+整理】
  15. 大数据平台有什么功能
  16. Java 分支与循环
  17. java框架快速使用mysql_阿里java架构师教你怎么用mysql怒怼面试官
  18. 2020年云计算发展趋势怎么样?
  19. source insight4.0各种问题处理方法汇总
  20. “高高兴兴上班,平平安安回家”

热门文章

  1. linux 查看文件句柄,查看linux下进程打开的文件句柄数并清理
  2. 编程语言和标记语言的区别
  3. module ‘glm‘ has no attribute ‘vec3‘
  4. HTTPS简介以及SSL协议详解
  5. https接入我们国标流媒体服务器视频无法播放问题解决
  6. Eclipse搭建简单的Spring框架
  7. 华为rs能不能用鸿蒙系统,mate40Pro和40RS能用上鸿蒙系统吗
  8. 资深老建模师带你快速掌握ZBrush中自动拓扑功能与动态网格功能,明日星星指日可待
  9. 通过二级域名与frp实现不同web服务的聚合透传
  10. Knockout初体验--监控属性