Help with Morpholib? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Help with Morpholib? (/thread-38694.html) |
Help with Morpholib? - Drachenbauer - Nov-12-2022 This Youtuber: Morphocular says, he has made his math animations with this library-package: https://github.com/morpho-matters/morpholib So i decided to play around with it my self. I installed python, the package and the pycharm environment and tested some sample codes from the repository. But the window, that opened from running theese things, flickered in green horizontal stripes and the lines look a bit out of shape [attachment=2097] How to fix this? I played around with the turtle library before, but do not mention it in my code any more Than i tried to create a polygon my self with this code: import morpholib as morpho morpho.importAll() from morpholib.tools.basics import * from morpholib.video import * from morpholib.grid import Polygon import math, cmath, random def kite(): class Kite(morpho.Skit): def makeFrame(self): kitepolygon = morpho.grid.Polygon(vertices = [(0, 1), (2, 0), (0, -3), (-2, 0)]) kitepolygon.width = 4 kitepolygon.color = (1,1,0) kitepolygon.alphaEdge = 0 kitepolygon.fill = (1,1,0) kitepolygon.alphaFill = 0 kitepolygon.alpha = 0 kitepolygon.commitTransforms() return morpho.Frame([kitepolygon]) kite1 = Kite() kite1 = morpho.Actor(kite1) kite1.newendkey(6*30).t = 6 animation = morpho.Animation(kite1) animation.play() kite()The coordinates should create a kite with the siagonals intersecting in the coordinate origin. like this Made with Geogebra If i run the code, as it is, i get this error: If i comment out the line "kitepolygon.commitTransforms()", i get an empty window.Does any one know how to use this morpho package, how to enter the vertex-coordinates for the polygon the right way and centrate the coodinate-origin on the window? RE: Help with Morpholib? - Drachenbauer - Nov-13-2022 Now i got the kiteshape to appear with this code: import morpholib as morpho morpho.importAll() import sample from morpholib.tools.basics import * from morpholib.video import * from morpholib.grid import Polygon import math, cmath, random kite = morpho.grid.Polygon([1*1j, 2, -3*1j, -2]) kite.width = 4 kite.color = (1,1,0) kite.alphaEdge = 1 kite.fill = (1,1,0) kite.alphaFill = 1 kite.alpha = 1 animation = morpho.Animation(kite) animation.play()i found in a tutorial, that i hat to give the vertices in the form [1*1j, 2, -3*1j, -2]. But what means the multiplication with a value of j, that it makes points come of from 0 along the y axis? RE: Help with Morpholib? - deanhystad - Nov-13-2022 1*1j is a complex number |