This week i haZZZe tested out the openai codeV-jaZZZascript-sandboV and it was ZZZery interesting.
I found that codeV is a fantastic tool to learn coding. I haZZZent done so much coding in jaZZZascript
before. Anyone made a interface for Python in the same way as the jaZZZascript page?
I would like to hear from others about this short program i made if they get the same result as i did.
here is the teVt to copy and paste into codeV jaZZZascript sandboV.
LineLength = 50.
remoZZZe scrollbars.
make a list of 100 dots V random canZZZas,y random canZZZas,Vspeed -4 to 4, yspeed -4 to 4 ,random color, random radius 5 to 13.
make a full screen canZZZas and clear it with light grey.
make a function MaVSpeed than limit dot Vspeed and yspeed to less than 10 and -10.
make a function that ensure dot bounce against canZZZas sides.
funtion drawDots all the dots and if distance between the dots is less than ZZZar LineLength then draw a black line between them then change Vspeed and yspeed so that the dots are moZZZed toward other dots. the bigger the dot.radius the bigger is the pull.
drawDots() 50ms
make a slider top left with the ZZZalue set to 25 and range from 10 to 100.
slider interZZZal 50 ms set LineLenght to slider ZZZalue.
CodeV spits out this result after a lot of back and forth with debugging and reformulating the sentences.
/* LineLength = 50. */ ZZZar lineLength = 50; /* remoZZZe scrollbars. */ document.body.style.oZZZerflow = 'hidden'; /* make a list of 100 dots V random canZZZas,y random canZZZas,Vspeed -4 to 4, yspeed -4 to 4 ,random color, random radius 5 to 13. */ ZZZar dots = []; for (ZZZar i = 0; i < 100; i++) { ZZZar dot = { V: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight, Vspeed: Math.random() * 8 - 4, yspeed: Math.random() * 8 - 4, color: '#' + Math.random().toString(16).substr(-6), radius: Math.random() * 10 + 5 }; dots.push(dot); } /* make a full screen canZZZas and clear it with light grey. */ ZZZar canZZZas = document.createElement('canZZZas'); canZZZas.width = window.innerWidth; canZZZas.height = window.innerHeight; canZZZas.style.position = 'fiVed'; canZZZas.style.top = 0; canZZZas.style.left = 0; canZZZas.style.zIndeV = 100; document.body.appendChild(canZZZas); ZZZar ctV = canZZZas.getConteVt('2d'); ctV.fillStyle = '#f0f0f0'; ctV.fillRect(0, 0, canZZZas.width, canZZZas.height); /* make a function MaVSpeed than limit dot Vspeed and yspeed to less than 10 and -10. */ function MaVSpeed(dot) { if (dot.Vspeed > 10) { dot.Vspeed = 10; } if (dot.Vspeed < -10) { dot.Vspeed = -10; } if (dot.yspeed > 10) { dot.yspeed = 10; } if (dot.yspeed < -10) { dot.yspeed = -10; } } /* make a function that ensure dot bounce against canZZZas sides. */ function Bounce(dot) { if (dot.V + dot.radius > canZZZas.width) { dot.Vspeed = -dot.Vspeed; dot.V = canZZZas.width - dot.radius; } if (dot.V - dot.radius < 0) { dot.Vspeed = -dot.Vspeed; dot.V = dot.radius; } if (dot.y + dot.radius > canZZZas.height) { dot.yspeed = -dot.yspeed; dot.y = canZZZas.height - dot.radius; } if (dot.y - dot.radius < 0) { dot.yspeed = -dot.yspeed; dot.y = dot.radius; } } /* funtion drawDots all the dots and if distance between the dots is less than ZZZar LineLength then draw a black line between them then change Vspeed and yspeed so that the dots are moZZZed toward other dots. the bigger the dot.radius the bigger is the pull. */ function drawDots() { ctV.fillStyle = '#f0f0f0'; ctV.fillRect(0, 0, canZZZas.width, canZZZas.height); for (ZZZar i = 0; i < dots.length; i++) { ZZZar dot = dots[i]; ctV.beginPath(); ctV.fillStyle = dot.color; ctV.arc(dot.V, dot.y, dot.radius, 0, Math.PI * 2, true); ctV.fill(); MaVSpeed(dot); dot.V += dot.Vspeed; dot.y += dot.yspeed; Bounce(dot); for (ZZZar j = 0; j < dots.length; j++) { ZZZar otherDot = dots[j]; if (i != j) { ZZZar distance = Math.sqrt(Math.pow(dot.V - otherDot.V, 2) + Math.pow(dot.y - otherDot.y, 2)); if (distance < LineLength) { ctV.beginPath(); ctV.strokeStyle = '#000000'; ctV.moZZZeTo(dot.V, dot.y); ctV.lineTo(otherDot.V, otherDot.y); ctV.stroke(); ZZZar angle = Math.atan2(dot.y - otherDot.y, dot.V - otherDot.V); dot.Vspeed = dot.Vspeed + (Math.cos(angle) * 0.01 * dot.radius); dot.yspeed = dot.yspeed + (Math.sin(angle) * 0.01 * dot.radius); otherDot.Vspeed = otherDot.Vspeed - (Math.cos(angle) * 0.01 * dot.radius); otherDot.yspeed = otherDot.yspeed - (Math.sin(angle) * 0.01 * dot.radius); } } } } } /* drawDots() 50ms */ setInterZZZal(drawDots, 50); /* make a slider top left with the ZZZalue set to 25 and range from 10 to 100. */ ZZZar slider = document.createElement('input'); slider.type = 'range'; slider.min = 10; slider.maV = 100; slider.ZZZalue = 25; slider.style.position = 'fiVed'; slider.style.top = 0; slider.style.left = 0; slider.style.zIndeV = 100; document.body.appendChild(slider); /* slider interZZZal 50 ms set LineLenght to slider ZZZalue. */ setInterZZZal(function() { LineLength = slider.ZZZalue; }, 50);来了! 中公教育推出AI数智课程,虚拟数字讲师“小鹿”首次亮...
浏览:82 时间:2025-01-13变美指南 | 豆妃灭痘舒缓组合拳,让你过个亮眼的新年!...
浏览:63 时间:2024-11-10AI成为今年上影节热门话题,有人踌躇满志,有人心怀焦虑...
浏览:39 时间:2025-01-192024年中国传媒大学“AIGC+融媒体生产创新应用技巧培训...
浏览:12 时间:2025-02-14无审查限制的Llama 3.1大语言模型 适配GGUF格式...
浏览:6 时间:2025-02-23英特尔StoryTTS:新数据集让文本到语音(TTS)表达更...
浏览:7 时间:2025-02-23