# `class tinylib.Polygon`

Available on all platforms

A polygon

## Sub classes:

Cube3D | A Cube
Cylinder | A Cylinder
Ribbon3D | Thin Ribbon
Sphere3D | Sphere
Square3D | Square
Triangles | Set of Triangles
Tube3D | Tube3D: 3-dimensional tube corresponding to Tube in VMD

## Instance Fields

### `var ambient:Float`

intensity of ambient

### `var diffuse:Float`

intensity of diffuse

### `var direction:Point3D`

direction of the polygon; where the polygon stick toward.

(0,0,1) would be considered as the default.

### `var faces:Array<Face>`

array of faces defined in this polygon

### `var gloss:Float`

gloss; shininess

### `var ibuf:IndexBuffer3D`

Flash Index Buffer

### `var origin:Point3D`

origin

### `var specular:Float`

intensity of specular

### `var texture:Texture`

Flash Texture

### `var vbuf:VertexBuffer3D`

Flash Vertex Buffer

### `var verts:Array<Vertex>`

array of vertex positions and their normal vectors

### `function new():Void`

### `function addFace(f:Face):Void`

### `function addVertex(v:Vertex):Int`

### `function addVertexNormals():Void`

### `function addVertexPos(p:Point3D):Int`

### `function allocate(c:Context3D, is_dc_active:Bool, str:String, color:Int, alpha:Float):Void`

### `function axisRotation(axis:Point3D, or:Point3D, angle:Float):Void`

### `function clear():Void`

### `function createDashedDoubleColoredTexture(c:Context3D, d:Int, color0:Int, color1:Int, size:Int):Void`

### `function createDoubleColoredTexture(c:Context3D, color0:Int, color1:Int, size:Int):Void`

### `function createGradientTexture(c:Context3D, color0:Int, color1:Int, size:Int):Void`

### `function disposeShader():Void`

### `function draw(c:Context3D, mpos:Matrix3D, mproj:Matrix3D, voffset:Vector3D, light:Vector3D, cpos:Vector3D, dcActive:Bool, dcCoeff:Float, dcLength:Float):Bool`

### `function dump(s:String):String`

### `function getFace(i:Int):Face`

### `function getVertex(i:Int):Vertex`

### `function get_ambient():Float`

getter of `ambient`

### `function get_diffuse():Float`

getter of `diffuse`

### `function get_direction():Point3D`

getter of `direction`

### `function get_faces():Array<Face>`

getter of `faces`

### `function get_gloss():Float`

getter of `gloss`

### `function get_ibuf():IndexBuffer3D`

getter of `ibuf`

### `function get_origin():Point3D`

getter of `origin`

### `function get_specular():Float`

getter of `specular`

### `function get_texture():Texture`

getter of `texture`

### `function get_vbuf():VertexBuffer3D`

setter of `vbuf`

### `function get_verts():Array<Vertex>`

getter of `verts`

### `function load(c:Context3D, numIndex:Int, indexes:Vector<UInt>, myIndex:Int, size:Int, buffer:Vector<Float>, str:String, is_dc_active:Bool, color:Int, alpha:Float):Void`

### `function lookAt(p:Point3D):Void`

### `function set_ambient(a:Float):Float`

setter of `ambient`

### `function set_diffuse(d:Float):Float`

setter of `diffuse`

### `function set_direction(d:Point3D):Point3D`

setter of `direction`

### `function set_faces(fs:Array<Face>):Array<Face>`

setter of `faces`

### `function set_gloss(g:Float):Float`

setter of `gloss`

### `function set_origin(o:Point3D):Point3D`

setter of `origin`

### `function set_specular(s:Float):Float`

setter of `specular`

### `function set_texture(t:Texture):Texture`

setter of `texture`

### `function set_verts(va:Array<Vertex>):Array<Vertex>`

setter of `verts`

### `function translate(x:Float, y:Float, z:Float):Void`

### `function translateByVec(p:Point3D):Void`