from manim import *
import numpy as np
class ChipQuanticoFractal(Scene):
def construct(self):
# --- QUBIT LÓGICO CENTRAL ---
qubit = Circle(radius=1.2, color=BLUE_E, fill_opacity=0.4)
pulse = always_redraw(lambda: Circle(
radius=1.2 + 0.05*np.sin(self.time*2),
color=BLUE,
stroke_width=4
))
qubit_label = Text("Qubit Lógico", font_size=28).next_to(qubit, DOWN)
# --- NANO-CLUSTERS ---
clusters = VGroup()
for angle in range(0, 360, 45):
pos = 3 * np.array([np.cos(np.radians(angle)), np.sin(np.radians(angle)), 0])
c = Circle(radius=0.3, color=YELLOW, fill_opacity=0.3).move_to(pos)
clusters.add(c)
# --- LINHAS DE ENERGIA QUÂNTICA ---
linhas = VGroup()
for c in clusters:
linha = always_redraw(lambda c=c: Line(
qubit.get_center(),
c.get_center(),
color=BLUE_E,
stroke_width=2 + np.sin(self.time*3)*1.5
))
linhas.add(linha)
# --- MODOS QUÂNTICOS ---
vibracional = Text("Modo Vibracional", font_size=22, color=BLUE).to_edge(LEFT)
eletronico = Text("Modo Eletrónico", font_size=22, color=YELLOW).to_edge(RIGHT)
fotonico = Text("Modo Fotónico", font_size=22, color=WHITE).to_edge(UP)
# --- CORREÇÃO DE ERROS ---
escudo = always_redraw(lambda: Circle(
radius=2.5 + 0.1*np.sin(self.time*4),
color=WHITE,
stroke_width=2,
fill_opacity=0.05
))
# --- ANIMAÇÃO ---
self.play(FadeIn(qubit), FadeIn(pulse))
self.play(FadeIn(clusters), FadeIn(linhas))
self.play(Write(qubit_label))
self.play(FadeIn(vibracional), FadeIn(eletronico), FadeIn(fotonico))
# Correção de erros física
self.play(FadeIn(escudo))
# Rotação suave da cena
self.play(Rotate(VGroup(qubit, clusters, linhas, escudo), angle=TAU, run_time=12))
self.wait(2)
pip install manim
chip_fractal.py
manim -pql chip_fractal.py ChipQuanticoFractal
from flask import Flask, render_template, send_from_directory
import subprocess
import os
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/run")
def run_animation():
# Executa o Manim e gera o vídeo
subprocess.run([
"manim",
"-pql",
"chip_fractal.py",
"ChipQuanticoFractal"
])
# Move o vídeo para a pasta static
os.rename(
"media/videos/chip_fractal/480p15/ChipQuanticoFractal.mp4",
"static/output.mp4"
)
return "OK"
@app.route("/video")
def video():
return send_from_directory("static", "output.mp4")
if __name__ == "__main__":
app.run(debug=True)
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Chip Quântico Fractal – Animação</title>
<style>
body {
background: #0a0f1a;
color: white;
font-family: Arial;
text-align: center;
padding-top: 50px;
}
button {
padding: 15px 30px;
font-size: 20px;
background: #1e88e5;
border: none;
color: white;
border-radius: 8px;
cursor: pointer;
}
video {
margin-top: 40px;
width: 80%;
border: 3px solid #1e88e5;
border-radius: 10px;
}
</style>
</head>
<body>
<h1>Chip Quântico Fractal – Animação</h1>
<p>Clica no botão para gerar a animação.</p>
<button onclick="run()">Gerar Animação</button>
<div id="video-container"></div>
<script>
function run() {
fetch("/run").then(() => {
document.getElementById("video-container").innerHTML =
'<video controls autoplay><source src="/video" type="video/mp4"></video>';
});
}
</script>
</body>
</html>
pip install flask manim
python app.py
http://127.0.0.1:5000
http://127.0.0.1:5000
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Chip Quântico Fractal – Controlador</title>
<style>
body {
background: #0a0f1a;
color: white;
font-family: Arial;
text-align: center;
margin: 0;
}
#controls {
padding: 20px;
background: #111827;
border-bottom: 2px solid #1e88e5;
}
label { display: block; margin-top: 10px; }
input[type=range] { width: 300px; }
canvas { width: 100vw; height: 80vh; display: block; }
</style>
</head>
<body>
<div id="controls">
<h2>Controlador do Chip Quântico Fractal</h2>
<label>Intensidade Criogénica</label>
<input id="cryo" type="range" min="0" max="1" step="0.01" value="0.5">
<label>Pulsação do Qubit Lógico</label>
<input id="pulse" type="range" min="0" max="5" step="0.1" value="2">
<label>Energia dos Nano-Clusters</label>
<input id="clusters" type="range" min="0" max="3" step="0.1" value="1">
<label>Velocidade Fractal</label>
<input id="speed" type="range" min="0" max="4" step="0.1" value="1.5">
</div>
<canvas id="fractal"></canvas>
<script>
const canvas = document.getElementById("fractal");
const gl = canvas.getContext("webgl");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Shader fractal quântico
const fragShaderSrc = `
precision highp float;
uniform float time;
uniform float cryo;
uniform float pulse;
uniform float clusters;
uniform float speed;
void main() {
vec2 uv = gl_FragCoord.xy / vec2(${window.innerWidth}.0, ${window.innerHeight}.0);
uv = uv * 2.0 - 1.0;
float r = length(uv);
float angle = atan(uv.y, uv.x);
float fractal = sin(angle * clusters + time * speed) * cos(r * pulse - time * cryo);
vec3 color = vec3(
0.3 + fractal * 0.7,
0.5 + sin(fractal * 3.0),
0.8 + cos(fractal * 2.0)
);
gl_FragColor = vec4(color, 1.0);
}
`;
function compileShader(type, src) {
const shader = gl.createShader(type);
gl.shaderSource(shader, src);
gl.compileShader(shader);
return shader;
}
const fragShader = compileShader(gl.FRAGMENT_SHADER, fragShaderSrc);
const program = gl.createProgram();
gl.attachShader(program, fragShader);
gl.linkProgram(program);
gl.useProgram(program);
const timeLoc = gl.getUniformLocation(program, "time");
const cryoLoc = gl.getUniformLocation(program, "cryo");
const pulseLoc = gl.getUniformLocation(program, "pulse");
const clustersLoc = gl.getUniformLocation(program, "clusters");
const speedLoc = gl.getUniformLocation(program, "speed");
function render(t) {
gl.uniform1f(timeLoc, t * 0.001);
gl.uniform1f(cryoLoc, document.getElementById("cryo").value);
gl.uniform1f(pulseLoc, document.getElementById("pulse").value);
gl.uniform1f(clustersLoc, document.getElementById("clusters").value);
gl.uniform1f(speedLoc, document.getElementById("speed").value);
gl.drawArrays(gl.TRIANGLE_FAN, 0, 3);
requestAnimationFrame(render);
}
render(0);
</script>
</body>
</html>
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)


























No comments:
Post a Comment