graphics/ primitives.bi

Summary
graphics/ primitives.bi
LicenseCopyright © 2009, FreeBASIC Extended Library Development Group
Functions
TriangleDraws a flat shaded triangle.
TriangleDraws a flat shaded triangle.
Examples
Drawing a Triangle
Using the Vector2D class to simplify Triangle drawing

License

Copyright © 2009, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License

Functions

Triangle

declare sub Triangle overload (byval dst as FB.IMAGE ptr =  0,
byval x1 as integer,  
byval y1 as integer,  
byval x2 as integer,  
byval y2 as integer,  
byval x3 as integer,  
byval y3 as integer,  
byval col as uinteger =  rgba(255,255,255,255))

Draws a flat shaded triangle.

Parameters

dstFBGFX buffer to draw on.  Pass 0 to draw to the screen.
x1x coordinate of first point of triangle.
y1y coordinate of first point of triangle.
x2x coordinate of second point of triangle.
y2y coordinate of second point of triangle.
x3x coordinate of third point of triangle.
y3y coordinate of third point of triangle.
colthe color of the triangle to be drawn, defaults to &hffffff (white).

See Also

Drawing a Triangle

Triangle

declare sub Triangle(byval dst as FB.IMAGE ptr =  0,
byref p1 as ext.math.vector2d,  
byref p2 as ext.math.vector2d,  
byref p3 as ext.math.vector2d,  
byval col as uinteger =  rgba(255,255,255,255))

Draws a flat shaded triangle.

Parameters

dstFBGFX buffer to draw on.  Pass 0 to draw to the screen.
p1vector2d containing the x and y of the first point.
p2vector2d containing the x and y of the second point.
p3vector2d containing the x and y of the third point.
colthe color of the triangle to be drawn, defaults to &hffffff (white).

See Also

Using the Vector2D class to simplify Triangle drawing

vector2d

Examples

Drawing a Triangle

#include once "ext/graphics.bi"
#include once "fbgfx.bi"

screenres 320, 240, 32

do while not multikey(FB.SC_ESCAPE)

  screenlock

  cls
  ext.gfx.Triangle( , 1, 1, 1, 10, 10, 1, rgb(255,0,0) ) 'Draw a red triangle in the top left corner of the screen

  screenunlock

  sleep 5

loop 'loop until the user pushes the ESC key

Using the Vector2D class to simplify Triangle drawing

#include once "ext/graphics.bi"
#include once "fbgfx.bi"

screenres 320, 240, 32

dim as ext.math.Vector2D ptr Points

Points = new ext.math.Vector2D[3]

do while not multikey(FB.SC_ESCAPE)

  for n as uinteger = 0 to 2
      Points[n].x = ext.math.RndRange(1.0,319.0)
      Points[n].y = ext.math.RndRange(1.0,319.0)
  next

  screenlock
  cls
  ext.gfx.Triangle( 0, Points[0], Points[1], Points[2], ext.math.RndRange(&h222222, &hFFFFFF) )
  screenunlock

  sleep 100,1

loop

delete[] Points
declare sub Triangle overload (byval dst as FB.IMAGE ptr =  0,
byval x1 as integer,  
byval y1 as integer,  
byval x2 as integer,  
byval y2 as integer,  
byval x3 as integer,  
byval y3 as integer,  
byval col as uinteger =  rgba(255,255,255,255))
Draws a flat shaded triangle.
Simple 2 dimensional vector.