Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add_bars(self, values):
buff = float(self.width) / (2 * len(values) + 1)
bars = VGroup()
for i, value in enumerate(values):
bar = Rectangle(
height=(value / self.max_value) * self.height,
width=buff,
stroke_width=self.bar_stroke_width,
fill_opacity=self.bar_fill_opacity,
)
bar.move_to((2 * i + 1) * buff * RIGHT, DOWN + LEFT)
bars.add(bar)
bars.set_color_by_gradient(*self.bar_colors)
bar_labels = VGroup()
for bar, name in zip(bars, self.bar_names):
label = TexMobject(str(name))
label.scale(self.bar_label_scale_val)
label.next_to(bar, DOWN, SMALL_BUFF)
bar_labels.add(label)
class Rectangle(Polygon):
CONFIG = {
"color": WHITE,
"height": 2.0,
"width": 4.0,
"mark_paths_closed": True,
"close_new_points": True,
}
def __init__(self, **kwargs):
Polygon.__init__(self, UL, UR, DR, DL, **kwargs)
self.set_width(self.width, stretch=True)
self.set_height(self.height, stretch=True)
class Square(Rectangle):
CONFIG = {
"side_length": 2.0,
}
def __init__(self, **kwargs):
digest_config(self, kwargs)
Rectangle.__init__(
self,
height=self.side_length,
width=self.side_length,
**kwargs
)
class RoundedRectangle(Rectangle):
CONFIG = {
]).arrange(RIGHT, buff=SMALL_BUFF)
for y in range(4)
]).arrange(DOWN, buff=MED_SMALL_BUFF)
keyboard.stretch_to_fit_width(
self.keyboard_width_to_body_width * body.get_width(),
)
keyboard.stretch_to_fit_height(
self.keyboard_height_to_body_height * body.get_height(),
)
keyboard.next_to(body, OUT, buff=0.1 * SMALL_BUFF)
keyboard.shift(MED_SMALL_BUFF * UP)
body.add(keyboard)
screen_plate.stretch(self.screen_thickness /
self.body_dimensions[2], dim=2)
screen = Rectangle(
stroke_width=0,
fill_color=BLACK,
fill_opacity=1,
)
screen.replace(screen_plate, stretch=True)
screen.scale_in_place(self.screen_width_to_screen_plate_width)
screen.next_to(screen_plate, OUT, buff=0.1 * SMALL_BUFF)
screen_plate.add(screen)
screen_plate.next_to(body, UP, buff=0)
screen_plate.rotate(
self.open_angle, RIGHT,
about_point=screen_plate.get_bottom()
)
self.screen_plate = screen_plate
self.screen = screen
def scroll_through_patrons(self):
logo_box = Square(side_length=2.5)
logo_box.to_corner(DOWN + LEFT, buff=MED_LARGE_BUFF)
black_rect = Rectangle(
fill_color=BLACK,
fill_opacity=1,
stroke_width=3,
stroke_color=BLACK,
width=FRAME_WIDTH,
height=0.6 * FRAME_HEIGHT,
)
black_rect.to_edge(UP, buff=0)
line = DashedLine(FRAME_X_RADIUS * LEFT, FRAME_X_RADIUS * RIGHT)
line.move_to(ORIGIN)
thanks = TextMobject(self.thanks_words)
thanks.scale(0.9)
thanks.next_to(black_rect.get_bottom(), UP, SMALL_BUFF)
thanks.set_color(YELLOW)
underline = Line(LEFT, RIGHT)
def get_unit_square(self, color=YELLOW, opacity=0.3, stroke_width=3):
square = self.square = Rectangle(
color=color,
width=self.plane.get_x_unit_size(),
height=self.plane.get_y_unit_size(),
stroke_color=color,
stroke_width=stroke_width,
fill_color=color,
fill_opacity=opacity
)
square.move_to(self.plane.coords_to_point(0, 0), DL)
return square
if input_sample_type == "left":
sample_input = x
elif input_sample_type == "right":
sample_input = x + dx
elif input_sample_type == "center":
sample_input = x + 0.5 * dx
else:
raise Exception("Invalid input sample type")
graph_point = self.input_to_graph_point(sample_input, graph)
points = VGroup(*list(map(VectorizedPoint, [
self.coords_to_point(x, 0),
self.coords_to_point(x + width_scale_factor * dx, 0),
graph_point
])))
rect = Rectangle()
rect.replace(points, stretch=True)
if graph_point[1] < self.graph_origin[1] and show_signed_area:
fill_color = invert_color(color)
else:
fill_color = color
rect.set_fill(fill_color, opacity=fill_opacity)
rect.set_stroke(stroke_color, width=stroke_width)
rectangles.add(rect)
return rectangles
fill_color = WHITE
if stroke_color in ["", "none", "#FFF", "#FFFFFF"] or Color(stroke_color) == Color(WHITE):
stroke_width = 0
stroke_color = BLACK
if stroke_color in ["#000", "#000000"]:
stroke_color = WHITE
if stroke_width in ["", "none", "0"]:
stroke_width = 0
if corner_radius in ["", "0", "none"]:
corner_radius = 0
corner_radius = float(corner_radius)
if corner_radius == 0:
mob = Rectangle(
width=self.attribute_to_float(
rect_element.getAttribute("width")
),
height=self.attribute_to_float(
rect_element.getAttribute("height")
),
stroke_width=stroke_width,
stroke_color=stroke_color,
fill_color=fill_color,
fill_opacity=opacity
)
else:
mob = RoundedRectangle(
width=self.attribute_to_float(
rect_element.getAttribute("width")
),
class Rectangle(Polygon):
CONFIG = {
"color": WHITE,
"height": 2.0,
"width": 4.0,
"mark_paths_closed": True,
"close_new_points": True,
}
def __init__(self, **kwargs):
Polygon.__init__(self, UL, UR, DR, DL, **kwargs)
self.set_width(self.width, stretch=True)
self.set_height(self.height, stretch=True)
class Square(Rectangle):
CONFIG = {
"side_length": 2.0,
}
def __init__(self, **kwargs):
digest_config(self, kwargs)
Rectangle.__init__(
self,
height=self.side_length,
width=self.side_length,
**kwargs
)
class RoundedRectangle(Rectangle):
CONFIG = {