# The Graphical Package¶

The goal of this package is to prepare geometric objects for rendering in a figure or in a gui. This package is intended to support graphical output via matplotlib.

## Graphical Polygons¶

class flatsurf.graphical.polygon.GraphicalPolygon(polygon, transformation=None, outline_color=None, fill_color='#ccc', label=None)[source]

Stores data necessary to draw one of the polygons from a surface.

base_polygon()[source]
base_ring()[source]
bounding_box()[source]

Return the quadruple (x1,y1,x2,y2) where x1 and y1 are the minimal x- and y-coordinates and x2 and y2 are the maximal x-and y- cordinates.

field()
maxx()[source]

Return the maximal x-coordinate of a vertex.

maxy()[source]

Return the minimal y-coordinate of a vertex

minx()[source]

Return the minimal x-coordinate of a vertex.

miny()[source]

Return the minimal y-coordinate of a vertex.

num_edges()[source]
plot()[source]

Returns a plot of the GraphicalPolygon.

EXAMPLES:

sage: from flatsurf import *
sage: s = similarity_surfaces.example()
sage: from flatsurf.graphical.surface import GraphicalSurface
sage: gs = GraphicalSurface(s)
sage: gs.graphical_polygon(0).set_fill_color("red")
sage: gs.graphical_polygon(0).plot()
Graphics object consisting of 2 graphics primitives

plot_edge(e, color=None, dotted=False)[source]
polygon_label_options()[source]
polygon_options()[source]
set_fill_color(fill_color)[source]

Set the fill color.

set_label(label)[source]
set_outline_color(outline_color)[source]

Set the outline color.

set_transformation(transformation)[source]

Set the transformation to be applied to the polygon.

transform(point, field=None)[source]

Return the transformation of point into graphical coordinates.

transformation()[source]

Return the transformation (similarity) which converts from mathematical to graphical coordinates.

transformed_vertex(e)[source]
vertices()[source]

Return the vertices of the polygon as a list of floating point vectors.

## Graphical Surfaces¶

class flatsurf.graphical.surface.GraphicalSurface(similarity_surface, name=None)[source]

EXAMPLES:

sage: from flatsurf import *
sage: from flatsurf.graphical.surface import GraphicalSurface

sage: s = similarity_surfaces.example()
sage: gs = GraphicalSurface(s)
sage: gs.graphical_polygon(0).set_fill_color("red")
sage: gs.graphical_polygon(0).plot()
Graphics object consisting of 2 graphics primitives

bounding_box()[source]

Return the quadruple (x1,y1,x2,y2) where x1 and y1 are the minimal x- and y-coordinates of a visible graphical polygon and x2 and y2 are the maximal x-and y- cordinates of a visible graphical polygon.

get_surface()[source]

Return the underlying similarity surface.

graphical_polygon(label)[source]

Return the graphical_polygon with the given label.

Returns the truth value of the statement ‘The polygon opposite edge (p,e) is adjacent to that edge.’

is_visible(label)[source]

Return whether the polygon with the given label is marked as visible.

Move the polygon across the prescribed edge so that is adjacent.

EXAMPLES:

sage: from flatsurf.geometry.similarity_surface_generators import SimilaritySurfaceGenerators
sage: s = SimilaritySurfaceGenerators.example()
sage: from flatsurf.graphical.surface import GraphicalSurface
sage: gs = GraphicalSurface(s)
sage: print("Polygon 0: "+str(gs.graphical_polygon(0).vertices()))
Polygon 0: [(0.0, 0.0), (2.0, -2.0), (2.0, 0.0)]
sage: print("Polygon 1: "+str(gs.graphical_polygon(1).vertices()))
Polygon 1: [(0.0, 0.0), (2.0, 0.0), (1.0, 3.0)]
sage: print("Polygon 0, edge 0 is opposite "+str(gs.opposite_edge(0,0)))
Polygon 0, edge 0 is opposite (1, 1)
sage: print("Polygon 0: "+str(gs.graphical_polygon(0).vertices()))
Polygon 0: [(0.0, 0.0), (2.0, -2.0), (2.0, 0.0)]
sage: print("Polygon 1: "+str(gs.graphical_polygon(1).vertices()))
Polygon 1: [(0.4, -2.8), (2.0, -2.0), (0.0, 0.0)]


Move the polygon across the prescribed edge so that is adjacent, and make the moved polygon visible.

make_all_visible()[source]

Attempt to show all invisible polygons by walking over the surface.

make_visible(label)[source]

Mark the polygon with the given label as visible.

maxx()[source]

Return the maximal x-coordinate of a vertex of a visible graphical polygon.

maxy()[source]

Return the minimal y-coordinate of a vertex of a visible graphical polygon.

minx()[source]

Return the minimal x-coordinate of a vertex of a visible graphical polygon.

miny()[source]

Return the minimal y-coordinate of a vertex of a visible graphical polygon.

opposite_edge(p, e)[source]

Given the label p of a polygon and an edge e in that polygon returns the pair (pp, ee) to which this edge is glued.

plot()[source]

Returns a plot of the GraphicalSurface

EXAMPLES:

sage: from flatsurf.geometry.similarity_surface_generators import SimilaritySurfaceGenerators
sage: s = SimilaritySurfaceGenerators.example()
sage: from flatsurf.graphical.surface import GraphicalSurface
sage: gs = GraphicalSurface(s)
sage: gs.make_visible(1)
sage: gs.plot()
Graphics object consisting of 9 graphics primitives

visible()[source]

Return the set of visible labels.

## Graphical Straight-Line Trajectories¶

class flatsurf.graphical.straight_line_trajectory.GraphicalSegmentInPolygon(graphical_surface, segment)[source]
end()[source]

Return the end point as a RDF Vector.

plot(color=None)[source]

EXAMPLES:

from flatsurf.geometry.similarity_surface_generators import SimilaritySurfaceGenerators
s=SimilaritySurfaceGenerators.example()
from flatsurf.graphical.surface import GraphicalSurface
gs=GraphicalSurface(s)
gs.make_visible(1)
from flatsurf.geometry.tangent_bundle import *
tb = SimilaritySurfaceTangentBundle(s)
V=tb.surface().vector_space()
v=SimilaritySurfaceTangentVector(tb, 0, V((1,-0.5)), V((3,-1)))
from flatsurf.geometry.straight_line_trajectory import *
seg = SegmentInPolygon(v)
from flatsurf.graphical.straight_line_trajectory import *
gseg = GraphicalSegmentInPolygon(gs, seg)
show(gs.plot()+gseg.plot())

polygon_label()[source]
start()[source]

Return the start point as a RDF Vector.

class flatsurf.graphical.straight_line_trajectory.GraphicalStraightLineTrajectory(graphical_surface, trajectory)[source]

Allows for the rendering of a straight-line trajectory through a graphical surface.

plot(color=None)[source]

EXAMPLES:

from flatsurf.geometry.similarity_surface_generators import SimilaritySurfaceGenerators
s=SimilaritySurfaceGenerators.example()
from flatsurf.graphical.surface import GraphicalSurface
gs=GraphicalSurface(s)
gs.make_visible(1)
from flatsurf.geometry.tangent_bundle import *
K.<sqrt2>=NumberField(x^2-2,embedding=1)
tb = SimilaritySurfaceTangentBundle(s)
from flatsurf.sage.modules.free_module_element import vector
v=SimilaritySurfaceTangentVector(tb, 0, vector((1,-1)), vector((sqrt2,-1)))
from flatsurf.geometry.straight_line_trajectory import *
traj = StraightLineTrajectory(v)
traj.flow(100)
traj.flow(-5)
from flatsurf.graphical.straight_line_trajectory import *
gtraj = GraphicalStraightLineTrajectory(gs, traj)
show(gs.plot()+gtraj.plot())