Home | History | Annotate | Download | only in agg23
      1 
      2 //----------------------------------------------------------------------------
      3 // Anti-Grain Geometry - Version 2.3
      4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
      5 //
      6 // Permission to copy, use, modify, sell and distribute this software
      7 // is granted provided this copyright notice appears in all copies.
      8 // This software is provided "as is" without express or implied
      9 // warranty, and with no claim as to its suitability for any purpose.
     10 //
     11 //----------------------------------------------------------------------------
     12 // Contact: mcseem (at) antigrain.com
     13 //          mcseemagg (at) yahoo.com
     14 //          http://www.antigrain.com
     15 //----------------------------------------------------------------------------
     16 //
     17 // Line dash generator
     18 //
     19 //----------------------------------------------------------------------------
     20 #ifndef AGG_VCGEN_DASH_INCLUDED
     21 #define AGG_VCGEN_DASH_INCLUDED
     22 #include "agg_basics.h"
     23 #include "agg_vertex_sequence.h"
     24 namespace agg
     25 {
     26 class vcgen_dash
     27 {
     28     enum max_dashes_e {
     29         max_dashes = 32
     30     };
     31     enum status_e {
     32         initial,
     33         ready,
     34         polyline,
     35         stop
     36     };
     37 public:
     38     typedef vertex_sequence<vertex_dist, 6> vertex_storage;
     39     vcgen_dash();
     40     void remove_all_dashes();
     41     void add_dash(FX_FLOAT dash_len, FX_FLOAT gap_len);
     42     void dash_start(FX_FLOAT ds);
     43     void shorten(FX_FLOAT s)
     44     {
     45         m_shorten = s;
     46     }
     47     double shorten() const
     48     {
     49         return m_shorten;
     50     }
     51     void remove_all();
     52     void add_vertex(FX_FLOAT x, FX_FLOAT y, unsigned cmd);
     53     void     rewind(unsigned path_id);
     54     unsigned vertex(FX_FLOAT* x, FX_FLOAT* y);
     55 private:
     56     vcgen_dash(const vcgen_dash&);
     57     const vcgen_dash& operator = (const vcgen_dash&);
     58     void calc_dash_start(FX_FLOAT ds);
     59     FX_FLOAT     m_dashes[max_dashes];
     60     FX_FLOAT		m_total_dash_len;
     61     unsigned        m_num_dashes;
     62     FX_FLOAT     m_dash_start;
     63     FX_FLOAT     m_shorten;
     64     FX_FLOAT     m_curr_dash_start;
     65     unsigned        m_curr_dash;
     66     FX_FLOAT     m_curr_rest;
     67     const vertex_dist* m_v1;
     68     const vertex_dist* m_v2;
     69     vertex_storage m_src_vertices;
     70     unsigned       m_closed;
     71     status_e       m_status;
     72     unsigned       m_src_vertex;
     73 };
     74 }
     75 #endif
     76