manimgl-best-practices について
ManimGLユーザー向けのリファレンススキルで、シーン構築、アニメーション、レンダリング、対話型開発を扱います。例とManim Communityとの比較により、適切なAPIやコマンドを選べます。
主な機能
- 01シーンとアニメーションの規則
- 02Tex、スタイル、カメラのガイド
- 033Dと対話型開発の解説
- 04検証済みの例とシーンテンプレート
- 05CLI、設定、バージョン比較
活用シーン
- 01ManimGLシーンの作成
- 02対話モードでのデバッグ
- 03ManimGLの構文やコマンドの確認
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ adithya-s-k/ manim_skill --skill manimgl-best-practicesインストール後、Claude Code で/manimgl-best-practicesを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
examples/attention_arcs_animation.pyattention_pattern_dots.pyattention_scenes.pyattention_softmax_masking.pyautoregressive_flow.pybasic_multihead.pybloch_sphere_3d.pyblock_collision_basic.pyblocks_3d.pycollision_phase_space.pycomplex_s_plane.pycost_function.pycube_projection_3d.pydamped_solutions_splane.pydot_product_visualization.pydouble_slit_interference.pyeigenvalue_equations.pyeigenvector_flow_field.pyeigenvector_matrix_transformation.pyelastic_collision_vectors.pyembedding_matrix.pyequation_transforms.pyexponential_derivative.pyfibonacci_eigenvalues.pygradient_descent_basic.pyhexagon_cube_correspondence.pyintegration_visualization.pylaplace_integral.pylight_polarization.pylinear_regression.py詳細
使い方
詳しい説明とコード例については、各ルールファイルをお読みください。
コアコンセプト
- rules/scenes.md - InteractiveScene、Scene の種類、construct メソッド
- rules/mobjects.md - Mobject の種類、VMobject、グループ、配置
- rules/animations.md - Animation クラス、アニメーションの再生、タイミング
作成と変形
- rules/creation-animations.md - ShowCreation、Write、FadeIn、DrawBorderThenFill
- rules/transform-animations.md - Transform、ReplacementTransform、TransformMatchingTex
- rules/animation-groups.md - LaggedStart、Succession、AnimationGroup
テキストと数学
- rules/tex.md - Tex クラス、raw strings R"..."、LaTeX レンダリング
- rules/text.md - Text Mobject、フォント、スタイル設定
- rules/t2c.md - 数式表現の色付けに使う tex_to_color_map (t2c)
スタイルと外観
- rules/colors.md - 色定数、グラデーション、RGB、hex、GLSL による色付け
- rules/styling.md - 塗りつぶし、線、透明度、背面の縁取り、光沢、影
3D とカメラ
- rules/3d.md - 3D オブジェクト、曲面、Sphere、Torus、パラメトリック曲面、ライティング
- rules/camera.md - frame.reorient()、オイラー角、fix_in_frame()、カメラアニメーション
インタラクティブ開発
- rules/interactive.md -
-seフラグを使ったインタラクティブモード、checkpoint_paste() - rules/frame.md - self.frame、カメラ制御、reorient、ズーム
- rules/embedding.md - IPython デバッグ用の self.embed()、touch() モード
設定と CLI
- rules/cli.md - manimgl コマンド、フラグ(-w、-o、-se、-l、-h)、レンダリングオプション
- rules/config.md - custom_config.yml、ディレクトリ、カメラ設定、品質プリセット
動作例
よく使われるパターンを紹介する、完全かつテスト済みのサンプルファイルです。
- examples/basic_animations.py - 基本図形、テキスト、アニメーション
- examples/math_visualization.py - LaTeX の数式と数学的な内容
- examples/graph_plotting.py - 座標軸、関数、グラフ描画
- examples/3d_visualization.py - カメラ制御と曲面を使った 3D シーン
- examples/updater_patterns.py - updater を使った動的なアニメーション
シーンテンプレート
新しいプロジェクトを始める際に、これらのテンプレートをコピーして変更してください。
- templates/basic_scene.py - 標準的な 2D シーンのテンプレート
- templates/interactive_scene.py - self.embed() を使った InteractiveScene
- templates/3d_scene.py - frame.reorient() を使った 3D シーン
- templates/math_scene.py - 数学的な導出と数式
クイックリファレンス
基本的なシーン構造
from manimlib import *
class MyScene(InteractiveScene):
def construct(self):
# Create mobjects
circle = Circle()
# Add to scene (static)
self.add(circle)
# Or animate
self.play(ShowCreation(circle)) # Note: ShowCreation, not Create
# Wait
self.wait(1)
レンダリングコマンド
# Render and preview
manimgl scene.py MyScene
# Interactive mode - drop into shell at line 15
manimgl scene.py MyScene -se 15
# Write to file
manimgl scene.py MyScene -w
# Low quality for testing
manimgl scene.py MyScene -l
ManimCE との主な違い
| 機能 | ManimGL (3b1b) | Manim Community |
|---|---|---|
| インポート | from manimlib import * | from manim import * |
| CLI | manimgl | manim |
| 数式テキスト | Tex(R"\pi") | MathTex(r"\pi") |
| シーン | InteractiveScene | Scene |
| 作成アニメーション | ShowCreation | Create |
| カメラ | self.frame | self.camera.frame |
| フレームに固定 | mob.fix_in_frame() | self.add_fixed_in_frame_mobjects(mob) |
| パッケージ | manimgl (PyPI) | manim (PyPI) |
インタラクティブ開発ワークフロー
ManimGL の最大の特長は、インタラクティブに開発できることです。
# Start at line 20 with state preserved
manimgl scene.py MyScene -se 20
インタラクティブモードでは:
# Copy code to clipboard, then run:
checkpoint_paste() # Run with animations
checkpoint_paste(skip=True) # Run instantly (no animations)
checkpoint_paste(record=True) # Record while running
カメラ制御(self.frame)
# Get the camera frame
frame = self.frame
# Reorient in 3D (phi, theta, gamma, center, height)
frame.reorient(45, -30, 0, ORIGIN, 8)
# Animate camera movement
self.play(frame.animate.reorient(60, -45, 0))
# Fix mobjects to stay in screen space during 3D movement
title.fix_in_frame()
Tex クラスでの LaTeX
# Use raw strings with capital R
formula = Tex(R"\int_0^1 x^2 \, dx = \frac{1}{3}")
# Color mapping with t2c
equation = Tex(
R"E = mc^2",
t2c={"E": BLUE, "m": GREEN, "c": YELLOW}
)
# Isolate substrings for animation
formula = Tex(R"\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}")
formula.set_color_by_tex("n", BLUE)
よく使われるパターン
デバッグ用の埋め込み
def construct(self):
circle = Circle()
self.play(ShowCreation(circle))
self.embed() # Drops into IPython shell here
3D 用の床面を設定する
self.set_floor_plane("xz") # Makes xy the viewing plane
テキストを読みやすくする背面の縁取り
text = Text("Label")
text.set_backstroke(BLACK, 5) # Black outline behind text
インストール
# Install ManimGL
pip install manimgl
# Check installation
manimgl --version
避けるべきよくある落とし穴
- バージョンの混同 -
manim(コミュニティ版)ではなく、manimglを使用していることを確認してください - ShowCreation と Create - ManimGL では
Createではなく、ShowCreationを使用します - Tex と MathTex - ManimGL では、大文字の R を使った raw 文字列で
Texを使用します - self.frame と self.camera.frame - ManimGL では、
self.frameを直接使用します - fix_in_frame() - シーンではなく、mobject に対して呼び出してください
- インタラクティブモード - インタラクティブな開発には
-seフラグを使用してください
ライセンスとクレジット
このスキルには、Grant Sanderson による3Blue1Brown の動画リポジトリをもとに改変したサンプルコードが含まれています。
ライセンス: CC BY-NC-SA 4.0
- クレジット表記が必要 - 3Blue1Brown と改変者の両方を明記してください
- 非営利 - 商用利用はできません
- 継承 - 派生物には同じライセンスを適用する必要があります
詳細はLICENSE.txtを参照してください。
コメント
Markdown 対応