void ElementImage::GenerateGeometry() { // Release the old geometry before specifying the new vertices. geometry.Release(true); std::vector< Rocket::Core::Vertex >& vertices = geometry.GetVertices(); std::vector< int >& indices = geometry.GetIndices(); vertices.resize(4); indices.resize(6); // Generate the texture coordinates. Vector2f texcoords[2]; if (using_coords) { Vector2f texture_dimensions((float) texture.GetDimensions(GetRenderInterface()).x, (float) texture.GetDimensions(GetRenderInterface()).y); if (texture_dimensions.x == 0) texture_dimensions.x = 1; if (texture_dimensions.y == 0) texture_dimensions.y = 1; texcoords[0].x = (float) coords[0] / texture_dimensions.x; texcoords[0].y = (float) coords[1] / texture_dimensions.y; texcoords[1].x = (float) coords[2] / texture_dimensions.x; texcoords[1].y = (float) coords[3] / texture_dimensions.y; } else { texcoords[0] = Vector2f(0, 0); texcoords[1] = Vector2f(1, 1); } const Property* element_colour = GetProperty(BACKGROUND_COLOR); float opacity = GetProperty<float>(OPACITY); Colourb quad_colour = Colourb(255, 255, 255); if (element_colour) { Colourb background_colour = element_colour->Get<Colourb>(); // Should be a non-transparent background if (background_colour.alpha != 0) quad_colour = background_colour; } // Apply opacity quad_colour.alpha = (byte)(opacity * (float)quad_colour.alpha); Rocket::Core::GeometryUtilities::GenerateQuad(&vertices[0], // vertices to write to &indices[0], // indices to write to Vector2f(0, 0), // origin of the quad GetBox().GetSize(Rocket::Core::Box::CONTENT), // size of the quad quad_colour, // colour of the vertices texcoords[0], // top-left texture coordinate texcoords[1]); // top-right texture coordinate geometry_dirty = false; }
void ElementImage::GenerateGeometry() { // Release the old geometry before specifying the new vertices. geometry.Release(true); std::vector< Rocket::Core::Vertex >& vertices = geometry.GetVertices(); std::vector< int >& indices = geometry.GetIndices(); vertices.resize(4); indices.resize(6); // Generate the texture coordinates. Vector2f texcoords[2]; if (using_coords) { Vector2f texture_dimensions((float) texture.GetDimensions(GetRenderInterface()).x, (float) texture.GetDimensions(GetRenderInterface()).y); if (texture_dimensions.x == 0) texture_dimensions.x = 1; if (texture_dimensions.y == 0) texture_dimensions.y = 1; texcoords[0].x = (float) coords[0] / texture_dimensions.x; texcoords[0].y = (float) coords[1] / texture_dimensions.y; texcoords[1].x = (float) coords[2] / texture_dimensions.x; texcoords[1].y = (float) coords[3] / texture_dimensions.y; } else { texcoords[0] = Vector2f(0, 0); texcoords[1] = Vector2f(1, 1); } Rocket::Core::GeometryUtilities::GenerateQuad(&vertices[0], // vertices to write to &indices[0], // indices to write to Vector2f(0, 0), // origin of the quad GetBox().GetSize(Rocket::Core::Box::CONTENT), // size of the quad Colourb(255, 255, 255, 255), // colour of the vertices texcoords[0], // top-left texture coordinate texcoords[1]); // top-right texture coordinate geometry_dirty = false; }
DecoratorTiled::DecoratorTiled() { color_multiplier = Colourb(255, 255, 255, 255); }
PropertyParserColour::PropertyParserColour() { html_colours["black"] = Colourb(0, 0, 0); html_colours["silver"] = Colourb(192, 192, 192); html_colours["gray"] = Colourb(128, 128, 128); html_colours["grey"] = Colourb(128, 128, 128); html_colours["white"] = Colourb(255, 255, 255); html_colours["maroon"] = Colourb(128, 0, 0); html_colours["red"] = Colourb(255, 0, 0); html_colours["orange"] = Colourb(255, 165, 0); html_colours["purple"] = Colourb(128, 0, 128); html_colours["fuschia"] = Colourb(255, 0, 255); html_colours["green"] = Colourb(0, 128, 0); html_colours["lime"] = Colourb(0, 255, 0); html_colours["olive"] = Colourb(128, 128, 0); html_colours["yellow"] = Colourb(255, 255, 0); html_colours["navy"] = Colourb(0, 0, 128); html_colours["blue"] = Colourb(0, 0, 255); html_colours["teal"] = Colourb(0, 128, 128); html_colours["aqua"] = Colourb(0, 255, 255); html_colours["transparent"] = Colourb(255, 255, 255, 0); }
void RegisterPythonInterfaces() { python::class_< ScriptInterface, boost::noncopyable >("ScriptInterface", python::no_init); VectorInterface< StringList >("StringList"); python::class_< Vector2f >("Vector2f") .def(python::init< float, float >()) .def_readwrite("x", &Vector2f::x) .def_readwrite("y", &Vector2f::y) .def(python::self * float()) // * float .def(python::self / float()) // / float .def(python::self + Vector2f()) // + Vector2f .def(python::self - Vector2f()) // - Vector2f .def(python::self == Vector2f()) // == .def(python::self != Vector2f()) // != .def("DotProduct", &Vector2f::DotProduct) .def("Normalise", &Vector2f::Normalise) .def("Rotate", &Vector2f::Rotate) .add_property("magnitude", &Vector2f::Magnitude) .def_pickle(PickleTypeConverter< Vector2f >()) ; python::class_< Vector2i >("Vector2i") .def(python::init< int, int >()) .def_readwrite("x", &Vector2i::x) .def_readwrite("y", &Vector2i::y) .def(python::self * int()) // * int .def(python::self / int()) // / int .def(python::self + Vector2i()) // + Vector2i .def(python::self - Vector2i()) // - Vector2i .def(python::self == Vector2i()) // == .def(python::self != Vector2i()) // != .def_pickle(PickleTypeConverter< Vector2i >()) ; python::class_< Colourf >("Colourf") .def(python::init< float, float, float, float >()) .def_readwrite("red", &Colourf::red) .def_readwrite("green", &Colourf::green) .def_readwrite("blue", &Colourf::blue) .def_readwrite("alpha", &Colourf::alpha) .def(python::self == Colourf()) // == .def_pickle(PickleTypeConverter< Colourf >()) ; python::class_< Colourb >("Colourb") .def(python::init< byte, byte, byte, byte>()) .def_readwrite("red", &Colourb::red) .def_readwrite("green", &Colourb::green) .def_readwrite("blue", &Colourb::blue) .def_readwrite("alpha", &Colourb::alpha) .def(python::self == Colourb()) // == .def(python::self + Colourb()) // + .def(python::self *= float()) // *= .def(python::self * float()) // * .def_pickle(PickleTypeConverter< Colourb >()) ; python::class_< URL >("URL") .def(python::init< const char* >()) .def_pickle(PickleTypeConverter< URL >()) ; python::def("Log", &Log); python::enum_< Core::Log::Type >("logtype") .value("always", Core::Log::LT_ALWAYS) .value("error", Core::Log::LT_ERROR) .value("warning", Core::Log::LT_WARNING) .value("info", Core::Log::LT_INFO) .value("debug", Core::Log::LT_DEBUG) ; DictionaryInterface(); //DataSourceWrapper::InitialisePythonInterface(); }