{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from PIL import Image, ImageDraw\n", "\n", "images = []\n", "\n", "width = 200\n", "center = width // 2\n", "color_1 = (0, 0, 0)\n", "color_2 = (255, 255, 255)\n", "max_radius = int(center * 1.5)\n", "step = 8\n", "\n", "for i in range(0, max_radius, step):\n", " im = Image.new('RGB', (width, width), color_1)\n", " draw = ImageDraw.Draw(im)\n", " draw.ellipse((center - i, center - i, center + i, center + i), fill=color_2)\n", " images.append(im)\n", "\n", "for i in range(0, max_radius, step):\n", " im = Image.new('RGB', (width, width), color_2)\n", " draw = ImageDraw.Draw(im)\n", " draw.ellipse((center - i, center - i, center + i, center + i), fill=color_1)\n", " images.append(im)\n", "\n", "images[0].save('pillow_imagedraw.gif',\n", " save_all=True, append_images=images[1:], optimize=False, duration=40, loop=0)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 4 }