~ubuntu-branches/ubuntu/trusty/mapnik/trusty

« back to all changes in this revision

Viewing changes to bindings/python/mapnik_color.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-03-18 01:07:40 UTC
  • mfrom: (1.1.4 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100318010740-u01iy3n0ux9xzzir
Tags: 0.7.0-2ubuntu1
* Merge from debian testing (LP: #526070), remaining changes:
  - Bump boost build-dep and libmapnik-dev depends to boost1.40

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 *****************************************************************************/
22
22
//$Id$
23
23
 
 
24
// boost
 
25
#include <boost/python.hpp>
 
26
 
24
27
//mapnik
25
28
#include <mapnik/color.hpp>
26
 
// boost
27
 
#include <boost/python.hpp>
 
29
 
28
30
 
29
31
using mapnik::color;
30
32
 
41
43
void export_color () 
42
44
{
43
45
    using namespace boost::python;
44
 
    class_<color>("Color",init<int,int,int,int>())
45
 
       .def(init<int,int,int>())
46
 
       .def(init<std::string>())
47
 
       .add_property("r",&color::red,&color::set_red)
48
 
       .add_property("g",&color::green,&color::set_green)
49
 
       .add_property("b",&color::blue,&color::set_blue)
50
 
       .add_property("a",&color::alpha,&color::set_alpha)
51
 
       .def(self == self)
52
 
       .def_pickle(color_pickle_suite())
53
 
       .def("__str__",&color::to_string)
54
 
       .def("to_hex_string",&color::to_hex_string)
55
 
       ;
 
46
    class_<color>("Color", init<int,int,int,int>(
 
47
        ( arg("r"), arg("g"), arg("b"), arg("a") ),
 
48
        "Creates a new color from its RGB components\n"
 
49
        "and an alpha value.\n"
 
50
        "All values between 0 and 255.\n")
 
51
        )
 
52
  .def(init<int,int,int>(
 
53
        ( arg("r"), arg("g"), arg("b") ),
 
54
        "Creates a new color from its RGB components.\n"
 
55
        "All values between 0 and 255.\n")
 
56
        )
 
57
  .def(init<std::string>(
 
58
        ( arg("color_string") ),
 
59
        "Creates a new color from its CSS string representation.\n"
 
60
        "The string may be a CSS color name (e.g. 'blue')\n"
 
61
        "or a hex color string (e.g. '#0000ff').\n")
 
62
        )
 
63
  .add_property("r",
 
64
        &color::red,
 
65
        &color::set_red,
 
66
        "Gets or sets the red component.\n"
 
67
        "The value is between 0 and 255.\n")
 
68
  .add_property("g",
 
69
        &color::green,
 
70
        &color::set_green,
 
71
        "Gets or sets the green component.\n"
 
72
        "The value is between 0 and 255.\n")
 
73
  .add_property("b",
 
74
        &color::blue,
 
75
        &color::set_blue,
 
76
        "Gets or sets the blue component.\n"
 
77
        "The value is between 0 and 255.\n")
 
78
  .add_property("a",
 
79
        &color::alpha,
 
80
        &color::set_alpha,
 
81
        "Gets or sets the alpha component.\n"
 
82
        "The value is between 0 and 255.\n")
 
83
  .def(self == self)
 
84
  .def_pickle(color_pickle_suite())
 
85
  .def("__str__",&color::to_string)
 
86
  .def("to_hex_string",&color::to_hex_string,
 
87
        "Returns the hexadecimal representation of this color.\n"
 
88
        "\n"
 
89
        "Example:\n"
 
90
        ">>> c = Color('blue')\n"
 
91
        ">>> c.to_hex_string()\n"
 
92
        "'#0000ff'\n")
 
93
  ;
56
94
}
57