fasdfsa commited on
Commit
d7caad3
·
1 Parent(s): 9f360d9

DifferentConceptions ok

Browse files
assets/house.svg ADDED

Git LFS Details

  • SHA256: 296604cd60ed7c18b26da69efcef38597f05995a59d4f93afb95fe31edac3099
  • Pointer size: 129 Bytes
  • Size of remote file: 1.33 kB
manim.py CHANGED
@@ -29,9 +29,11 @@ if __name__ == "__main__":
29
  # sys.argv.extend(['old_projects/eola/chapter0.py', 'AboutPacing', '-pl'])
30
  # sys.argv.extend(['old_projects/eola/chapter0.py', 'DifferingBackgrounds', '-pl'])
31
  # sys.argv.extend(['old_projects/eola/chapter0.py', 'PauseAndPonder', '-pl'])
32
- sys.argv.extend(['old_projects/eola/chapter0.py', 'NextVideo', '-pl'])
33
 
34
 
 
 
35
 
36
 
37
  manimlib.main()
 
29
  # sys.argv.extend(['old_projects/eola/chapter0.py', 'AboutPacing', '-pl'])
30
  # sys.argv.extend(['old_projects/eola/chapter0.py', 'DifferingBackgrounds', '-pl'])
31
  # sys.argv.extend(['old_projects/eola/chapter0.py', 'PauseAndPonder', '-pl'])
32
+ # sys.argv.extend(['old_projects/eola/chapter0.py', 'NextVideo', '-pl'])
33
 
34
 
35
+ # sys.argv.extend(['old_projects/eola/chapter1.py', 'OpeningQuote', '-pl'])
36
+ sys.argv.extend(['old_projects/eola/chapter1.py', 'DifferentConceptions', '-pl'])
37
 
38
 
39
  manimlib.main()
manimlib/mobject/svg/svg_mobject.py CHANGED
@@ -172,7 +172,10 @@ class SVGMobject(VMobject):
172
  stroke_color = rect_element.getAttribute("stroke")
173
  stroke_width = rect_element.getAttribute("stroke-width")
174
  corner_radius = rect_element.getAttribute("rx")
175
-
 
 
 
176
  # input preprocessing
177
  if fill_color in ["", "none", "#FFF", "#FFFFFF"] or Color(fill_color) == Color(WHITE):
178
  opacity = 0
 
172
  stroke_color = rect_element.getAttribute("stroke")
173
  stroke_width = rect_element.getAttribute("stroke-width")
174
  corner_radius = rect_element.getAttribute("rx")
175
+
176
+ # 设置默认的opacity值
177
+ opacity = self.fill_opacity # 使用类的默认fill_opacity值
178
+
179
  # input preprocessing
180
  if fill_color in ["", "none", "#FFF", "#FFFFFF"] or Color(fill_color) == Color(WHITE):
181
  opacity = 0
old_projects/eola/chapter1.py CHANGED
@@ -48,7 +48,7 @@ class DifferentConceptions(Scene):
48
  physy.title = TextMobject("Physics student").to_corner(DOWN+LEFT)
49
  compy.title = TextMobject("CS student").to_corner(DOWN+RIGHT)
50
  mathy.title = TextMobject("Mathematician").to_edge(DOWN)
51
- names = VMobject(physy.title, mathy.title, compy.title)
52
  names.arrange(RIGHT, buff = 1)
53
  names.to_corner(DOWN+LEFT)
54
  for pi in creatures:
@@ -69,7 +69,7 @@ class DifferentConceptions(Scene):
69
 
70
  def intro_vector(self):
71
  plane = NumberPlane()
72
- labels = VMobject(*plane.get_coordinate_labels())
73
  vector = Vector(RIGHT+2*UP, color = YELLOW)
74
  coordinates = vector_coordinate_label(vector)
75
  symbol = TexMobject("\\vec{\\textbf{v}}")
@@ -108,7 +108,7 @@ class DifferentConceptions(Scene):
108
  brace = Brace(vector, DOWN)
109
  length = TextMobject("Length")
110
  length.next_to(brace, DOWN)
111
- group = VMobject(vector, brace, length)
112
  group.rotate_in_place(np.pi/6)
113
  vector.get_center = lambda : vector.get_start()
114
 
@@ -121,7 +121,7 @@ class DifferentConceptions(Scene):
121
  two_dimensional.to_corner(UP+RIGHT)
122
  three_dimensional.to_corner(UP+RIGHT)
123
 
124
- random_vectors = VMobject(*[
125
  Vector(
126
  random.uniform(-2, 2)*RIGHT + \
127
  random.uniform(-2, 2)*UP
@@ -182,11 +182,12 @@ class DifferentConceptions(Scene):
182
  title = TextMobject("Vectors $\\Leftrightarrow$ lists of numbers")
183
  title.to_edge(UP)
184
 
185
- vectors = VMobject(*list(map(matrix_to_mobject, [
186
  [2, 1],
187
  [5, 0, 0, -3],
188
  [2.3, -7.1, 0.1],
189
  ])))
 
190
  vectors.arrange(RIGHT, buff = 1)
191
  vectors.to_edge(LEFT)
192
 
@@ -223,13 +224,36 @@ class DifferentConceptions(Scene):
223
  price.next_to(price_words)
224
  price.set_color(GREEN)
225
 
226
- vector = Matrix([square_footage.copy(), price.copy()])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  vector.next_to(house, RIGHT).shift(0.25*UP)
228
- new_square_footage, new_price = vector.get_mob_matrix().flatten()
 
 
 
229
  not_equals = TexMobject("\\ne")
230
  not_equals.next_to(vector)
231
  alt_vector = Matrix([
232
- TextMobject("300{,}000\\text{ ft}^2").set_color(RED),
233
  TextMobject("\\$2{,}600").set_color(GREEN)
234
  ])
235
  alt_vector.next_to(not_equals)
@@ -237,7 +261,7 @@ class DifferentConceptions(Scene):
237
  brace = Brace(vector, RIGHT)
238
  two_dimensional = TextMobject("2 dimensional")
239
  two_dimensional.next_to(brace)
240
- brackets = vector.get_brackets()
241
 
242
  self.play(Transform(starter_mobject, house))
243
  self.remove(starter_mobject)
@@ -272,7 +296,7 @@ class DifferentConceptions(Scene):
272
  )
273
  self.wait()
274
 
275
- everything = VMobject(
276
  house, square_footage, price, brackets, brace,
277
  two_dimensional, title
278
  )
@@ -292,14 +316,14 @@ class DifferentConceptions(Scene):
292
  w_arrow = Vector([2, 1])
293
  w_arrow.shift(v_arrow.get_end())
294
  sum_arrow = Vector(w_arrow.get_end())
295
- arrows = VMobject(v_arrow, w_arrow, sum_arrow)
296
  arrows.scale(0.7)
297
  arrows.to_edge(LEFT, buff = 2)
298
 
299
  v_array = matrix_to_mobject([3, -5])
300
  w_array = matrix_to_mobject([2, 1])
301
  sum_array = matrix_to_mobject(["3+2", "-5+1"])
302
- arrays = VMobject(
303
  v_array, TexMobject("+"), w_array, TexMobject("="), sum_array
304
  )
305
  arrays.arrange(RIGHT)
@@ -308,7 +332,7 @@ class DifferentConceptions(Scene):
308
 
309
  v_sym = TexMobject("\\vec{\\textbf{v}}")
310
  w_sym = TexMobject("\\vec{\\textbf{w}}")
311
- syms = VMobject(v_sym, TexMobject("+"), w_sym)
312
  syms.arrange(RIGHT)
313
  syms.center().shift(2*UP)
314
 
@@ -319,9 +343,9 @@ class DifferentConceptions(Scene):
319
  circle = Circle()
320
  circle.shift(syms.get_bottom())
321
 
322
- VMobject(v_arrow, v_array, v_sym).set_color(v_color)
323
- VMobject(w_arrow, w_array, w_sym).set_color(w_color)
324
- VMobject(sum_arrow, sum_array).set_color(sum_color)
325
 
326
  self.play(
327
  Write(syms), Write(arrays),
@@ -342,7 +366,7 @@ class DifferentConceptions(Scene):
342
 
343
 
344
  def add_scaling(self, arrows, syms, arrays):
345
- s_arrows = VMobject(
346
  TexMobject("2"), Vector([1, 1]).set_color(YELLOW),
347
  TexMobject("="), Vector([2, 2]).set_color(WHITE)
348
  )
@@ -350,7 +374,7 @@ class DifferentConceptions(Scene):
350
  s_arrows.scale(0.75)
351
  s_arrows.next_to(arrows, DOWN)
352
 
353
- s_arrays = VMobject(
354
  TexMobject("2"),
355
  matrix_to_mobject([3, -5]).set_color(YELLOW),
356
  TextMobject("="),
@@ -360,7 +384,7 @@ class DifferentConceptions(Scene):
360
  s_arrays.scale(0.75)
361
  s_arrays.next_to(arrays, DOWN)
362
 
363
- s_syms = TexMobject(["2", "\\vec{\\textbf{v}}"])
364
  s_syms.split()[-1].set_color(YELLOW)
365
  s_syms.next_to(syms, DOWN)
366
 
@@ -374,7 +398,7 @@ class DifferentConceptions(Scene):
374
 
375
  def fade_all_but(self, creatures, index):
376
  self.play(*[
377
- FadeOut(VMobject(pi, pi.title))
378
  for pi in creatures[:index] + creatures[index+1:]
379
  ])
380
 
@@ -1242,7 +1266,7 @@ class NextVideo(Scene):
1242
 
1243
  self.add(title)
1244
  self.play(ShowCreation(rect))
1245
- self.wait()
1246
 
1247
 
1248
 
 
48
  physy.title = TextMobject("Physics student").to_corner(DOWN+LEFT)
49
  compy.title = TextMobject("CS student").to_corner(DOWN+RIGHT)
50
  mathy.title = TextMobject("Mathematician").to_edge(DOWN)
51
+ names = VGroup(physy.title, mathy.title, compy.title)
52
  names.arrange(RIGHT, buff = 1)
53
  names.to_corner(DOWN+LEFT)
54
  for pi in creatures:
 
69
 
70
  def intro_vector(self):
71
  plane = NumberPlane()
72
+ labels = VGroup(*plane.get_coordinate_labels())
73
  vector = Vector(RIGHT+2*UP, color = YELLOW)
74
  coordinates = vector_coordinate_label(vector)
75
  symbol = TexMobject("\\vec{\\textbf{v}}")
 
108
  brace = Brace(vector, DOWN)
109
  length = TextMobject("Length")
110
  length.next_to(brace, DOWN)
111
+ group = VGroup(vector, brace, length)
112
  group.rotate_in_place(np.pi/6)
113
  vector.get_center = lambda : vector.get_start()
114
 
 
121
  two_dimensional.to_corner(UP+RIGHT)
122
  three_dimensional.to_corner(UP+RIGHT)
123
 
124
+ random_vectors = VGroup(*[
125
  Vector(
126
  random.uniform(-2, 2)*RIGHT + \
127
  random.uniform(-2, 2)*UP
 
182
  title = TextMobject("Vectors $\\Leftrightarrow$ lists of numbers")
183
  title.to_edge(UP)
184
 
185
+ vectors = VGroup(*list(map(matrix_to_mobject, [
186
  [2, 1],
187
  [5, 0, 0, -3],
188
  [2.3, -7.1, 0.1],
189
  ])))
190
+
191
  vectors.arrange(RIGHT, buff = 1)
192
  vectors.to_edge(LEFT)
193
 
 
224
  price.next_to(price_words)
225
  price.set_color(GREEN)
226
 
227
+ # 使用VGroup替代MobjectMatrix
228
+ vector_elements = VGroup(square_footage.copy(), price.copy())
229
+ vector_elements.arrange(DOWN, buff=0.5) # 垂直排列
230
+
231
+ # 添加括号
232
+ l_bracket = TexMobject("\\big[")
233
+ r_bracket = TexMobject("\\big]")
234
+ l_bracket.scale(2)
235
+ r_bracket.scale(2)
236
+
237
+ # 调整括号高度以匹配向量元素
238
+ bracket_height = vector_elements.get_height() + 0.5
239
+ l_bracket.stretch_to_fit_height(bracket_height)
240
+ r_bracket.stretch_to_fit_height(bracket_height)
241
+
242
+ # 定位括号
243
+ l_bracket.next_to(vector_elements, LEFT, buff=0.1)
244
+ r_bracket.next_to(vector_elements, RIGHT, buff=0.1)
245
+
246
+ # 创建完整的向量显示
247
+ vector = VGroup(l_bracket, vector_elements, r_bracket)
248
  vector.next_to(house, RIGHT).shift(0.25*UP)
249
+
250
+ # 获取向量元素用于后续操作
251
+ new_square_footage, new_price = vector_elements.submobjects
252
+
253
  not_equals = TexMobject("\\ne")
254
  not_equals.next_to(vector)
255
  alt_vector = Matrix([
256
+ TextMobject("300{,}000 ft$^2$").set_color(RED),
257
  TextMobject("\\$2{,}600").set_color(GREEN)
258
  ])
259
  alt_vector.next_to(not_equals)
 
261
  brace = Brace(vector, RIGHT)
262
  two_dimensional = TextMobject("2 dimensional")
263
  two_dimensional.next_to(brace)
264
+ brackets = VGroup(l_bracket, r_bracket) # 用于后续引用
265
 
266
  self.play(Transform(starter_mobject, house))
267
  self.remove(starter_mobject)
 
296
  )
297
  self.wait()
298
 
299
+ everything = VGroup(
300
  house, square_footage, price, brackets, brace,
301
  two_dimensional, title
302
  )
 
316
  w_arrow = Vector([2, 1])
317
  w_arrow.shift(v_arrow.get_end())
318
  sum_arrow = Vector(w_arrow.get_end())
319
+ arrows = VGroup(v_arrow, w_arrow, sum_arrow)
320
  arrows.scale(0.7)
321
  arrows.to_edge(LEFT, buff = 2)
322
 
323
  v_array = matrix_to_mobject([3, -5])
324
  w_array = matrix_to_mobject([2, 1])
325
  sum_array = matrix_to_mobject(["3+2", "-5+1"])
326
+ arrays = VGroup(
327
  v_array, TexMobject("+"), w_array, TexMobject("="), sum_array
328
  )
329
  arrays.arrange(RIGHT)
 
332
 
333
  v_sym = TexMobject("\\vec{\\textbf{v}}")
334
  w_sym = TexMobject("\\vec{\\textbf{w}}")
335
+ syms = VGroup(v_sym, TexMobject("+"), w_sym)
336
  syms.arrange(RIGHT)
337
  syms.center().shift(2*UP)
338
 
 
343
  circle = Circle()
344
  circle.shift(syms.get_bottom())
345
 
346
+ VGroup(v_arrow, v_array, v_sym).set_color(v_color)
347
+ VGroup(w_arrow, w_array, w_sym).set_color(w_color)
348
+ VGroup(sum_arrow, sum_array).set_color(sum_color)
349
 
350
  self.play(
351
  Write(syms), Write(arrays),
 
366
 
367
 
368
  def add_scaling(self, arrows, syms, arrays):
369
+ s_arrows = VGroup(
370
  TexMobject("2"), Vector([1, 1]).set_color(YELLOW),
371
  TexMobject("="), Vector([2, 2]).set_color(WHITE)
372
  )
 
374
  s_arrows.scale(0.75)
375
  s_arrows.next_to(arrows, DOWN)
376
 
377
+ s_arrays = VGroup(
378
  TexMobject("2"),
379
  matrix_to_mobject([3, -5]).set_color(YELLOW),
380
  TextMobject("="),
 
384
  s_arrays.scale(0.75)
385
  s_arrays.next_to(arrays, DOWN)
386
 
387
+ s_syms = TexMobject("2", "\\vec{\\mathbf{v}}")
388
  s_syms.split()[-1].set_color(YELLOW)
389
  s_syms.next_to(syms, DOWN)
390
 
 
398
 
399
  def fade_all_but(self, creatures, index):
400
  self.play(*[
401
+ FadeOut(VGroup(pi, pi.title))
402
  for pi in creatures[:index] + creatures[index+1:]
403
  ])
404
 
 
1266
 
1267
  self.add(title)
1268
  self.play(ShowCreation(rect))
1269
+ self.wait()
1270
 
1271
 
1272
 
readme.txt CHANGED
@@ -82,7 +82,7 @@ np.array(matrix, dtype=str)
82
  # 这种改成这样
83
 
84
 
85
- chapters = VMobject(*list(map(TextMobject, [
86
  "Chapter 1: Vectors, what even are they?",
87
  "Chapter 2: Linear combinations, span and bases",
88
  "Chapter 3: Matrices as linear transformations",
@@ -94,22 +94,21 @@ chapters = VMobject(*list(map(TextMobject, [
94
  "Chapter 9: Eigenvectors and eigenvalues",
95
  "Chapter 10: Abstract vector spaces",
96
  ])))
 
 
97
 
98
- chapters = VGroup(*[
99
- TextMobject("Chapter 1: Vectors, what even are they?"),
100
- TextMobject("Chapter 2: Linear combinations, span and bases"),
101
- TextMobject("Chapter 3: Matrices as linear transformations"),
102
- TextMobject("Chapter 4: Matrix multiplication as composition"),
103
- TextMobject("Chapter 5: The determinant"),
104
- TextMobject("Chapter 6: Inverse matrices, column space and null space"),
105
- TextMobject("Chapter 7: Dot products and cross products"),
106
- TextMobject("Chapter 8: Change of basis"),
107
- TextMobject("Chapter 9: Eigenvectors and eigenvalues"),
108
- TextMobject("Chapter 10: Abstract vector spaces"),
109
- ])
110
  # 改成这样
111
 
112
 
 
 
 
 
 
 
113
 
114
  assets/svg_images/video_icon.svg
115
  # 新建这个文件看看,第二个场景缺少文件
 
82
  # 这种改成这样
83
 
84
 
85
+ chapters = VGroup(*list(map(TextMobject, [
86
  "Chapter 1: Vectors, what even are they?",
87
  "Chapter 2: Linear combinations, span and bases",
88
  "Chapter 3: Matrices as linear transformations",
 
94
  "Chapter 9: Eigenvectors and eigenvalues",
95
  "Chapter 10: Abstract vector spaces",
96
  ])))
97
+ # 改成这样
98
+
99
 
100
+ vi old_projects\eola\chapter1.py
101
+ # vector = Matrix([square_footage.copy(), price.copy()])
102
+ vector = MobjectMatrix([square_footage.copy(), price.copy()])
 
 
 
 
 
 
 
 
 
103
  # 改成这样
104
 
105
 
106
+ vi old_projects\eola\chapter1.py
107
+ class DifferentConceptions(Scene):
108
+ # s_syms = TexMobject("2", "\\vec{\\textbf{v}}")
109
+ s_syms = TexMobject("2", "\\vec{\\mathbf{v}}")
110
+ # 改成这样
111
+
112
 
113
  assets/svg_images/video_icon.svg
114
  # 新建这个文件看看,第二个场景缺少文件