Редактирование: Участник:StarfloFr
Внимание! Вы не авторизовались на сайте. Ваш IP-адрес будет публично видимым, если вы будете вносить любые правки. Если вы войдёте или создадите учётную запись, правки вместо этого будут связаны с вашим именем пользователя, а также у вас появятся другие преимущества.
Правка может быть отменена. Пожалуйста, просмотрите сравнение версий, чтобы убедиться, что это именно те изменения, которые вас интересуют, и нажмите «Записать страницу», чтобы изменения вступили в силу.
Текущая версия | Ваш текст | ||
Строка 1: | Строка 1: | ||
− | {{#widget:Iframe | url=http://tm.spbstu.ru/htmlets/js2020/Natalin/Kursach1.html | width= | + | {{#widget:Iframe | url=http://tm.spbstu.ru/htmlets/js2020/Natalin/Kursach1.html | width=1920 | height=1080 | border=0}} |
− | == | + | == КОД == |
− | < | + | <!DOCTYPE html> |
− | ''' | + | <html lang="ru"> |
− | < | + | <head> |
+ | <title>Модель броуновского движения</title> | ||
+ | <meta charset="UTF-8"> | ||
+ | |||
+ | |||
+ | </head> | ||
+ | |||
+ | <style> | ||
+ | canvas { border: 1px solid black; } | ||
+ | .pr { | ||
+ | |||
+ | border-bottom :1px solid #a2a9b1; | ||
+ | |||
+ | </style> | ||
+ | <body onload = "start();" > | ||
+ | |||
+ | |||
+ | <p class = "pr" ; style='font-size:30px ; font-weight:40; font-family:'Linux Libertine','Georgia','Times',serif;'>Модель Броуновского движения</p> | ||
+ | |||
+ | <p class = "pr" ; style='font-size:23px ; font-weight:40; font-family:'Linux Libertine','Georgia','Times',serif;'>Описание</p> | ||
+ | <p style='font-size:18px ; font-weight:40; font-family:'Linux Libertine','Georgia','Times',serif;'>Модель Броуновского движения с изоброжением траектории. Работа сделана на языке программирования JavaScript.</p> | ||
+ | <p style='font-size:18px ; font-weight:40; font-family:'Linux Libertine','Georgia','Times',serif;'>Исполнитель: Никита Натальин.</p> | ||
+ | <p style='font-size:18px ; font-weight:40; font-family:'Linux Libertine','Georgia','Times',serif;'>Группа:3630103/90001</p> | ||
+ | |||
+ | |||
+ | <p class = "pr" ; style='font-size:23px ; font-weight:40; font-family:'Linux Libertine','Georgia','Times',serif;'>Визуализация</p> | ||
+ | |||
+ | <br> | ||
+ | <input type="text" id="size" value="500"> | ||
+ | |||
+ | <input type="button" value="chaneg size" onclick="changeSize();"> | ||
+ | <br> | ||
+ | <input type="text" id="addCount" value="10"> | ||
+ | <input type="button" value="add" onclick="add();"> | ||
+ | |||
+ | <input type="button" value="delete" onclick="del();"> | ||
+ | <br> | ||
+ | |||
+ | <input type="text" id="weight" value="500"> | ||
+ | <input type="button" value="weight" onclick="weight();"> | ||
+ | <br> | ||
+ | |||
+ | <input type="button" value="slowly" onclick="slowly();"> | ||
+ | <input type="button" value="faster" onclick="faster();"> | ||
+ | |||
+ | <br> | ||
+ | |||
+ | |||
+ | |||
+ | <label><input type="checkbox" id="color" checked>color</label> | ||
+ | <br><br> | ||
+ | |||
+ | |||
+ | <canvas id="GG" width="500" height="500"></canvas> | ||
+ | <script> | ||
class Ball { | class Ball { | ||
Строка 183: | Строка 237: | ||
canvas.height = document.getElementById('size').value; | canvas.height = document.getElementById('size').value; | ||
} | } | ||
− | + | var tander = 0; | |
− | |||
− | + | function drawPath() { | |
− | + | tander++; | |
− | + | if(tander === 5){ | |
− | + | tander=0; | |
− | + | if ( pathx.length>=1000){ | |
− | + | pathx.shift(); | |
− | + | pathy.shift(); | |
− | + | } | |
− | + | var c = canvas.width / WIDTH; | |
− | + | pathx.push( balls[0].x*c); | |
− | + | pathy.push( balls[0].y*c); | |
− | + | } | |
ctx.beginPath(); | ctx.beginPath(); | ||
− | + | ctx.lineWidth = 2; | |
ctx.strokeStyle = 'Black'; | ctx.strokeStyle = 'Black'; | ||
− | + | ctx.moveTo(pathx[0], pathy[0]); | |
− | + | for (i=1;i<pathx.length; i++) | |
− | + | { | |
− | + | ctx.lineTo(pathx[i], pathy[i]); | |
+ | } | ||
+ | |||
+ | ctx.stroke(); | ||
} | } | ||
− | |||
− | |||
− | |||
Строка 239: | Строка 292: | ||
timeSpeed++; | timeSpeed++; | ||
} | } | ||
− | </ | + | |
− | </ | + | </script> |
+ | </body> | ||
+ | </html> |