OSDLBezier.cc

Go to the documentation of this file.
00001 #include "OSDLBezier.h"
00002 
00003 #include "OSDLSurface.h"        // for Surface
00004 #include "OSDLPoint2D.h"        // for Point2D
00005 #include "OSDLVideo.h"          // for VideoModule
00006 
00007 #include "Ceylan.h"             // for Ceylan::LogPlug
00008 
00009 #include "SDL_gfxPrimitives.h"  // for graphic primitives exported by SDL_gfx
00010 
00011 
00012 using namespace OSDL::Video ;
00013 
00014 using namespace Ceylan::Log ;
00015 
00016 
00017 
00018 // A return code of 0 for SDL_gfx functions means no error, contrary to -1.
00019 
00020 
00021 
00022 bool TwoDimensional::drawBezierCurve( 
00023     Surface & targetSurface, 
00024     const listPoint2D & controlPoints,
00025     Ceylan::Uint16 numberOfSteps, 
00026     Pixels::ColorElement red, 
00027     Pixels::ColorElement green, 
00028     Pixels::ColorElement blue, 
00029     Pixels::ColorElement alpha ) throw()
00030 {
00031         
00032     return drawBezierCurve( targetSurface, controlPoints, numberOfSteps, 
00033         Pixels::convertRGBAToColorDefinition( red, green, blue, alpha ) ) ;
00034 
00035 }   
00036 
00037 
00038 bool TwoDimensional::drawBezierCurve( 
00039     Surface & targetSurface, 
00040     const listPoint2D & controlPoints,
00041     Ceylan::Uint16 numberOfSteps, 
00042     Pixels::ColorDefinition colorDef ) throw()
00043 {
00044 
00045 
00046     /*
00047      * If a large number of summits is to be used, dynamic allocation
00048      * (new/delete) would be better.
00049      *
00050      */
00051     Ceylan::System::Size vertexCount = controlPoints.size() ;
00052     
00053     /*
00054      * Used to be allocated on the stack, but 
00055      * 'ISO C++ forbids variable-size array'...
00056      *
00057      */
00058     Coordinate * abscissaArray = new Coordinate[ vertexCount ] ;
00059     Coordinate * ordinateArray = new Coordinate[ vertexCount ] ;
00060     
00061     vertexCount = 0 ;
00062     
00063     for ( listPoint2D::const_iterator it = controlPoints.begin(); 
00064         it != controlPoints.end(); it++ )
00065     {
00066         abscissaArray[ vertexCount ] = (*it)->getX() ;
00067         ordinateArray[ vertexCount ] = (*it)->getY() ;
00068         
00069         vertexCount++ ;
00070     }
00071     
00072     int res = ::bezierColor( & targetSurface.getSDLSurface(), 
00073         abscissaArray, ordinateArray, vertexCount, numberOfSteps, 
00074         Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) ;
00075     
00076     delete [] abscissaArray ;
00077     delete [] ordinateArray ;
00078         
00079     return ( res == 0 ) ;   
00080 
00081 }   
00082 
00083 
00084 

Generated on Fri Mar 30 14:46:59 2007 for OSDL by  doxygen 1.5.1