質問編集履歴
1
htmlコードを追加 一部修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -238,122 +238,26 @@
|
|
238
238
|
|
239
239
|
}
|
240
240
|
|
241
|
-
|
242
|
-
|
243
|
-
function allClear() {
|
244
|
-
|
245
|
-
ctx.beginPath();
|
246
|
-
|
247
|
-
ctx.fillStyle = bgColor;
|
248
|
-
|
249
|
-
ctx.fillRect(0, 0, 500, 400);
|
250
|
-
|
251
|
-
outputData = new Array();
|
252
|
-
|
253
|
-
$('#undo, #redo').attr('disabled', true);
|
254
|
-
|
255
|
-
}
|
256
|
-
|
257
|
-
$('#pallet li').addClass('ofclic');
|
258
|
-
|
259
|
-
$('#pallet li').click(function() {
|
260
|
-
|
261
|
-
penColor = $(this).css('background-color');
|
262
|
-
|
263
|
-
$('#pallet li').removeClass('clic');
|
264
|
-
|
265
|
-
$(this).addClass('clic');
|
266
|
-
|
267
|
-
});
|
268
|
-
|
269
|
-
$('#penselect1').click(function() {
|
270
|
-
|
271
|
-
penSize = 3;
|
272
|
-
|
273
|
-
});
|
274
|
-
|
275
|
-
$('#penselect2').click(function() {
|
276
|
-
|
277
|
-
penSize = 10;
|
278
|
-
|
279
|
-
});
|
280
|
-
|
281
|
-
$('#penselect3').click(function() {
|
282
|
-
|
283
|
-
penSize = 15;
|
284
|
-
|
285
|
-
});
|
286
|
-
|
287
|
-
// 戻るボタン
|
288
|
-
|
289
|
-
$('#undo').click(function() {
|
290
|
-
|
291
|
-
if (outputLength >= 0) {
|
292
|
-
|
293
|
-
outputLength--;
|
294
|
-
|
295
|
-
ctx.putImageData(outputData[outputLength], 0, 0);
|
296
|
-
|
297
|
-
$('#redo').attr('disabled', false);
|
298
|
-
|
299
|
-
if (outputLength <= 0) {
|
300
|
-
|
301
|
-
$('#undo').attr('disabled', true);
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
});
|
308
|
-
|
309
|
-
// 進むボタン
|
310
|
-
|
311
|
-
$('#redo').click(function() {
|
312
|
-
|
313
|
-
if (outputLength <= outputData.length - 1) {
|
314
|
-
|
315
|
-
outputLength++;
|
316
|
-
|
317
|
-
ctx.putImageData(outputData[outputLength], 0, 0);
|
318
|
-
|
319
|
-
$('#undo').attr('disabled', false);
|
320
|
-
|
321
|
-
if (outputLength >= outputData.length - 1) {
|
322
|
-
|
323
|
-
$('#redo').attr('disabled', true);
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
}
|
328
|
-
|
329
|
-
});
|
330
|
-
|
331
|
-
$('#allclear').click(function() {
|
332
|
-
|
333
|
-
if (!confirm('すべて消去します\nよろしいですか?')) return;
|
334
|
-
|
335
|
-
allClear();
|
336
|
-
|
337
|
-
});
|
338
|
-
|
339
|
-
$('#save').click(function() {
|
340
|
-
|
341
|
-
var d = canvas.toDataURL('image/png');
|
342
|
-
|
343
|
-
d = d.replace('image/png', 'image/octet-stream');
|
344
|
-
|
345
|
-
window.open(d, 'save');
|
346
|
-
|
347
|
-
});
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
$("#drawbtn").on("click", function() {
|
352
|
-
|
353
|
-
$(".draw").slideToggle();
|
354
|
-
|
355
|
-
});
|
356
|
-
|
357
241
|
}
|
358
242
|
|
359
243
|
```
|
244
|
+
|
245
|
+
```html
|
246
|
+
|
247
|
+
<script type="text/javascript">
|
248
|
+
|
249
|
+
<!-- //
|
250
|
+
|
251
|
+
$(function(){
|
252
|
+
|
253
|
+
drawScript();
|
254
|
+
|
255
|
+
});
|
256
|
+
|
257
|
+
// -->
|
258
|
+
|
259
|
+
</script>
|
260
|
+
|
261
|
+
<canvas id="drawCanvas" width="500" height="400"></canvas>
|
262
|
+
|
263
|
+
```
|