A collection of utility functions to for creating CAD-like visuals in Manim.
Project description
Manim CAD drawing utils
This is a collecion of various functions and utilities that help creating manimations that look like CAD drawings. Also some other stuff that just looks cool.
Features:
- Round corners
- Chamfer corners
- Dimensions
- Dashed line, dashed mobject
- Path offset mapping
Installation
manim-CAD_Drawing_Utils
is a package on pypi, and can be directly installed using pip:
pip install manim-CAD_Drawing_Utils
Note: CAD_Drawing_Utils
uses, and depends on SciPy and Manim.
Usage
Make sure include these two imports at the top of the .py file
from manim import *
from manim_cad_drawing_utils import *
Examples
rounded corners
class Test_round(Scene):
def construct(self):
mob1 = RegularPolygon(n=4,radius=1.5,color=PINK).rotate(PI/4)
mob2 = Triangle(radius=1.5,color=TEAL)
# making a cross
crbase = Rectangle(height=0.5,width=3)
mob3 = Union(crbase.copy().rotate(PI/4),crbase.copy().rotate(-PI/4),color=BLUE)
mob4 = Circle(radius=1.3)
mob2.shift(2.5*UP)
mob3.shift(2.5*DOWN)
mob1.shift(2.5*LEFT)
mob4.shift(2.5*RIGHT)
mob1 = round_corners(mob1, 0.25)
mob2 = round_corners(mob2, 0.25)
mob3 = round_corners(mob3, 0.25)
self.add(mob1,mob2,mob3,mob4)
cut off corners
class Test_chamfer(Scene):
def construct(self):
mob1 = RegularPolygon(n=4,radius=1.5,color=PINK).rotate(PI/4)
mob2 = Triangle(radius=1.5,color=TEAL)
crbase = Rectangle(height=0.5,width=3)
mob3 = Union(crbase.copy().rotate(PI/4),crbase.copy().rotate(-PI/4),color=BLUE)
mob4 = Circle(radius=1.3)
mob2.shift(2.5*UP)
mob3.shift(2.5*DOWN)
mob1.shift(2.5*LEFT)
mob4.shift(2.5*RIGHT)
mob1 = chamfer_corners(mob1, 0.25)
mob2 = chamfer_corners(mob2,0.25)
mob3 = chamfer_corners(mob3, 0.25)
self.add(mob1,mob2,mob3,mob4)
pointer
class test_dimension_pointer(Scene):
def construct(self):
mob1 = round_corners(Triangle().scale(2),0.3)
p = ValueTracker(0)
dim1 = Pointer_To_Mob(mob1,p.get_value(),r'triangel')
dim1.add_updater(lambda mob: mob.update_mob(mob1,p.get_value()))
dim1.update()
PM = Path_mapper(mob1)
self.play(Create(mob1),rate_func=PM.equalize_rate_func(smooth))
self.play(Create(dim1))
self.play(p.animate.set_value(1),run_time=10)
self.play(Uncreate(mob1,rate_func=PM.equalize_rate_func(smooth)))
self.play(Uncreate(dim1))
self.wait()
dimension
class test_dimension_base(Scene):
def construct(self):
mob1 = round_corners(Triangle().scale(2),0.3)
dim1 = Linear_Dimension(mob1.get_critical_point(UP),
mob1.get_critical_point(DOWN),
direction=RIGHT,
offset=3,
color=RED)
dim2 = Linear_Dimension(mob1.get_critical_point(RIGHT),
mob1.get_critical_point(LEFT),
direction=UP,
offset=-3,
color=RED)
self.add(mob1,dim1,dim2)
hatching
class test_hatch(Scene):
def construct(self):
mob1 = Star().scale(2)
hatch1 = Hatch_lines(mob1,angle=PI/6,stroke_width=2)
hatch2 = Hatch_lines(mob1,angle=PI/6+PI/2,stroke_width=2)
self.add(mob1,hatch1,hatch2)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for manim-CAD_Drawing_Utils-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6d1e0af5d4482a559512bb0528d4c434300c5c209e3385a5226d2e081a8574f |
|
MD5 | 8766e36892d0985aee7cee8488704869 |
|
BLAKE2b-256 | d7c05f8822b1ea7a1cf144b65dc57c44ef20ac21f31cef744ddbda1851737cbc |
Close
Hashes for manim_CAD_Drawing_Utils-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa0bb66ce21530ee1eddbc133115a72ba614ab4ddd5243b6f8c397b1917dfaf5 |
|
MD5 | a18de52ce08412c6ed21b368a67197ff |
|
BLAKE2b-256 | 93e4705239057e74efe37a2288b58e8e6f3f3ba3120b73d0a48139bb67363b0f |