From 56d2dce13365c77b14b709f92dca35eb57575a66 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sun, 12 Aug 2018 19:14:37 -0700 Subject: [PATCH 1/3] Typo fix --- mobject/mobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobject/mobject.py b/mobject/mobject.py index 44cadf8a..75232f96 100644 --- a/mobject/mobject.py +++ b/mobject/mobject.py @@ -161,7 +161,7 @@ class Mobject(Container): def get_time_based_updaters(self): return [ - udpater + updater for updater in self.updaters if get_num_args(updater) == 2 ] From d2fa2b6ef2af5ecd3314efe3d52bc24ee13a89a6 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sun, 12 Aug 2018 19:22:13 -0700 Subject: [PATCH 2/3] Added get_complex_formatter to Decimal --- mobject/numbers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mobject/numbers.py b/mobject/numbers.py index b89b7025..63703ee9 100644 --- a/mobject/numbers.py +++ b/mobject/numbers.py @@ -83,7 +83,7 @@ class DecimalNumber(VMobject): """ config = dict(self.__dict__) config.update(kwargs) - return reduce(op.add, [ + return "".join([ "{", config.get("field_name", ""), ":", @@ -94,7 +94,11 @@ class DecimalNumber(VMobject): ]) def get_complex_formatter(self, **kwargs): - pass + return "".join([ + self.get_formatter(field_name="0.real"), + self.get_formatter(field_name="0.imag", include_sign=True), + "i" + ]) def set_value(self, number, **config): full_config = dict(self.initial_config) From 0e0a0c1673584f7f8ebe551798f71c4926dbff4e Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 13 Aug 2018 13:35:14 -0700 Subject: [PATCH 3/3] Whoops, didn't mean to have the cairo_test.py in there... --- cairo_test.py | 74 --------------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 cairo_test.py diff --git a/cairo_test.py b/cairo_test.py deleted file mode 100644 index a9cb9f36..00000000 --- a/cairo_test.py +++ /dev/null @@ -1,74 +0,0 @@ -import math -import cairo -from PIL import Image -import subprocess as sp -import os -import numpy as np -import sys - -WIDTH, HEIGHT = 1024, 1024 - - -def argb32_to_rgba(array): - h, w = array.shape - result = np.ndarray(shape=(h, w, 4), dtype=np.uint8) - for i in range(0, 4): - result[:, :, (i + 1) % 4] = (array // (256**i)) % 256 - # result[:, :, 3] = array % 256 - return result - - -data = np.ndarray(shape=(HEIGHT, WIDTH, 4), dtype=np.uint8) - -surface = cairo.ImageSurface.create_for_data( - data, cairo.FORMAT_ARGB32, WIDTH, HEIGHT -) - -# surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT) - -# surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT) -ctx = cairo.Context(surface) - -ctx.scale(WIDTH, HEIGHT) # Normalizing the canvas - -pat = cairo.LinearGradient(0.0, 0.0, 0.0, 1.0) -pat.add_color_stop_rgba(1, 0.7, 0, 0, 0.5) # First stop, 50% opacity -pat.add_color_stop_rgba(0, 0.9, 0.7, 0.2, 1) # Last stop, 100% opacity - -ctx.rectangle(0, 0, 1, 1) # Rectangle(x0, y0, x1, y1) -ctx.set_source(pat) -ctx.fill() - -ctx.translate(0.1, 0.1) # Changing the current transformation matrix - -ctx.move_to(0, 0) -# Arc(cx, cy, radius, start_angle, stop_angle) -ctx.arc(0.2, 0.1, 0.1, -math.pi / 2, 0) -ctx.line_to(0.5, 0.1) # Line to (x,y) -# Curve(x1, y1, x2, y2, x3, y3) -ctx.curve_to(0.5, 0.2, 0.5, 0.4, 0.2, 0.8) -ctx.close_path() - -ctx.set_source_rgb(0.8, 0.2, 0.5) # Solid color -ctx.set_line_width(0.01) -ctx.stroke() - -# ctx.set_source(pat) -# ctx.fill() - -new_data = np.array(data) -new_data[:,:,:3] = data[:,:,2::-1] - -im = Image.fromarray(new_data, mode="RGBa") -im2 = im.convert("RGBA") -im2.show() -print(new_data[-1, -1]) - - -surface.write_to_png("example.png") # Output to PNG - -FNULL = open(os.devnull, 'w') -sp.call(["open", "example.png"], stdout=FNULL, stderr=sp.STDOUT) -FNULL.close() - -print(np.array(Image.open("example.png"))[-1, -1])