Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

draw / main.min

.js
Скачиваний:
2
Добавлен:
19.01.2023
Размер:
1.15 Кб
Скачать
function circle(){var e=document.querySelector("input[type=checkbox]"),t=document.querySelector("canvas").getContext("2d");t.beginPath(),t.lineWidth=5,t.arc(1350*Math.random()+50,450*Math.random()+50,75,0,function(e){return Math.PI/180*e}(360)),e.checked&&t.fill(),t.stroke()}function line(){var e=document.querySelector("canvas").getContext("2d");e.beginPath(),e.lineWidth=5,e.moveTo(1350*Math.random()+50,450*Math.random()+50),e.lineTo(1350*Math.random()+50,450*Math.random()+50),e.stroke()}function rectangle(){var e=document.querySelector("input[type=checkbox]"),t=document.querySelector("canvas").getContext("2d");if(t.beginPath(),t.fillStyle="#"+(Math.random().toString(16)+"000000").substring(2,8).toUpperCase(),e.checked){var n=820*Math.random()+180,c=120*Math.random()+180;t.strokeRect(n,c,200,100),t.fillRect(n,c,200,100)}else t.strokeRect(820*Math.random()+180,120*Math.random()+180,200,100)}window.onload=function(){document.querySelector("canvas").getContext("2d")},circle0.onclick=circle,line0.onclick=line,rectangle0.onclick=rectangle,clear0.onclick=function(){document.querySelector("canvas").getContext("2d").clearRect(0,0,1500,1e3)};
Соседние файлы в папке draw