bool ViewCodo::on_image_expose_event(GdkEventExpose *e)
{
- Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+ Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
Gdk::Color blanco = Gdk::Color("white");
colormap->alloc_color(color);
gc->set_foreground(color);
bool ViewExclusa::on_image_expose_event(GdkEventExpose *e)
{
- Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+ Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
colormap->alloc_color(color);
gc->set_foreground(color);
gc->set_background(color);
bool ViewPump::on_image_expose_event(GdkEventExpose *e)
{
- Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
- colormap->alloc_color(color);
+ Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
+ if (!colormap->alloc_color(color, true, true)) {
+ std::cout << name << ": Error alocando color!" << std::endl;
+ }
+
gc->set_foreground(color);
gc->set_background(color);
gc->set_line_attributes(6, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER);
bool ViewUnion::on_image_expose_event(GdkEventExpose *e)
{
- Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
- colormap->alloc_color(color);
+ Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
+ if (!colormap->alloc_color(color, false, false)) {
+ std::cout << "ERROR ALOCANDO COLOR!" << std::endl;
+ }
gc->set_foreground(color);
gc->set_background(color);
+
+ if (name == "union6") {
+ std::cout << color.get_red() << " " << color.get_green() << " " << color.get_blue() << std::endl;
+ }
int w,h;
w = image.get_width();
h = image.get_height();
b = static_cast<gushort>(65535 * (b / 255.0f));
Gdk::Color c;
c.set_rgb(r,g,b);
+
return c;
}
}
i++;
sim->simulate();
- //std::cout << sim->get_state_as_xml() << std::endl << std::endl;
+ std::cout << sim->get_state_as_xml() << std::endl << std::endl;
}
delete sim;
RGB Simulator::loadRGB(xmlNodePtr nodo)
{
- unsigned r,g,b;
+ unsigned long r,g,b;
while (nodo != NULL) {
if (nodo->type == XML_ELEMENT_NODE) {
if (xmlStrcmp(nodo->name, BAD_CAST"rojo")==0)
}
nodo = nodo->next;
}
+ r = static_cast<unsigned long>(255 * (r / 65535.0f));
+ g = static_cast<unsigned long>(255 * (g / 65535.0f));
+ b = static_cast<unsigned long>(255 * (b / 65535.0f));
+
return RGB(r,g,b);
}
if (flow2 == 0) n--;
float suma = flow1+flow2;
if (n != 0) {
- r = (int)(color1.r()*flow1/suma + color2.r()*flow2/suma)/n;
- g = (int)(color1.g()*flow1/suma + color2.g()*flow2/suma)/n;
- b = (int)(color1.b()*flow1/suma + color2.b()*flow2/suma)/n;
- r %= 256;
- g %= 256;
- b %= 256;
+ r = (int)(color1.r()*flow1/suma + color2.r()*flow2/suma);
+ g = (int)(color1.g()*flow1/suma + color2.g()*flow2/suma);
+ b = (int)(color1.b()*flow1/suma + color2.b()*flow2/suma);
set_color(RGB(r,g,b));
} else {
set_color(RGB(0,0,0));