00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "OSDLLine.h"
00028
00029
00030 #include "OSDLSurface.h"
00031 #include "OSDLPoint2D.h"
00032 #include "OSDLVideo.h"
00033
00034
00035
00036 #include "OSDLFromGfx.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifdef OSDL_USES_CONFIG_H
00046 #include "OSDLConfig.h"
00047 #endif // OSDL_USES_CONFIG_H
00048
00049 #if OSDL_ARCH_NINTENDO_DS
00050 #include "OSDLConfigForNintendoDS.h"
00051 #endif // OSDL_ARCH_NINTENDO_DS
00052
00053
00054
00055
00056 #if OSDL_USES_SDL_GFX
00057
00058
00059 #include "SDL_gfxPrimitives.h"
00060
00061 #endif // OSDL_USES_SDL_GFX
00062
00063
00064
00065 using namespace OSDL::Video ;
00066 using namespace OSDL::Video::Pixels ;
00067 using namespace OSDL::Video::TwoDimensional ;
00068
00069 using namespace Ceylan ;
00070
00071
00072
00073
00074 bool Line::drawHorizontal( Surface & targetSurface,
00075 Coordinate xStart, Coordinate xStop, Coordinate y,
00076 ColorElement red, ColorElement green, ColorElement blue,
00077 ColorElement alpha )
00078 {
00079
00080 #if OSDL_USES_SDL_GFX
00081
00082
00083
00084 return ( ::hlineColor( & targetSurface.getSDLSurface(), xStart, xStop, y,
00085 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00086 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00087 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00088 ( static_cast<Ceylan::Uint32>( alpha ) ) ) == 0 ) ;
00089
00090 #else // OSDL_USES_SDL_GFX
00091
00092
00093
00094 return false ;
00095
00096 #endif // OSDL_USES_SDL_GFX
00097
00098 }
00099
00100
00101
00102 bool Line::drawHorizontal( Surface & targetSurface,
00103 Coordinate xStart, Coordinate xStop, Coordinate y,
00104 Pixels::PixelColor actualColor )
00105 {
00106
00107 #if OSDL_USES_SDL_GFX
00108
00109
00110
00111 return ( ::hlineColorStore( & targetSurface.getSDLSurface(),
00112 xStart, xStop, y, actualColor) == 0 ) ;
00113
00114 #else // OSDL_USES_SDL_GFX
00115
00116
00117
00118 return false ;
00119
00120 #endif // OSDL_USES_SDL_GFX
00121
00122 }
00123
00124
00125
00126 bool Line::drawHorizontal( Surface & targetSurface,
00127 Coordinate xStart, Coordinate xStop, Coordinate y,
00128 ColorDefinition colorDef )
00129 {
00130
00131 #if OSDL_USES_SDL_GFX
00132
00133
00134
00135 return ( ::hlineColor( & targetSurface.getSDLSurface(), xStart, xStop, y,
00136 Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) == 0 ) ;
00137
00138 #else // OSDL_USES_SDL_GFX
00139
00140
00141
00142 return false ;
00143
00144 #endif // OSDL_USES_SDL_GFX
00145
00146 }
00147
00148
00149
00150 bool Line::drawVertical( Surface & targetSurface, Coordinate x,
00151 Coordinate yStart, Coordinate yStop,
00152 ColorElement red, ColorElement blue, ColorElement green,
00153 ColorElement alpha )
00154 {
00155
00156 #if OSDL_USES_SDL_GFX
00157
00158
00159
00160 return ( ::vlineColor( & targetSurface.getSDLSurface(), x, yStart, yStop,
00161 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00162 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00163 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00164 ( static_cast<Ceylan::Uint32>( alpha ) ) ) == 0 ) ;
00165
00166 #else // OSDL_USES_SDL_GFX
00167
00168
00169
00170 return false ;
00171
00172 #endif // OSDL_USES_SDL_GFX
00173
00174 }
00175
00176
00177
00178 bool Line::drawVertical( Surface & targetSurface, Coordinate x,
00179 Coordinate yStart, Coordinate yStop, ColorDefinition colorDef )
00180 {
00181
00182 #if OSDL_USES_SDL_GFX
00183
00184
00185
00186 return ( ::vlineColor( & targetSurface.getSDLSurface(), x, yStart, yStop,
00187 Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) == 0 ) ;
00188
00189 #else // OSDL_USES_SDL_GFX
00190
00191
00192
00193 return false ;
00194
00195 #endif // OSDL_USES_SDL_GFX
00196
00197 }
00198
00199
00200
00201 bool Line::draw( Surface & targetSurface, Coordinate xStart, Coordinate yStart,
00202 Coordinate xStop, Coordinate yStop,
00203 ColorElement red, ColorElement green, ColorElement blue,
00204 ColorElement alpha )
00205 {
00206
00207 #if OSDL_USES_SDL_GFX
00208
00209 if ( VideoModule::GetAntiAliasingState() )
00210 {
00211
00212 return ( ::aalineColorInt( & targetSurface.getSDLSurface(),
00213 xStart, yStart, xStop, yStop,
00214 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00215 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00216 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00217 ( static_cast<Ceylan::Uint32>( alpha ) ),
00218 VideoModule::GetEndPointDrawState() ) == 0 ) ;
00219
00220 }
00221 else
00222 {
00223
00224
00225
00226
00227
00228
00229
00230 return ( ::lineColor( & targetSurface.getSDLSurface(),
00231 xStart, yStart, xStop, yStop,
00232 ( static_cast<Ceylan::Uint32>( red ) << 24 ) |
00233 ( static_cast<Ceylan::Uint32>( green ) << 16 ) |
00234 ( static_cast<Ceylan::Uint32>( blue ) << 8 ) |
00235 ( static_cast<Ceylan::Uint32>( alpha ) ) ) == 0 ) ;
00236
00237 }
00238
00239 #else // OSDL_USES_SDL_GFX
00240
00241
00242
00243 return false ;
00244
00245 #endif // OSDL_USES_SDL_GFX
00246
00247 }
00248
00249
00250
00251 bool Line::draw( Surface & targetSurface, Coordinate xStart, Coordinate yStart,
00252 Coordinate xStop, Coordinate yStop, ColorDefinition colorDef )
00253 {
00254
00255 #if OSDL_USES_SDL_GFX
00256
00257 if ( VideoModule::GetAntiAliasingState() )
00258 {
00259
00260 return ( ::aalineColorInt( & targetSurface.getSDLSurface(),
00261 xStart, yStart, xStop, yStop,
00262 Pixels::convertColorDefinitionToRawPixelColor( colorDef ),
00263 VideoModule::GetEndPointDrawState() ) == 0 ) ;
00264
00265 }
00266 else
00267 {
00268
00269
00270
00271
00272
00273
00274
00275 return ( ::lineColor( & targetSurface.getSDLSurface(),
00276 xStart, yStart, xStop, yStop,
00277 Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) == 0 ) ;
00278
00279 }
00280
00281 #else // OSDL_USES_SDL_GFX
00282
00283
00284
00285 return false ;
00286
00287 #endif // OSDL_USES_SDL_GFX
00288
00289 }
00290
00291
00292
00293 bool Line::draw( Surface & targetSurface,
00294 Point2D & firstPoint, Point2D & secondPoint,
00295 Pixels::ColorElement red, Pixels::ColorElement green,
00296 Pixels::ColorElement blue, Pixels::ColorElement alpha )
00297 {
00298
00299 return draw( targetSurface, firstPoint.getX(), firstPoint.getY(),
00300 secondPoint.getX(), secondPoint.getY(), red, green, blue, alpha ) ;
00301
00302 }
00303
00304
00305
00306 bool Line::draw( Surface & targetSurface,
00307 Point2D & firstPoint, Point2D & secondPoint,
00308 Pixels::ColorDefinition colorDef )
00309 {
00310
00311 return draw( targetSurface, firstPoint.getX(), firstPoint.getY(),
00312 secondPoint.getX(), secondPoint.getY(), colorDef ) ;
00313
00314 }
00315
00316
00317
00318 bool Line::drawCross( Surface & targetSurface, const Point2D & center,
00319 Pixels::ColorDefinition colorDef, Length squareEdge )
00320 {
00321
00322 return drawCross( targetSurface, center.getX(), center.getY(),
00323 colorDef, squareEdge ) ;
00324
00325 }
00326
00327
00328
00329 bool Line::drawCross( Surface & targetSurface,
00330 Coordinate xCenter, Coordinate yCenter,
00331 Pixels::ColorDefinition colorDef, Length squareEdge )
00332 {
00333
00334
00335
00336 const FloatingPointCoordinate demiEdge =
00337 static_cast<FloatingPointCoordinate>( squareEdge / 2 ) ;
00338
00339 bool result = draw( targetSurface,
00340 static_cast<Coordinate>( xCenter - demiEdge ),
00341 static_cast<Coordinate>( yCenter - demiEdge ),
00342 static_cast<Coordinate>( xCenter + demiEdge ),
00343 static_cast<Coordinate>( yCenter + demiEdge ),
00344 colorDef ) ;
00345
00346
00347 return result && draw( targetSurface,
00348 static_cast<Coordinate>( xCenter - demiEdge ),
00349 static_cast<Coordinate>( yCenter + demiEdge ),
00350 static_cast<Coordinate>( xCenter + demiEdge ),
00351 static_cast<Coordinate>( yCenter - demiEdge ),
00352 colorDef ) ;
00353
00354 }