00001 #include "OSDLBezier.h"
00002
00003 #include "OSDLSurface.h"
00004 #include "OSDLPoint2D.h"
00005 #include "OSDLVideo.h"
00006
00007 #include "Ceylan.h"
00008
00009 #include "SDL_gfxPrimitives.h"
00010
00011
00012 using namespace OSDL::Video ;
00013
00014 using namespace Ceylan::Log ;
00015
00016
00017
00018
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
00048
00049
00050
00051 Ceylan::System::Size vertexCount = controlPoints.size() ;
00052
00053
00054
00055
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