├── README.md
├── canvas_inline
├── images
│ ├── arc.png
│ ├── bg.png
│ ├── brush.png
│ ├── line.png
│ ├── logo.jpg
│ ├── paint.png
│ ├── poly.png
│ ├── text.png
│ ├── arcfill.png
│ ├── canvas.png
│ ├── dropper.png
│ ├── eraser.png
│ ├── h5_audio.PNG
│ ├── h5_video.PNG
│ ├── line1px.png
│ ├── line3px.png
│ ├── line5px.png
│ ├── line8px.png
│ ├── screen.png
│ ├── icon_close.png
│ ├── magnifier.png
│ ├── rectangle.png
│ ├── h5_video_attr.PNG
│ └── icon_box-empty.png
├── js
│ ├── Canvas.js
│ ├── Color.js
│ ├── lineWidth.js
│ ├── ToolShape.js
│ └── ToolShapeFunc.js
├── css
│ └── style.css
└── index.html
├── .gitattributes
└── .gitignore
/README.md:
--------------------------------------------------------------------------------
1 | # canvas_inline
2 | 在线画图板
3 |
--------------------------------------------------------------------------------
/canvas_inline/images/arc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/arc.png
--------------------------------------------------------------------------------
/canvas_inline/images/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/bg.png
--------------------------------------------------------------------------------
/canvas_inline/images/brush.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/brush.png
--------------------------------------------------------------------------------
/canvas_inline/images/line.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/line.png
--------------------------------------------------------------------------------
/canvas_inline/images/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/logo.jpg
--------------------------------------------------------------------------------
/canvas_inline/images/paint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/paint.png
--------------------------------------------------------------------------------
/canvas_inline/images/poly.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/poly.png
--------------------------------------------------------------------------------
/canvas_inline/images/text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/text.png
--------------------------------------------------------------------------------
/canvas_inline/images/arcfill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/arcfill.png
--------------------------------------------------------------------------------
/canvas_inline/images/canvas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/canvas.png
--------------------------------------------------------------------------------
/canvas_inline/images/dropper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/dropper.png
--------------------------------------------------------------------------------
/canvas_inline/images/eraser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/eraser.png
--------------------------------------------------------------------------------
/canvas_inline/images/h5_audio.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/h5_audio.PNG
--------------------------------------------------------------------------------
/canvas_inline/images/h5_video.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/h5_video.PNG
--------------------------------------------------------------------------------
/canvas_inline/images/line1px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/line1px.png
--------------------------------------------------------------------------------
/canvas_inline/images/line3px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/line3px.png
--------------------------------------------------------------------------------
/canvas_inline/images/line5px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/line5px.png
--------------------------------------------------------------------------------
/canvas_inline/images/line8px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/line8px.png
--------------------------------------------------------------------------------
/canvas_inline/images/screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/screen.png
--------------------------------------------------------------------------------
/canvas_inline/images/icon_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/icon_close.png
--------------------------------------------------------------------------------
/canvas_inline/images/magnifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/magnifier.png
--------------------------------------------------------------------------------
/canvas_inline/images/rectangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/rectangle.png
--------------------------------------------------------------------------------
/canvas_inline/images/h5_video_attr.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/h5_video_attr.PNG
--------------------------------------------------------------------------------
/canvas_inline/images/icon_box-empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliuq/canvas_inline/master/canvas_inline/images/icon_box-empty.png
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/canvas_inline/js/Canvas.js:
--------------------------------------------------------------------------------
1 | (function(window){
2 | 'use strict';
3 |
4 | function Canvas(){
5 | //获取CanvasID
6 | this.cvs = document.getElementById("canvas");
7 | //获取2d对象
8 | this.cxt = this.cvs.getContext("2d");
9 |
10 | // this.offsetLeft = this.cvs.offsetLeft;
11 | // this.offsetTop = this.cvs.offsetTop;
12 | // return {
13 | // cvs : this.cvs,
14 | // cxt : this.cxt
15 | // }
16 | }
17 |
18 | window.Canvas = Canvas;
19 | })(window)
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
--------------------------------------------------------------------------------
/canvas_inline/js/Color.js:
--------------------------------------------------------------------------------
1 | // ——————颜色模块——————
2 | this.canvas = new Canvas();
3 | var colorUl = document.getElementById("color_ul");
4 | var colorLi = colorUl.getElementsByTagName('li');
5 |
6 | // 初始化颜色
7 | colorDef(colorLi[0]);
8 |
9 | colorUl.addEventListener('click',function(event){
10 | event = event || window.event;
11 | var target = event.target || window.event.srcElement;
12 | if(target.nodeName.toLowerCase() === 'li'){
13 | (function(){
14 | // 清空全部
15 | for( var i = 0; i < colorLi.length; i++ ){
16 | colorLi[i].style.border = "";
17 | }
18 | colorDef(target);
19 | })();
20 | }
21 | })
22 | function colorDef(obj){
23 | this.canvas.cxt.strokeStyle = obj.className;
24 | this.canvas.cxt.fillStyle = obj.className;
25 | obj.style.border= "2px solid #fff";
26 | }
--------------------------------------------------------------------------------
/canvas_inline/js/lineWidth.js:
--------------------------------------------------------------------------------
1 | // ——————线宽模块——————
2 | this.canvas = new Canvas();
3 | var lineWidthUl = document.getElementById("line_width");
4 | var lineWidthLi = lineWidthUl.getElementsByTagName('li');
5 |
6 | // 初始化线宽
7 | lineDef('line_1px', 1);
8 |
9 | lineWidthUl.addEventListener('click',function(event){
10 | event = event || window.event;
11 | var target = event.target || window.event.srcElement;
12 | // 清空全部
13 | for( var i = 0; i < lineWidthLi.length; i++ ){
14 | lineWidthLi[i].style.background = "";
15 | }
16 | if(target.nodeName.toLowerCase() === 'li' || target.nodeName.toLowerCase() === 'img'){
17 | var lineWidth = target.className.substr(5, 1);
18 | lineDef(target.className, lineWidth);
19 | }
20 | },false)
21 | function lineDef(className, px){
22 | var oli = document.getElementsByClassName(className);
23 | this.canvas.cxt.lineWidth = px;
24 | oli[0].style.background = "yellow";
25 | }
--------------------------------------------------------------------------------
/canvas_inline/css/style.css:
--------------------------------------------------------------------------------
1 | * { padding: 0; margin: 0; list-style: none; }
2 | body{ background-color: #ABCDEF; }
3 | /*头部 Start*/
4 | #header{
5 | font-size: 40px;
6 | width: 1000px;
7 | height: 100px;
8 | margin: 0 auto;
9 | text-align: center;
10 | line-height: 100px;
11 | }
12 | /*头部 End*/
13 |
14 | /*内容模块 Start*/
15 | #content{
16 | width: 1000px;
17 | height: 600px;
18 | background-color: #ccc;
19 | margin: 0 auto;
20 | padding: 10px;
21 | }
22 | /*工具栏 五个 Start*/
23 | #content #toolsUl { height: 200px; width: 1000px;}
24 | #content #toolsUl li.toolModel{
25 | background-color:gray;
26 | height: 190px;
27 | width: 199px;
28 | float: left;
29 | border-right: 1px solid #000;
30 | }
31 | /*工具栏 标题*/
32 | #toolsUl li h3{ text-align: center;padding: 5px; }
33 |
34 | /*图像下的样式*/
35 | #toolsUl li .ul1{ padding:30px; }
36 | #toolsUl li .ul1 li { list-style:square; padding-bottom:10px; }
37 | #toolsUl li .ul1 li button{ background: gray; border: 1px solid #000; }
38 | #toolsUl li .ul1 li button:hover{ border: 1px solid #fff; }
39 |
40 | /*工具和形状下的样式*/
41 | .tool_shape_ul{ padding: 30px 20px;}
42 | .tool_shape_ul li{
43 | float: left;
44 | border: 1px solid dimgray;
45 | margin-right: 1px;
46 | margin-bottom: 10px;
47 | height: 30px;
48 | width: 50px;
49 | text-align: center;
50 | }
51 | .tool_shape_ul li:hover{ border: 1px solid #fff; }
52 | .tool_shape_ul li img{ width: 35px; height: 25px;}
53 |
54 | /*线宽下的样式*/
55 | #line_width {padding:20px 30px}
56 | #line_width li{ padding-bottom: 5px; }
57 | #line_width li:hover{ border: 1px solid #fff; }
58 | #line_width li img{ width: 139px; }
59 |
60 | /*颜色下的样式*/
61 | #color_ul { padding: 30px 20px; }
62 | #color_ul li{
63 | border: 2px solid #000;
64 | height:25px;
65 | width: 25px;
66 | float: left;
67 | margin: 1px;
68 | margin-bottom: 4px;
69 | }
70 | #color_ul li:hover{ border: 2px solid #fff; }
71 |
72 | #color_ul .red{ background: red; }
73 | #color_ul .green{ background: green; }
74 | #color_ul .blue{ background: blue; }
75 | #color_ul .yellow{ background: yellow; }
76 | #color_ul .white{ background: white; }
77 | #color_ul .black{ background: black; }
78 | #color_ul .pink{ background: pink; }
79 | #color_ul .purple{ background: purple; }
80 | #color_ul .orange{ background: orange; }
81 | #color_ul .cyan{ background: cyan; }
82 |
83 | /*工具栏 五个 End*/
84 |
85 |
86 |
87 | /*画图板 Start*/
88 | /*画板溢出自适应 Start*/
89 | #content #over{ width: 1000px; height: 400px; overflow: auto; }
90 | /*画板溢出自适应 End*/
91 |
92 | #content #canvas{ background-color: #fff; }
93 | #content #canvas:hover{ cursor: crosshair; }
94 | /*画图板 End*/
95 |
96 | /*内容模块 End*/
97 | /* 保存图片 */
98 | #flag{
99 | position: fixed;
100 | left: 0;
101 | right: 0;
102 | top: 0;
103 | bottom: 0;
104 | background: rgba(0, 0, 0, 0.3);
105 | display: none;
106 | }
107 | #photo{
108 | border: 1px solid #333;
109 | background: #fff;;
110 | position: absolute;
111 | width: 600px;
112 | height: 400px;
113 | left: 50%;
114 | top: 50%;
115 | margin-left:-300px;
116 | margin-top: -200px;
117 | display: none;
118 | z-index: 99;
119 | }
120 | #photo span{
121 | position: absolute;
122 | right: 0;
123 | top: 0;
124 | cursor: pointer;
125 | }
126 |
127 | /*底部 Start*/
128 | #footer{
129 | width: 1000px;
130 | height: 50px;
131 | margin: 0 auto;
132 | text-align: center;
133 | padding-top: 15px;
134 | }
135 | /*底部 End*/
136 |
--------------------------------------------------------------------------------
/canvas_inline/js/ToolShape.js:
--------------------------------------------------------------------------------
1 | //——————工具模块——————
2 | // ——————形状模块——————
3 | this.canvas = new Canvas();
4 | this.Func = new Func();
5 | var toolUl = document.getElementById('tool_ul');
6 | var toolLi = toolUl.getElementsByTagName('li');
7 | var shapeUl = document.getElementById('shape_ul');
8 | var shapeLi = shapeUl.getElementsByTagName('li');
9 |
10 | // 初始化
11 | toolShapeDef(toolLi[0].className);
12 | this.Func.drawBrush();
13 | var that = this;
14 |
15 | toolUl.addEventListener('click',function(event){
16 | event = event || window.event;
17 | var target = event.target || window.event.srcElement;
18 | if(target.nodeName.toLowerCase() === 'li' || target.nodeName.toLowerCase() === 'img'){
19 | switch(target.className){
20 | case 'tool_brush':
21 | toolShapeDef(target.className);
22 | that.Func.drawBrush();
23 | break;
24 | case 'tool_eraser':
25 | toolShapeDef(target.className);
26 | that.Func.drawEraser();
27 | break;
28 | case 'tool_paint':
29 | toolShapeDef(target.className);
30 | that.Func.drawPaint();
31 | break;
32 | case 'tool_dropper':
33 | toolShapeDef(target.className);
34 | that.Func.drawDropper();
35 | break;
36 | case 'tool_text':
37 | toolShapeDef(target.className);
38 | that.Func.drawWord();
39 | break;
40 | case 'tool_magnifier':
41 | toolShapeDef(target.className);
42 | that.Func.drawMagnifier();
43 | break;
44 | }
45 | }
46 | },false);
47 |
48 | shapeUl.addEventListener('click',function(event){
49 | event = event || window.event;
50 | var target = event.target || window.event.srcElement;
51 | if(target.nodeName.toLowerCase() === 'li' || target.nodeName.toLowerCase() === 'img'){
52 | switch(target.className){
53 | case 'shape_line':
54 | toolShapeDef(target.className);
55 | that.Func.drawLine();
56 | break;
57 | case 'shape_arc':
58 | toolShapeDef(target.className);
59 | that.Func.drawArc();
60 | break;
61 | case 'shape_screen':
62 | toolShapeDef(target.className);
63 | that.Func.drawScreen();
64 | break;
65 | case 'shape_poly':
66 | toolShapeDef(target.className);
67 | that.Func.drawPoly();
68 | break;
69 | case 'shape_arcfill':
70 | toolShapeDef(target.className);
71 | that.Func.drawArcFill();
72 | break;
73 | case 'shape_rectangle':
74 | toolShapeDef(target.className);
75 | that.Func.drawRectFill();
76 | break;
77 | }
78 | }
79 | },false);
80 |
81 | function toolShapeDef(className){
82 | var oli = document.getElementsByClassName(className);
83 | for( var i = 0; i < toolLi.length; i++ ){
84 | toolLi[i].style.background = "";
85 | }
86 | for( var i = 0; i < shapeLi.length; i++ ){
87 | shapeLi[i].style.background = "";
88 | }
89 | oli[0].style.background = "yellow";
90 | }
91 |
92 | // 清空画布
93 | var clear = document.getElementById('clear');
94 | clear.onclick = function(){
95 | // 清除画布方法
96 | that.Func.clearPainting();
97 | }
98 |
99 | var save = document.getElementById('save');
100 | save.onclick = function(){
101 | that.Func.saveImg();
102 | }
103 |
104 | var close = document.getElementById('close');
105 | close.onclick = function(){
106 | that.Func.closeSaveImg();
107 | }
108 |
109 |
--------------------------------------------------------------------------------
/canvas_inline/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
74 |
75 |
78 |
79 |
80 |