00001 #include "OSDLLine.h"
00002
00003
00004 #include "OSDLSurface.h"
00005 #include "OSDLPoint2D.h"
00006 #include "OSDLVideo.h"
00007
00008
00009 #include "SDL_gfxPrimitives.h"
00010
00011
00012 #include "OSDLFromGfx.h"
00013
00014
00015
00016 using namespace OSDL::Video ;
00017 using namespace OSDL::Video::TwoDimensional ;
00018
00019 using namespace Ceylan ;
00020
00021
00022
00023
00024
00025
00026
00027 bool Line::drawHorizontal( Surface & targetSurface,
00028 Coordinate xStart, Coordinate xStop, Coordinate y,
00029 ColorElement red, ColorElement green, ColorElement blue,
00030 ColorElement alpha ) throw()
00031 {
00032
00033
00034
00035 return ( ::hlineColor( & targetSurface.getSDLSurface(), xStart, xStop, y,
00036 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00037 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00038 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00039 ( static_cast<Ceylan::Uint32>( alpha ) ) ) == 0 ) ;
00040
00041 }
00042
00043
00044
00045 bool Line::drawHorizontal( Surface & targetSurface,
00046 Coordinate xStart, Coordinate xStop, Coordinate y,
00047 Pixels::PixelColor actualColor ) throw()
00048 {
00049
00050
00051
00052 return ( ::hlineColorStore( & targetSurface.getSDLSurface(),
00053 xStart, xStop, y, actualColor) == 0 ) ;
00054
00055 }
00056
00057
00058
00059 bool Line::drawHorizontal( Surface & targetSurface,
00060 Coordinate xStart, Coordinate xStop, Coordinate y,
00061 ColorDefinition colorDef ) throw()
00062 {
00063
00064
00065
00066 return ( ::hlineColor( & targetSurface.getSDLSurface(), xStart, xStop, y,
00067 Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) == 0 ) ;
00068
00069 }
00070
00071
00072
00073 bool Line::drawVertical( Surface & targetSurface, Coordinate x,
00074 Coordinate yStart, Coordinate yStop,
00075 ColorElement red, ColorElement blue, ColorElement green,
00076 ColorElement alpha ) throw()
00077 {
00078
00079
00080
00081 return ( ::vlineColor( & targetSurface.getSDLSurface(), x, yStart, yStop,
00082 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00083 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00084 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00085 ( static_cast<Ceylan::Uint32>( alpha ) ) ) == 0 ) ;
00086
00087 }
00088
00089
00090
00091 bool Line::drawVertical( Surface & targetSurface, Coordinate x,
00092 Coordinate yStart, Coordinate yStop, ColorDefinition colorDef ) throw()
00093 {
00094
00095
00096
00097 return ( ::vlineColor( & targetSurface.getSDLSurface(), x, yStart, yStop,
00098 Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) == 0 ) ;
00099
00100 }
00101
00102
00103
00104 bool Line::draw( Surface & targetSurface, Coordinate xStart, Coordinate yStart,
00105 Coordinate xStop, Coordinate yStop,
00106 ColorElement red, ColorElement green, ColorElement blue,
00107 ColorElement alpha ) throw()
00108 {
00109
00110 if ( VideoModule::GetAntiAliasingState() )
00111 {
00112
00113 return ( ::aalineColorInt( & targetSurface.getSDLSurface(),
00114 xStart, yStart, xStop, yStop,
00115 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00116 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00117 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00118 ( static_cast<Ceylan::Uint32>( alpha ) ),
00119 VideoModule::GetEndPointDrawState() ) == 0 ) ;
00120
00121 }
00122 else
00123 {
00124
00125
00126
00127
00128
00129
00130
00131 return ( ::lineColor( & targetSurface.getSDLSurface(),
00132 xStart, yStart, xStop, yStop,
00133 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00134 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00135 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00136 ( static_cast<Ceylan::Uint32>( alpha ) ) ) == 0 ) ;
00137
00138 }
00139
00140 }
00141
00142
00143
00144 bool Line::draw( Surface & targetSurface, Coordinate xStart, Coordinate yStart,
00145 Coordinate xStop, Coordinate yStop, ColorDefinition colorDef ) throw()
00146 {
00147
00148 if ( VideoModule::GetAntiAliasingState() )
00149 {
00150
00151 return ( ::aalineColorInt( & targetSurface.getSDLSurface(),
00152 xStart, yStart, xStop, yStop,
00153 Pixels::convertColorDefinitionToRawPixelColor( colorDef ),
00154 VideoModule::GetEndPointDrawState() ) == 0 ) ;
00155
00156 }
00157 else
00158 {
00159
00160
00161
00162
00163
00164
00165
00166 return ( ::lineColor( & targetSurface.getSDLSurface(),
00167 xStart, yStart, xStop, yStop,
00168 Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) == 0 ) ;
00169
00170 }
00171
00172 }
00173
00174
00175
00176 bool Line::draw( Surface & targetSurface,
00177 Point2D & firstPoint, Point2D & secondPoint,
00178 Pixels::ColorElement red, Pixels::ColorElement green,
00179 Pixels::ColorElement blue, Pixels::ColorElement alpha )
00180 throw()
00181 {
00182
00183 return draw( targetSurface, firstPoint.getX(), firstPoint.getY(),
00184 secondPoint.getX(), secondPoint.getY(), red, green, blue, alpha ) ;
00185
00186 }
00187
00188
00189
00190 bool Line::draw( Surface & targetSurface,
00191 Point2D & firstPoint, Point2D & secondPoint,
00192 Pixels::ColorDefinition colorDef ) throw()
00193 {
00194
00195 return draw( targetSurface, firstPoint.getX(), firstPoint.getY(),
00196 secondPoint.getX(), secondPoint.getY(), colorDef ) ;
00197
00198 }
00199
00200
00201
00202 bool Line::drawCross( Surface & targetSurface, const Point2D & center,
00203 Pixels::ColorDefinition colorDef, Length squareEdge ) throw()
00204 {
00205
00206 return drawCross( targetSurface, center.getX(), center.getY(),
00207 colorDef, squareEdge ) ;
00208
00209 }
00210
00211
00212
00213 bool Line::drawCross( Surface & targetSurface,
00214 Coordinate xCenter, Coordinate yCenter,
00215 Pixels::ColorDefinition colorDef, Length squareEdge ) throw()
00216 {
00217
00218
00219
00220 const FloatingPointCoordinate demiEdge =
00221 static_cast<FloatingPointCoordinate>( squareEdge / 2 ) ;
00222
00223 bool result = draw( targetSurface,
00224 static_cast<Coordinate>( xCenter - demiEdge ),
00225 static_cast<Coordinate>( yCenter - demiEdge ),
00226 static_cast<Coordinate>( xCenter + demiEdge ),
00227 static_cast<Coordinate>( yCenter + demiEdge ),
00228 colorDef ) ;
00229
00230
00231 return result && draw( targetSurface,
00232 static_cast<Coordinate>( xCenter - demiEdge ),
00233 static_cast<Coordinate>( yCenter + demiEdge ),
00234 static_cast<Coordinate>( xCenter + demiEdge ),
00235 static_cast<Coordinate>( yCenter - demiEdge ),
00236 colorDef ) ;
00237
00238 }
00239