Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
eguid_1
graffitiCanvas
提交
1fe6d2d6
G
graffitiCanvas
项目概览
eguid_1
/
graffitiCanvas
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
graffitiCanvas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1fe6d2d6
编写于
10月 30, 2019
作者:
eguid_1
⚾
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
submit
上级
181e3087
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
968 addition
and
1 deletion
+968
-1
LICENSE
LICENSE
+1
-1
README.md
README.md
+6
-0
canvans.html
canvans.html
+154
-0
graffitiCanvas.js
graffitiCanvas.js
+807
-0
snapshot.png
snapshot.png
+0
-0
未找到文件。
LICENSE
浏览文件 @
1fe6d2d6
...
...
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright
[yyyy] [name of copyright owner]
Copyright
eguid eguid@outlook.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
...
...
README.md
浏览文件 @
1fe6d2d6
# graffitiCanvas
Graffiti Canvas Library (涂鸦画板工具库)
# description
“graffitiCanvas” is a canvas drawing tool based on javascript native canvas, which can draw many shapes. Browser compatibility supports IE8+ (support IE5+ with excanvas)
“graffitiCanvas”是一个基于javascript原生canvas的画板绘制工具,可以绘制很多形状,浏览器兼容性支持IE8+(借助excanvas可以支持IE5+)。
## 功能说明
图片
\ No newline at end of file
canvans.html
0 → 100644
浏览文件 @
1fe6d2d6
<!DOCTYPE html >
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
测试拖拽绘图
</title>
<link
rel=
"stylesheet"
href=
"http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css"
>
</head>
<body>
<div>
操作方式:
<p>
选择要画的图形(除了多边形),在绘制区域按住鼠标左键不放,移动鼠标即时绘制图形,松开鼠标左键结束绘制
</p>
<p>
进行多边形绘制时,多次点击以确定每个角的点,右键结束多边形绘制
</p>
<p>
注意:鼠标越出绘制区域会自动结束绘制
</p>
</div>
<div
class=
"form-group"
>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawPen"
>
画笔
</button>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawLine"
>
绘制线条
</button>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawArror"
>
绘制箭头
</button>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawTriangle"
>
绘制三角形
</button>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawRect"
>
绘制矩形
</button>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawParallel"
>
绘制平行四边形
</button>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawTrape"
>
绘制梯形
</button>
<a
id=
"drawPolygon"
tabindex=
"0"
class=
"btn btn-warning"
role=
"button"
data-toggle=
"popover"
data-placement=
"bottom"
data-trigger=
"focus"
data-content=
"点击鼠标右键结束多边形绘制"
>
绘制多边形
</a>
<button
type=
"button"
class=
"btn btn-warning"
id=
"drawCircle"
>
绘制圆
</button>
<button
type=
"button"
class=
"btn btn-primary"
id=
"no-drawing"
>
手型选择
</button>
<button
type=
"button"
class=
"btn btn-danger"
id=
"clearAll"
>
清空
</button>
</div>
<div
style=
""
>
<canvas
id=
"calibrationCanvas"
width=
"352"
height=
"288"
style=
"width:352px;height:288px;display: block;margin:5px auto;border:1px solid red;"
>
你的浏览器不支持绘图,请更换浏览器后重试!
</canvas>
</div>
<div
class=
"form-inline"
>
<label
for=
"pictureurl"
>
背景图片
</label>
<input
id=
"pictureurl"
class=
"form-control"
name=
"pictureurl"
value=
"http://eguid.cc/img/cv.jpg"
>
<button
id=
"changeImg"
type=
"button"
class=
"btn btn-primary"
>
切换图片
</button>
</div>
<div
class=
"form-inline"
>
<label
for=
"pictureurl"
>
画笔粗度
</label>
<input
id=
"lineWidth"
type=
"number"
value=
"1"
/>
<label
for=
"pictureurl"
>
画笔颜色
</label>
<input
id=
"strokeStyle"
type=
"color"
id=
"color"
value=
"#ff0000"
/>
<label
for=
"pictureurl"
>
填充颜色
</label>
<input
id=
"fillStyle"
type=
"color"
id=
"color"
value=
"#ff0000"
/>
<button
id=
"changeStyle"
type=
"button"
class=
"btn btn-primary"
>
设置
</button>
<button
type=
"button"
class=
"btn btn-primary"
id=
"save"
>
保存设置
</button>
<button
type=
"button"
class=
"btn btn-warning"
id=
"restore"
>
恢复到上一次保存的设置
</button>
<button
id=
"enIsFill"
type=
"button"
class=
"btn btn-primary"
>
允许使用填充色
</button>
<button
id=
"disIsFill"
type=
"button"
class=
"btn btn-primary"
>
禁止使用填充色
</button>
<button
id=
"enableContinus"
type=
"button"
class=
"btn btn-primary"
>
开启连续绘图模式
</button>
<button
id=
"disableContinus"
type=
"button"
class=
"btn btn-primary"
>
禁止连续绘图模式
</button>
</div>
</body>
<!-- 拖拽式绘图 -->
<script
type=
"text/javascript"
src=
"GraffitiCanvas.js"
charset=
"utf-8"
></script>
<script
src=
"http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"http://apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js"
></script>
<script
type=
"text/javascript"
>
//使用demo
var
drawUtil
=
new
GraffitiCanvas
();
if
(
drawUtil
.
init
({
'
id
'
:
'
calibrationCanvas
'
})){
//加载图片
var
imgsrc
=
$
(
"
#pictureurl
"
).
val
();
if
(
!
drawUtil
.
isNull
(
imgsrc
)){
drawUtil
.
setBgPic
(
imgsrc
,
true
);
}
}
$
(
"
#enableContinus
"
).
click
(
function
(){
alert
(
drawUtil
.
isContinuous
(
true
));
});
$
(
"
#disableContinus
"
).
click
(
function
(){
alert
(
drawUtil
.
isContinuous
(
false
));
});
$
(
"
#save
"
).
click
(
function
(){
drawUtil
.
save
();
});
$
(
"
#restore
"
).
click
(
function
(){
drawUtil
.
restore
();
})
$
(
"
#enIsFill
"
).
click
(
function
(){
drawUtil
.
enableFillStyle
(
true
);
});
$
(
"
#disIsFill
"
).
click
(
function
(){
drawUtil
.
enableFillStyle
(
false
);
});
$
(
"
#changeImg
"
).
click
(
function
(){
var
imgsrc
=
$
(
"
#pictureurl
"
).
val
();
if
(
!
drawUtil
.
isNull
(
imgsrc
)){
drawUtil
.
setBgPic
(
imgsrc
,
true
);
}
});
//切换笔触样式
$
(
"
#changeStyle
"
).
click
(
function
(){
var
lineWidth
=
$
(
"
#lineWidth
"
).
val
();
var
strokeStyle
=
$
(
"
#strokeStyle
"
).
val
();
var
fillStyle
=
$
(
"
#fillStyle
"
).
val
();
drawUtil
.
setPaintConfig
({
lineWidth
:
lineWidth
,
strokeStyle
:
strokeStyle
,
fillStyle
:
fillStyle
,
});
});
//画笔
$
(
"
#drawPen
"
).
click
(
function
(){
drawUtil
.
begin
(
1
);
});
//箭头
$
(
"
#drawArror
"
).
click
(
function
(){
drawUtil
.
begin
(
21
);
});
//线条
$
(
"
#drawLine
"
).
click
(
function
(){
drawUtil
.
begin
(
2
);
});
//三角形
$
(
"
#drawTriangle
"
).
click
(
function
(){
drawUtil
.
begin
(
3
);
});
//矩形
$
(
"
#drawRect
"
).
click
(
function
(){
drawUtil
.
begin
(
4
);
});
//平行四边形
$
(
"
#drawParallel
"
).
click
(
function
(){
drawUtil
.
begin
(
41
);
});
$
(
"
#drawTrape
"
).
click
(
function
(){
drawUtil
.
begin
(
42
);
});
//多边形
$
(
"
#drawPolygon
"
).
click
(
function
(){
drawUtil
.
begin
(
5
);
});
//绘制圆
$
(
"
#drawCircle
"
).
click
(
function
(){
drawUtil
.
begin
(
6
);
});
//取消绘制
$
(
"
#no-drawing
"
).
click
(
function
(){
drawUtil
.
hand
();
});
//取消绘制
$
(
"
#clearAll
"
).
click
(
function
(){
drawUtil
.
clear
();
});
$
(
"
#cancel
"
).
click
(
function
(){
parent
.
layer
.
closeAll
();
});
$
(
'
#drawPolygon
'
).
popover
();
</script>
</html>
\ No newline at end of file
graffitiCanvas.js
0 → 100644
浏览文件 @
1fe6d2d6
此差异已折叠。
点击以展开。
snapshot.png
0 → 100644
浏览文件 @
1fe6d2d6
123.6 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录