{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Resolution and Camera \n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from manim import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Scene Coordinates\n", "First, let's learn a bit about how manim coordinates work. \n", "There is the config.frame_width, config.frame_height which is unrelated to the pixelsize. \n", "Their default values are 14.222 and 8. \n", "These values are chosen, because it gives and width/height ratio of 16/9, which is a common screen resolution. \n", "The coordinate center of scenes is in the center, which is at **(0,0)**. \n", "The most left point is **(-7.1,0)**, right is **(7.1,0)**, top is **(0,4)**, and button is **(0,-4)**." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "config.frame_width/config.frame_height " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "config.pixel_width/config.pixel_height " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "16/9" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# for setup only\n", "def yellow_frame_annotation(framew, frameh):\n", " d1 = DoubleArrow(framew * LEFT / 2, framew * RIGHT / 2, buff=0).to_edge(DOWN)\n", " t1 = Text(str(framew)[:6]).next_to(d1, UP)\n", " d2 = DoubleArrow(frameh * UP / 2, frameh * DOWN / 2, buff=0).to_edge(LEFT)\n", " t2= Text(str(frameh)).next_to(d2, RIGHT)\n", " x=Group(d1,d2,t1,t2).set_color(YELLOW)\n", " return x\n", "\n", "def blue_pixel_annotation(framew, frameh,pixelw, pixelh):\n", " d1 = DoubleArrow(framew * LEFT / 2, framew * RIGHT / 2, buff=0).to_edge(UP)\n", " t1 = Text(str(pixelw) + \" pixel\").next_to(d1, DOWN)\n", " d2 = DoubleArrow(frameh * UP / 2, frameh * DOWN / 2, buff=0).to_edge(RIGHT)\n", " t2= Text(str(pixelh) + \" pixel\").next_to(d2, LEFT)\n", " x=Group(d1,d2,t1,t2).set_color(BLUE)\n", " return x\n", "\n", "annulus = Annulus(inner_radius =1,outer_radius=2,color=WHITE, stroke_width=10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Pixel Ratio of 16/9\n", "See a table of commen 16/9 resolutions here: https://en.wikipedia.org/wiki/16:9_aspect_ratio#Common_resolutions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%manim -v WARNING -s -r 160,90 --disable_caching Example\n", "class Example(Scene):\n", " def construct(self):\n", " frame_annotation= yellow_frame_annotation(config.frame_width,config.frame_height)\n", " pixel_annotation= blue_pixel_annotation(config.frame_width,config.frame_height,config.pixel_width,config.pixel_height)\n", " self.add(frame_annotation, pixel_annotation, annulus)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%manim -v WARNING -s -r 256,144 --disable_caching Example\n", "class Example(Scene):\n", " def construct(self):\n", " frame_annotation= yellow_frame_annotation(config.frame_width,config.frame_height)\n", " pixel_annotation= blue_pixel_annotation(config.frame_width,config.frame_height,config.pixel_width,config.pixel_height)\n", " self.add(frame_annotation, pixel_annotation, annulus)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%manim -v WARNING -s -ql --disable_caching Example\n", "class Example(Scene):\n", " def construct(self):\n", " frame_annotation= yellow_frame_annotation(config.frame_width,config.frame_height)\n", " pixel_annotation= blue_pixel_annotation(config.frame_width,config.frame_height,config.pixel_width,config.pixel_height)\n", " self.add(frame_annotation, pixel_annotation, annulus)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%manim -v WARNING -s -qm --disable_caching Example\n", "class Example(Scene):\n", " def construct(self):\n", " frame_annotation= yellow_frame_annotation(config.frame_width,config.frame_height)\n", " pixel_annotation= blue_pixel_annotation(config.frame_width,config.frame_height,config.pixel_width,config.pixel_height)\n", " self.add(frame_annotation, pixel_annotation, annulus)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "