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 #ifndef OSDL_POLYGON_H_
00028 #define OSDL_POLYGON_H_
00029
00030
00031 #include "OSDLPixel.h"
00032
00033 #include "Ceylan.h"
00034
00035 #include <string>
00036 #include <list>
00037
00038
00039 #if ! defined(OSDL_USES_SDL) || OSDL_USES_SDL
00040
00041 #include "SDL.h"
00042
00043 #endif // OSDL_USES_SDL
00044
00045
00046 namespace OSDL
00047 {
00048
00049
00050
00051 namespace Video
00052 {
00053
00054
00055
00056
00057 class Surface ;
00058
00059
00060
00061 namespace TwoDimensional
00062 {
00063
00064
00065
00066
00067 class Point2D ;
00068
00069
00070
00077 typedef std::list<Point2D *> listPoint2D ;
00078
00079
00080
00093
00094
00095
00096
00097
00098
00099
00100
00137 OSDL_DLL bool drawPie( Surface & targetSurface,
00138 Coordinate xCenter, Coordinate yCenter, Length radius,
00139 Ceylan::Maths::AngleInDegrees angleStart,
00140 Ceylan::Maths::AngleInDegrees angleStop,
00141 Pixels::ColorElement red, Pixels::ColorElement green,
00142 Pixels::ColorElement blue,
00143 Pixels::ColorElement alpha = Pixels::AlphaOpaque ) ;
00144
00145
00146
00177 OSDL_DLL bool drawPie( Surface & targetSurface,
00178 Coordinate xCenter, Coordinate yCenter, Length radius,
00179 Ceylan::Maths::AngleInDegrees angleStart,
00180 Ceylan::Maths::AngleInDegrees angleStop,
00181 Pixels::ColorDefinition colorDef ) ;
00182
00183
00184
00203 OSDL_DLL bool drawTriangle( Surface & targetSurface,
00204 Coordinate x1, Coordinate y1,
00205 Coordinate x2, Coordinate y2,
00206 Coordinate x3, Coordinate y3,
00207 Pixels::ColorElement red, Pixels::ColorElement green,
00208 Pixels::ColorElement blue,
00209 Pixels::ColorElement alpha = Pixels::AlphaOpaque,
00210 bool filled = true ) ;
00211
00212
00213
00232 OSDL_DLL bool drawTriangle( Surface & targetSurface,
00233 Coordinate x1, Coordinate y1,
00234 Coordinate x2, Coordinate y2,
00235 Coordinate x3, Coordinate y3,
00236 Pixels::ColorDefinition colorDef, bool filled = true ) ;
00237
00238
00239
00258 OSDL_DLL bool drawTriangle( Surface & targetSurface,
00259 const Point2D & p1, const Point2D & p2, const Point2D & p3,
00260 Pixels::ColorElement red, Pixels::ColorElement green,
00261 Pixels::ColorElement blue,
00262 Pixels::ColorElement alpha = Pixels::AlphaOpaque,
00263 bool filled = true ) ;
00264
00265
00266
00285 OSDL_DLL bool drawTriangle( Surface & targetSurface,
00286 const Point2D & p1, const Point2D & p2, const Point2D & p3,
00287 Pixels::ColorDefinition colorDef, bool filled = true ) ;
00288
00289
00290
00319 OSDL_DLL bool drawPolygon( Surface & targetSurface,
00320 const listPoint2D & summits,
00321 Coordinate x, Coordinate y,
00322 Pixels::ColorElement red, Pixels::ColorElement green,
00323 Pixels::ColorElement blue,
00324 Pixels::ColorElement alpha = Pixels::AlphaOpaque,
00325 bool filled = true ) ;
00326
00327
00328
00358 OSDL_DLL bool drawPolygon( Surface & targetSurface,
00359 const listPoint2D & summits,
00360 Coordinate x, Coordinate y,
00361 Pixels::ColorDefinition colorDef, bool filled = true ) ;
00362
00363
00364
00365
00385 class OSDL_DLL Polygon: public Ceylan::Locatable2D
00386 {
00387
00388
00389 public:
00390
00391
00392
00411 explicit Polygon( listPoint2D & summits,
00412 bool listOwner = false ) ;
00413
00414
00415
00417 virtual ~Polygon() throw() ;
00418
00419
00420
00442 virtual bool draw( Surface & targetSurface,
00443 Pixels::ColorDefinition colorDef = Pixels::White,
00444 bool filled = true ) const ;
00445
00446
00447
00455 virtual listPoint2D & getPoints() const ;
00456
00457
00458
00468 virtual void setPoints( listPoint2D & newList ) ;
00469
00470
00471
00472
00474 virtual bool isListOwner() const ;
00475
00476
00477
00490 virtual const std::string toString(
00491 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00492
00493
00494
00495
00496
00497
00498
00499
00500
00532 static Polygon & CreateFlakeBranch(
00533 Length length = 200,
00534 Length thickness = 20,
00535 Ceylan::Maths::AngleInDegrees childAngle = 50,
00536 Ceylan::Maths::Ratio branchingHeightRatio = 0.7,
00537 Ceylan::Maths::Ratio scale = 0.3 ) ;
00538
00539
00540
00549 static listPoint2D & Duplicate(
00550 const listPoint2D & source ) ;
00551
00552
00553
00559 static void Delete( listPoint2D & listToBeDeleted ) ;
00560
00561
00562
00579 static listPoint2D & Append( listPoint2D & toBeAugmented,
00580 const listPoint2D & toAppend ) ;
00581
00582
00583
00602 static listPoint2D & Apply(
00603 const Ceylan::Maths::Linear::HomogeneousMatrix3
00604 & transformation,
00605 listPoint2D & sourceList ) ;
00606
00607
00608
00609
00610 private:
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 #pragma warning( push )
00621 #pragma warning( disable: 4251 )
00622
00624 listPoint2D * _summits ;
00625
00626 #pragma warning( pop )
00627
00628
00629
00635 bool _listOwner ;
00636
00637
00638
00647 explicit Polygon( const Polygon & source ) ;
00648
00649
00650
00659 Polygon & operator = ( const Polygon & source ) ;
00660
00661
00662
00663 } ;
00664
00665
00666
00667
00668
00680 class OSDL_DLL PolygonSet: public Ceylan::Locatable2D
00681 {
00682
00683
00684 public:
00685
00686
00687
00697 explicit PolygonSet( bool listOwner = false ) ;
00698
00699
00700
00723 explicit PolygonSet(
00724 std::list<listPoint2D *> & polygonList,
00725 bool listOwner = false ) ;
00726
00727
00728
00730 virtual ~PolygonSet() throw() ;
00731
00732
00733
00750 virtual void addPointsOf( Polygon & newPolygon ) ;
00751
00752
00753
00765 virtual void addPointList( listPoint2D & listToAdd ) ;
00766
00767
00768
00775 virtual bool draw( Surface & targetSurface,
00776 Coordinate x, Coordinate y,
00777 Pixels::ColorDefinition colorDef = Pixels::White,
00778 bool filled = true ) const ;
00779
00780
00781
00794 virtual const std::string toString(
00795 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00796
00797
00798
00799
00800
00801
00802
00803
00831 static PolygonSet & CreateFlake(
00832 Ceylan::Uint8 branchCount = 5,
00833 Length length = 200, Length thickness = 20,
00834 Ceylan::Maths::AngleInDegrees childAngle = 50,
00835 Ceylan::Maths::Ratio branchingHeightRatio = 0.7,
00836 Ceylan::Maths::Ratio scale = 0.3 ) ;
00837
00838
00839
00840 protected:
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850 #pragma warning( push )
00851 #pragma warning( disable: 4251 )
00852
00854 std::list<listPoint2D *> * _polygonList ;
00855
00856 #pragma warning( pop )
00857
00858
00859
00865 bool _listOwner ;
00866
00867
00868
00869
00870 private:
00871
00872
00873
00882 explicit PolygonSet( const PolygonSet & source ) ;
00883
00884
00885
00894 PolygonSet & operator = ( const PolygonSet & source ) ;
00895
00896
00897 } ;
00898
00899
00900 }
00901
00902 }
00903
00904 }
00905
00906
00907
00908 #endif // OSDL_POLYGON_H_
00909