сделай солнечную систему на p5js
- User
сделай солнечную систему на p5js
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
сделай солнечную систему на p5js
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Вот пример простой модели Солнечной системы на p5.js:
let sun;
let planets = [];
function setup() {
createCanvas(800, 600);
background(0);
// Создаем Солнце
sun = {
x: width / 2,
y: height / 2,
radius: 30,
color: color(255, 204, 0)
};
// Создаем планеты
let planetData = [
{ name: 'Меркурий', radius: 3, orbit: 60, speed: 0.05, color: color(128, 128, 128) },
{ name: 'Венера', radius: 8, orbit: 100, speed: 0.03, color: color(255, 204, 153) },
{ name: 'Земля', radius: 10, orbit: 140, speed: 0.02, color: color(0, 0, 255) },
{ name: 'Марс', radius: 6, orbit: 180, speed: 0.018, color: color(255, 0, 0) },
{ name: 'Юпитер', radius: 20, orbit: 280, speed: 0.008, color: color(204, 153, 0) },
{ name: 'Сатурн', radius: 18, orbit: 340, speed: 0.006, color: color(200, 150, 100) },
{ name: 'Уран', radius: 14, orbit: 400, speed: 0.004, color: color(0, 150, 200) },
{ name: 'Нептун', radius: 12, orbit: 460, speed: 0.003, color: color(0, 0, 150) }
];
for (let i = 0; i < planetData.length; i++) {
let planet = {
name: planetData[i].name,
radius: planetData[i].radius,
orbit: planetData[i].orbit,
speed: planetData[i].speed,
angle: random(TWO_PI),
color: planetData[i].color,
x: sun.x + cos(0) * planetData[i].orbit,
y: sun.y + sin(0) * planetData[i].orbit
};
planets.push(planet);
}
}
function draw() {
background(0);
// Рисуем Солнце
fill(sun.color);
noStroke();
ellipse(sun.x, sun.y, sun.radius * 2);
// Обновляем и рисуем планеты
for (let i = 0; i < planets.length; i++) {
let planet = planets[i];
// Обновляем позицию планеты
planet.angle += planet.speed;
planet.x = sun.x + cos(planet.angle) * planet.orbit;
planet.y = sun.y + sin(planet.angle) * planet.orbit;
// Рисуем планету
fill(planet.color);
noStroke();
ellipse(planet.x, planet.y, planet.radius * 2);
// Рисуем орбиту планеты
noFill();
stroke(50);
ellipse(sun.x, sun.y, planet.orbit * 2);
// Выводим название планеты
fill(255);
noStroke();
textSize(12);
text(planet.name, planet.x + planet.radius + 5, planet.y);
}
}
Эта модель включает:
Чтобы улучшить модель, можно:
Для более реалистичной модели можно использовать данные из астрономических источников и учитывать различные факторы, такие как:
Эта базовая модель дает общее представление о структуре Солнечной системы и может быть расширена и улучшена для образовательных или демонстрационных целей.