Replaced background_alpha with background_opacity

This commit is contained in:
Grant Sanderson
2018-05-10 19:55:06 -07:00
parent d36a68f756
commit 80176f0940
7 changed files with 16 additions and 15 deletions

View File

@ -206,7 +206,7 @@ class LeaveItToComputers(TeacherStudentsScene):
class PrerequisiteKnowledge(TeacherStudentsScene):
CONFIG = {
"camera_config": {"background_alpha": 255}
"camera_config": {"background_opacity": 1}
}
def construct(self):

View File

@ -34,7 +34,7 @@ class Camera(object):
"frame_shape": (FRAME_HEIGHT, FRAME_WIDTH),
"space_center": ORIGIN,
"background_color": BLACK,
"background_alpha": 0, # Out of rgb_max_val
"background_opacity": 0,
# Points in vectorized mobjects with norm greater
# than this value will be rescaled.
"max_allowable_norm": FRAME_WIDTH,
@ -94,7 +94,7 @@ class Camera(object):
self.background = self.background.astype(self.pixel_array_dtype)
else:
background_rgba = color_to_int_rgba(
self.background_color, alpha=self.background_alpha
self.background_color, self.background_opacity
)
self.background = np.zeros(
list(self.pixel_shape) + [self.n_rgb_coords],
@ -115,10 +115,10 @@ class Camera(object):
retval = np.array(pixel_array)
if convert_from_floats:
retval = np.apply_along_axis(
lambda f: (
f * self.rgb_max_val).astype(self.pixel_array_dtype),
lambda f: (f * self.rgb_max_val).astype(self.pixel_array_dtype),
2,
retval)
retval
)
return retval
def set_pixel_array(self, pixel_array, convert_from_floats=False):

View File

@ -2884,7 +2884,7 @@ class ZeroFoundOnBoundary(Scene):
class AllOfTheVideos(Scene):
CONFIG = {
"camera_config" : {
"background_alpha" : 255,
"background_opacity" : 1,
}
}
def construct(self):

View File

@ -1479,7 +1479,7 @@ class AskAboutLayers(PreviewMNistNetwork):
class BreakUpMacroPatterns(IntroduceEachLayer):
CONFIG = {
"camera_config" : {"background_alpha" : 255},
"camera_config" : {"background_opacity" : 1},
"prefixes" : [
"nine", "eight", "four",
"upper_loop", "right_line",
@ -1868,7 +1868,7 @@ class BreakUpMicroPatterns(BreakUpMacroPatterns):
class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer):
CONFIG = {
"camera_config" : {
"background_alpha" : 255,
"background_opacity" : 1,
},
"network_mob_config" : {
"layer_to_layer_buff" : 2,
@ -2081,7 +2081,7 @@ class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer):
class EdgeDetection(Scene):
CONFIG = {
"camera_config" : {"background_alpha" : 255}
"camera_config" : {"background_opacity" : 1}
}
def construct(self):
lion = ImageMobject("Lion")

View File

@ -468,7 +468,7 @@ class TauFalls(Scene):
class EulerWrites628(Scene):
CONFIG = {
"camera_config" : {
"background_alpha" : 255,
"background_opacity" : 1,
}
}
def construct(self):
@ -548,7 +548,7 @@ class EulerWrites628(Scene):
class HeroAndVillain(Scene):
CONFIG = {
"camera_config" : {
"background_alpha" : 255,
"background_opacity" : 1,
}
}
def construct(self):
@ -987,7 +987,7 @@ class SpecialThanks(Scene):
class EndScene(PatreonEndScreen):
CONFIG = {
"camera_config" : {
"background_alpha" : 255,
"background_opacity" : 1,
}
}
def construct(self):

View File

@ -4958,7 +4958,7 @@ class KeeperAndSailorForSineProduct(KeeperAndSailor):
class Conclusion(TeacherStudentsScene):
CONFIG = {
"camera_config": {"background_alpha": 255},
"camera_config": {"background_opacity": 1},
}
def construct(self):

View File

@ -39,7 +39,8 @@ def color_to_int_rgb(color):
return (255 * color_to_rgb(color)).astype('uint8')
def color_to_int_rgba(color, alpha=255):
def color_to_int_rgba(color, opacity=1.0):
alpha = int(255 * opacity)
return np.append(color_to_int_rgb(color), alpha)