Polygon¶
[1]:
import fresnel
scene = fresnel.Scene()
The polygon geometry defines a set of N simple polygons in two dimensions. All polygons in the geometry have the same vertices. Each polygon has a separate position, orientation angle, and color.
[2]:
geometry = fresnel.geometry.Polygon(scene,
N=2,
vertices = [[0, -1], [1, 1],
[0, 0.5], [-1, 1]])
geometry.material.color = fresnel.color.linear([0.20,0.64,0.58])
geometry.material.solid=1
Geometric properties¶
position defines the position of each polygon in the z=0 plane.
[3]:
geometry.position[:] = [[-1,0],
[1, 0]]
angle defines the rotation angle of each polygon
[4]:
geometry.angle[:] = [0.1, -1.0]
[5]:
scene.camera = fresnel.camera.Orthographic.fit(scene)
fresnel.preview(scene)
[5]:
Color¶
color sets the color of each polygon (when primitive_color_mix > 0).
[6]:
geometry.color[:] = [fresnel.color.linear([0.02,0.23,0.42]),
fresnel.color.linear([0.38,0.84,0.98])];
geometry.material.primitive_color_mix = 1.0
[7]:
fresnel.preview(scene)
[7]:
Outlines¶
Outlines are applied inside the outer edge of the polygon in the z=0 plane.
[8]:
geometry.outline_width = 0.05
[9]:
fresnel.preview(scene)
[9]:
Rounded polygons¶
Specify rounding_radius to round the edges of the polygon.
[10]:
scene2 = fresnel.Scene()
geometry2 = fresnel.geometry.Polygon(scene2,
rounding_radius=0.3,
N=1,
vertices = [[-1, -1], [1, -1],
[1, 1], [-1, 1]],
outline_width=0.1)
geometry2.material.color=fresnel.color.linear([0.56,0.03,0.28])
geometry2.material.solid=1
scene2.camera = fresnel.camera.Orthographic.fit(scene2)
[11]:
fresnel.preview(scene2)
[11]:
This page was generated from a jupyter notebook. You can download and run the notebook locally from the fresnel-examples repository.