From ae5c393b6f7b0b336d96e427c8e6d033789c01cf Mon Sep 17 00:00:00 2001 From: looooo Date: Tue, 27 Mar 2018 10:05:20 +0200 Subject: [PATCH] gif --- README.md | 3 ++- examples/animation.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2a09fc..79eeac0 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ A gear module for FreeCAD > 0.16 --------------------------- ![gear](examples/spiral.png) +![gear1](examples/animated_spiral.gif) ## supported gear-types: - cylindric involute @@ -49,4 +50,4 @@ A gear module for FreeCAD > 0.16 * go to the gear workbench * create new document * create a gear (click on gear symbol) - * change parameters + * change parameters diff --git a/examples/animation.py b/examples/animation.py index e786dce..6e39d99 100644 --- a/examples/animation.py +++ b/examples/animation.py @@ -1,6 +1,9 @@ # script for bevel-gear animation from PySide import QtGui, QtCore +import FreeCADGui as Gui +import numpy as np +import imageio doc = App.ActiveDocument g2 = doc.Common @@ -8,6 +11,17 @@ g1 = doc.Common001 timer = QtCore.QTimer() +def make_pics(): + n = 30 + for i in range(n): + phi = np.pi * 2 / 30 / n + g1.Placement.Rotation.Angle += phi * 2 + g2.Placement.Rotation.Angle -= phi + Gui.activeDocument().activeView().saveImage('/home/lo/Schreibtisch/animated_gear/gear_{}.png'.format(i) ,300,300,'Current') + +def make_animated_gif(): + + def update(*args): print("time") delta_phi = 0.005 @@ -15,4 +29,4 @@ def update(*args): g2.Placement.Rotation.Angle -= delta_phi timer.timeout.connect(update) -timer.start() \ No newline at end of file +timer.start()