/** The ColorMap constructor defines many hardcoded RGB values that are used during segmentation. The most important of these with respect to inputs * are the STEM_COLOR, BORDER_COLOR, UNSEGMENTED_COLOR. The remainders correspond to leaves. If a hand-segmented or machine learning segmented plant * is provided and colors don't correspond to these values, behavior will likely be unexpected. */ ColorMap::ColorMap() { TupleTriplet STEM_COLOR(0.0, 255.0, 255.0); TupleTriplet BORDER_COLOR(80.0, 80.0, 80.0); TupleTriplet UNSEGMENTED_COLOR(255.0, 255.0, 255.0); TupleTriplet DEBUG_COLOR(255.0, 20.0, 147.0); TupleTriplet INFLORESCENCE_COLOR(255.0, 215.0, 0.0); // gold _stem_color = STEM_COLOR; _border_color = BORDER_COLOR; _unsegmented_color = UNSEGMENTED_COLOR; _debug_color = DEBUG_COLOR; _inflorescence_color = INFLORESCENCE_COLOR; // We're emulating the ggplot2 colors. // http://stackoverflow.com/questions/8197559/emulate-ggplot2-default-color-palette // and converted the hex to rgb TupleTriplet color1(248.0, 118.0, 109.0); //salmon-y #F8766D TupleTriplet color2(183.0, 159.0, 0.0); //tan-y #B79F00 TupleTriplet color3(0.0, 186.0, 56.0); //green-y #00BA38 //TupleTriplet color4(0.0, 191.0, 196.0); //sea-green-y #00BFC4 TupleTriplet color4(0.0, 134.0, 125.0); //sea-green-y TupleTriplet color5(97.0, 156.0, 255.0); // sky blue-y #619CFF TupleTriplet color6(245.0, 100.0, 227.0); // pink-y #F564E3 TupleTriplet color7(229.0, 135.0, 0.0); //orange-y #E58700 TupleTriplet color8(185.0, 131.0, 255.0); // purple-y #B983FF TupleTriplet color9(222.0, 42.0, 29.0); // red-ish TupleTriplet color10(222.0, 29.0, 186.0); TupleTriplet color11(103.0, 29.0, 222.0); TupleTriplet color12(20.0, 42.0, 222.0); /* TupleTriplet color5(29.0, 135.0, 222.0); TupleTriplet color6(29.0, 222.0, 96.0); TupleTriplet color7(148.0, 222.0, 29.0); TupleTriplet color8(222.0, 125.0, 29.0); TupleTriplet color9(240.0, 178.0, 179.0); TupleTriplet color10(176.0, 237.0, 161.0); TupleTriplet color11(250.0, 250.0, 17.0); TupleTriplet color12(247.0, 168.0, 229.0); */ //New colors added to account for manual segmentation TupleTriplet color13(150.0, 150.0, 150.0); TupleTriplet color14(0.0, 0.0, 255.0); TupleTriplet color15(170.0, 170.0, 255.0); TupleTriplet color16(255.0, 0.0, 0.0); TupleTriplet color17(255.0, 0.0, 127.0); TupleTriplet color18(0.0, 170.0, 0.0); TupleTriplet color19(85.0, 170.0, 255.0); TupleTriplet color20(255.0, 170.0, 0.0); TupleTriplet color21(153.0, 102.0, 51.0); TupleTriplet color22(255.0, 170.0, 255.0); TupleTriplet color23(170.0, 255.0, 127.0); TupleTriplet color24(255.0, 255.0, 127.0); TupleTriplet color25(108.0, 108.0, 108.0); TupleTriplet color26(237.0, 146.0, 15.0); TupleTriplet color27(170.0, 255.0, 0.0); _leafColorMap.insert(std::pair<int, TupleTriplet> (1, color1)); _leafColorMap.insert(std::pair<int, TupleTriplet> (2, color2)); _leafColorMap.insert(std::pair<int, TupleTriplet> (3, color3)); _leafColorMap.insert(std::pair<int, TupleTriplet> (4, color4)); _leafColorMap.insert(std::pair<int, TupleTriplet> (5, color5)); _leafColorMap.insert(std::pair<int, TupleTriplet> (6, color6)); _leafColorMap.insert(std::pair<int, TupleTriplet> (7, color7)); _leafColorMap.insert(std::pair<int, TupleTriplet> (8, color8)); _leafColorMap.insert(std::pair<int, TupleTriplet> (9, color9)); _leafColorMap.insert(std::pair<int, TupleTriplet> (10, color10)); _leafColorMap.insert(std::pair<int, TupleTriplet> (11, color11)); _leafColorMap.insert(std::pair<int, TupleTriplet> (12, color12)); _leafColorMap.insert(std::pair<int, TupleTriplet> (13, color13)); _leafColorMap.insert(std::pair<int, TupleTriplet> (14, color14)); _leafColorMap.insert(std::pair<int, TupleTriplet> (15, color15)); _leafColorMap.insert(std::pair<int, TupleTriplet> (16, color16)); _leafColorMap.insert(std::pair<int, TupleTriplet> (17, color17)); _leafColorMap.insert(std::pair<int, TupleTriplet> (18, color18)); _leafColorMap.insert(std::pair<int, TupleTriplet> (19, color19)); _leafColorMap.insert(std::pair<int, TupleTriplet> (20, color20)); _leafColorMap.insert(std::pair<int, TupleTriplet> (21, color21)); _leafColorMap.insert(std::pair<int, TupleTriplet> (22, color22)); _leafColorMap.insert(std::pair<int, TupleTriplet> (23, color23)); _leafColorMap.insert(std::pair<int, TupleTriplet> (24, color24)); _leafColorMap.insert(std::pair<int, TupleTriplet> (25, color25)); _leafColorMap.insert(std::pair<int, TupleTriplet> (26, color26)); _leafColorMap.insert(std::pair<int, TupleTriplet> (27, color27)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color1, 1)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color2, 2)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color3, 3)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color4, 4)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color5, 5)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color6, 6)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color7, 7)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color8, 8)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color9, 9)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color10, 10)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color11, 11)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color12, 12)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color13, 13)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color14, 14)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color15, 15)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color16, 16)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color17, 17)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color18, 18)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color19, 19)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color20, 20)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color21, 21)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color22, 22)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color23, 23)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color24, 24)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color25, 25)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color26, 26)); _leafColorMap_colorsToLabel.insert(std::pair<TupleTriplet, int> (color27, 27)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color1, 1)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color2, 2)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color3, 3)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color4, 4)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color5, 5)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color6, 6)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color7, 7)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color8, 8)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color9, 9)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color10, 10)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color11, 11)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color12, 12)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color13, 13)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color14, 14)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color15, 15)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color16, 16)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color17, 17)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color18, 18)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color19, 19)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color20, 20)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color21, 21)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color22, 22)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color23, 23)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color24, 24)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color25, 25)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color26, 26)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (color27, 27)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (STEM_COLOR, 28)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (BORDER_COLOR, 29)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (UNSEGMENTED_COLOR, 30)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (DEBUG_COLOR, 31)); _map_explicitlyHandledColors.insert(std::pair<TupleTriplet, int> (INFLORESCENCE_COLOR, 32)); }
void TriangleType::draw(RenderMode::WhichColorMode& wcm, RenderMode::RenderType& r,const Matrix44& adjust_matrix, const Vec3& bias) { if (!visible_) { return; } // std::vector<Vertex*>& vs = sample_.vertices_; //r = RenderMode::PointMode; switch(r) { case RenderMode::PointMode:{ break; } case RenderMode::FlatMode:{ glBegin(GL_TRIANGLES); for( int i = 0 ;i <3 ;++i) { if(this->i_norm[i]!=-1) { Vec4 tmpn( sample_[this->i_norm[i]].nx() , sample_[this->i_norm[i]].ny() ,sample_[this->i_norm[i]].nz() ,1.); Vec4 normal_to_show = tmpn;//adjust_matrix * tmpn; glNormal3f( normal_to_show(0), normal_to_show(1), normal_to_show(2)); //Logger<<"NORMAL: "<<(float)vs[this->i_norm[i]]->nx()<<" "<< // (float)vs[this->i_norm[i]]->ny()<<" "<< // (float)vs[this->i_norm[i]]->nz()<<std::endl; } ColorType color2 = Color_Utility::span_color_from_table(sample_[this->i_vertex[i]].label()); glColor3f( color2(0) ,color2(1) ,color2(2) /* (GLfloat) vs[this->i_vertex[i]]->r(), (GLfloat) vs[this->i_vertex[i]]->g(), (GLfloat) vs[this->i_vertex[i]]->b()*/ ); //Logger<<"COLOR: "<<vs[this->i_vertex[i]]->r()<<" "<< // vs[this->i_vertex[i]]->g()<<" "<< // vs[this->i_vertex[i]]->b()<<std::endl; Vec4 tmpv( sample_[this->i_vertex[i]].x() , sample_[this->i_vertex[i]].y() ,sample_[this->i_vertex[i]].z() ,1.); Vec4 point_to_show = adjust_matrix * tmpv; glVertex3f( point_to_show(0)+ bias(0), point_to_show(1)+ bias(1), point_to_show(2)+ bias(2) ); //Logger<<"VERTEX: "<<vs[this->i_vertex[i]]->x()<<" "<< // vs[this->i_vertex[i]]->y()<<" "<< // vs[this->i_vertex[i]]->z()<<std::endl; } glEnd(); break; } case RenderMode::WireMode:{ glLineWidth(2.0f); glBegin(GL_LINE_LOOP); for( int i = 0 ;i <3 ;++i) { if(this->i_norm[i]!=-1) { Vec4 tmpn( sample_[this->i_norm[i]].nx() , sample_[this->i_norm[i]].ny() ,sample_[this->i_norm[i]].nz() ,1.); Vec4 normal_to_show = adjust_matrix * tmpn; glNormal3f( normal_to_show(0), normal_to_show(1), normal_to_show(2)); } ColorType color2 = Color_Utility::span_color_from_table(sample_[this->i_vertex[i]].label()); glColor3f( color2(0) ,color2(1) ,color2(2) /*(GLfloat) vs[this->i_vertex[i]]->r(), (GLfloat) vs[this->i_vertex[i]]->g(), (GLfloat) vs[this->i_vertex[i]]->b() */); Vec4 tmpv( sample_[this->i_vertex[i]].x() , sample_[this->i_vertex[i]].y() ,sample_[this->i_vertex[i]].z() ,1.); Vec4 point_to_show = adjust_matrix * tmpv; glVertex3f( point_to_show(0)+ bias(0), point_to_show(1)+ bias(1), point_to_show(2)+ bias(2) ); } glEnd(); break; } case RenderMode::FlatWireMode:{ glBegin(GL_TRIANGLES); for( int i = 0 ;i <3 ;++i) { if(this->i_norm[i]!=-1) { Vec4 tmpn( sample_[this->i_norm[i]].nx() , sample_[this->i_norm[i]].ny() ,sample_[this->i_norm[i]].nz() ,1.); Vec4 normal_to_show = tmpn;//adjust_matrix * tmpn; glNormal3f( normal_to_show(0), normal_to_show(1), normal_to_show(2)); //Logger<<"NORMAL: "<<(float)vs[this->i_norm[i]]->nx()<<" "<< // (float)vs[this->i_norm[i]]->ny()<<" "<< // (float)vs[this->i_norm[i]]->nz()<<std::endl; } ColorType color2 = Color_Utility::span_color_from_table(sample_[this->i_vertex[i]].label()); glColor3f( color2(0) ,color2(1) ,color2(2) /* (GLfloat) vs[this->i_vertex[i]]->r(), (GLfloat) vs[this->i_vertex[i]]->g(), (GLfloat) vs[this->i_vertex[i]]->b()*/ ); //Logger<<"COLOR: "<<vs[this->i_vertex[i]]->r()<<" "<< // vs[this->i_vertex[i]]->g()<<" "<< // vs[this->i_vertex[i]]->b()<<std::endl; Vec4 tmpv( sample_[this->i_vertex[i]].x() , sample_[this->i_vertex[i]].y() ,sample_[this->i_vertex[i]].z() ,1.); Vec4 point_to_show = adjust_matrix * tmpv; glVertex3f( point_to_show(0)+ bias(0), point_to_show(1)+ bias(1), point_to_show(2)+ bias(2) ); //Logger<<"VERTEX: "<<vs[this->i_vertex[i]]->x()<<" "<< // vs[this->i_vertex[i]]->y()<<" "<< // vs[this->i_vertex[i]]->z()<<std::endl; } glEnd(); glLineWidth(2.0f); glBegin(GL_LINE_LOOP); for( int i = 0 ;i <3 ;++i) { if(this->i_norm[i]!=-1) { Vec4 tmpn( sample_[this->i_norm[i]].nx() , sample_[this->i_norm[i]].ny() ,sample_[this->i_norm[i]].nz() ,1.); Vec4 normal_to_show = adjust_matrix * tmpn; glNormal3f( normal_to_show(0), normal_to_show(1), normal_to_show(2)); } glColor3f( 0.5f,0.5f,0.5f /*(GLfloat) vs[this->i_vertex[i]]->r(), (GLfloat) vs[this->i_vertex[i]]->g(), (GLfloat) vs[this->i_vertex[i]]->b() */); Vec4 tmpv( sample_[this->i_vertex[i]].x() , sample_[this->i_vertex[i]].y() ,sample_[this->i_vertex[i]].z() ,1.); Vec4 point_to_show = adjust_matrix * tmpv; glVertex3f( point_to_show(0)+ bias(0), point_to_show(1)+ bias(1), point_to_show(2)+ bias(2) ); } glEnd(); break; } case RenderMode::SmoothMode:{ break;} case RenderMode::TextureMode:{ break;} case RenderMode::SelectMode:{ break;} default:{} } }
void LogsProcessor::prepare(int id) { log *l = m_logs[id]; l->opened = true; bool result = true; if (l->append) { l->append = false; DWORD inbuffer = 0; DWORD size = GetFileSize(l->hfile, NULL); DWORD buffer_len = m_buffer.getSize(); char *buffer = m_buffer.getData(); int pos = 0; int fileptr = -1; while (size > 0) { DWORD toread = buffer_len - inbuffer; if (toread > size) toread = size; char *p = buffer + inbuffer; DWORD readed = 0; if (!ReadFile(l->hfile, p, toread, &readed, NULL) || toread != readed) { result = false; break; } size -= toread; toread += inbuffer; // find teg in data std::string teg("</body>"); int teg_len = teg.length(); char *s = buffer; char *e = s + toread; while (s != e) { int len = e-s; char *m = (char*)memchr(s, teg.at(0), len); if ( m && (e-m)>=teg_len && !memcmp(teg.c_str(), m, teg_len) ) { fileptr = pos+(m-buffer); break; } if (!m) break; s = s+(m-s)+1; } if (fileptr != -1) break; pos += (toread-teg_len); inbuffer = teg_len; memcpy(buffer, buffer+(toread-teg_len), teg_len); } if (fileptr == -1) result = false; else { SetFilePointer(l->hfile, fileptr, NULL, FILE_BEGIN); SetEndOfFile(l->hfile); write(l->hfile, "<pre>\r\n"); } } if (l->newlog || !result) { l->newlog = false; if (!result) { SetFilePointer(l->hfile, 0, NULL, FILE_BEGIN); SetEndOfFile(l->hfile); } tstring tu; { tu.assign(m_propData->title); SYSTEMTIME tm; GetSystemTime(&tm); tchar buffer[32]; swprintf(buffer, L" - %d %s %d", tm.wDay, month[tm.wMonth], tm.wYear); tu.append(buffer); } char *buffer = m_buffer.getData(); std::string header("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\">\r\n<title>"); header.append(TW2U(tu.c_str())); header.append("</title>\r\n</head>\r\n<style type=\"text/css\">\r\n"); TW2U font(m_propData->font_name.c_str()); sprintf(buffer, "body{ background-color: %s; color: %s; font-size: %dpt; font-weight: %d; font-family: %s }\r\n", color(m_propData->bkgnd), color2(m_palette->getColor(7)), m_propData->font_heigth, m_propData->font_bold, (const char*)font); header.append(buffer); for (int i=0; i<16; ++i) { COLORREF c = m_palette->getColor(i); sprintf(buffer, ".c%d { color: %s } .b%d { background: %s }\r\n", i, color(c), i, color2( i==0 ? m_propData->bkgnd : c )); header.append(buffer); } header.append(".u { text-decoration: underline; }\r\n.b { border: 1px solid; }\r\n.i { font-style: italic; }\r\n"); header.append("</style>\r\n<body><pre>"); write(l->hfile, header); } }
int TestLauncher::testDraw() { Image *img[3]; img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png"); img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png"); img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png"); ImageCollection *const col = new ImageCollection; ImageCollection *const col2 = new ImageCollection; ImageVertexes *const vert = new ImageVertexes; vert->image = img[2]; Skin *skin = theme->load("button.xml", "button.xml"); if (!skin) return 0; mainGraphics->pushClipArea(Rect(10, 20, 790, 580)); mainGraphics->setColor(Color(0xFFU, 0xFFU, 0x00U, 0xFFU)); mainGraphics->drawRectangle(Rect(0, 0, 400, 200)); mainGraphics->setColor(Color(0xFFU, 0x00U, 0x00U, 0xB0U)); img[0]->setAlpha(0.5f); mainGraphics->drawImage(img[0], 190, 383); img[0]->setAlpha(1.0f); mainGraphics->calcWindow(col2, 5, 40, 500, 40, skin->getBorder()); mainGraphics->finalize(col2); mainGraphics->calcTileVertexes(vert, img[2], 10, 10); mainGraphics->calcTileVertexes(vert, img[2], 40, 10); mainGraphics->finalize(vert); mainGraphics->setColor(Color(0x80U, 0x00U, 0xA0U, 0x90U)); mainGraphics->fillRectangle(Rect(200, 100, 300, 300)); mainGraphics->popClipArea(); Color color(0xFFU, 0x00U, 0x00U, 0xB0U); Color color2(0x00U, 0xFFU, 0x00U, 0xB0U); boldFont->drawString(mainGraphics, color, color2, "test test test test test test test test ", 300, 100); mainGraphics->drawTileCollection(col2); mainGraphics->drawPattern(img[0], 10, 400, 300, 180); mainGraphics->calcPattern(col, img[1], 500, 400, 150, 100); mainGraphics->finalize(col); mainGraphics->drawTileVertexes(vert); mainGraphics->drawRescaledImage(img[0], 250, 350, 35, 90); mainGraphics->setColor(Color(0x00U, 0xFFU, 0x00U, 0x90U)); mainGraphics->drawNet(450, 10, 600, 300, 32, 20); mainGraphics->drawTileCollection(col); img[0]->setAlpha(0.3f); mainGraphics->drawRescaledPattern(img[0], 250, 150, 250, 300, 30, 100); for (int f = 0; f < 255; f ++) { mainGraphics->setColor(Color(0x20U, 0x60U, f, 0x90U)); mainGraphics->drawLine(300 + f, 490, 300 + f, 480); for (int d = 0; d < 10; d ++) mainGraphics->drawPoint(300 + f, 500 + d); } mainGraphics->updateScreen(); sleep(10); delete col; return 0; }
void TestApp::test_hsv() { Console::write_line(" Header: color_hsv.h"); Console::write_line(" Class: ColorHSVi"); Console::write_line(" Function: ColorHSVi()"); { ColorHSVi hsv; if (hsv.h !=0) fail(); if (hsv.s !=0) fail(); if (hsv.v !=0) fail(); if (hsv.a !=0) fail(); } Console::write_line(" Function: ColorHSVi(int h, int s, int v, int a)"); { ColorHSVi hsv(1,2,3,4); if (hsv.h != 1) fail(); if (hsv.s != 2) fail(); if (hsv.v != 3) fail(); if (hsv.a != 4) fail(); } Console::write_line(" Function: ColorHSVi(const ColorHSVi ©)"); { ColorHSVi hsv(1,2,3,4); ColorHSVi hsv_copy(hsv); if (hsv_copy.h != 1) fail(); if (hsv_copy.s != 2) fail(); if (hsv_copy.v != 3) fail(); if (hsv_copy.a != 4) fail(); } Console::write_line(" Function: ColorHSVi(const Color &color)"); { Color color(255, 0, 0, 64); ColorHSVi hsv(color); if (hsv.h != 0) fail(); if (hsv.s != 255) fail(); if (hsv.v != 255) fail(); if (hsv.a != 64) fail(); } { Color color(128, 255, 128, 64); ColorHSVi hsv(color); if (hsv.h != 120) fail(); if (hsv.s != 127) fail(); if (hsv.v != 255) fail(); if (hsv.a != 64) fail(); } { Colorf colorf(0.5f, 1.0f, 0.5f, 1.0f); ColorHSVi hsv(colorf); if (hsv.h != 120) fail(); if (hsv.s != 128) fail(); if (hsv.v != 255) fail(); if (hsv.a != 255) fail(); } { Color color(0, 0, 128, 64); ColorHSVi hsv(color); if (hsv.h != 240) fail(); if (hsv.s != 255) fail(); if (hsv.v != 128) fail(); if (hsv.a != 64) fail(); } { Color color(64, 90, 136, 90); ColorHSVi hsv(color); if (hsv.h != 218) fail(); if (hsv.s != 135) fail(); if (hsv.v != 136) fail(); if (hsv.a != 90) fail(); } { Color color(128, 128, 128, 90); ColorHSVi hsv(color); if (hsv.h != 0) fail(); if (hsv.s != 0) fail(); if (hsv.v != 128) fail(); if (hsv.a != 90) fail(); } { Color color(64, 90, 136, 90); ColorHSVi hsv(color); Color color2(hsv); int red = color2.get_red(); int green = color2.get_green(); int blue = color2.get_blue(); int alpha = color2.get_alpha(); if (red != 64) fail(); if (green != 90) fail(); if (blue != 136) fail(); if (alpha != 90) fail(); } Console::write_line(" Class: ColorHSVf"); Console::write_line(" Function: ColorHSVf()"); { ColorHSVf hsv; if (hsv.h !=0.0f) fail(); if (hsv.s !=0.0f) fail(); if (hsv.v !=0.0f) fail(); if (hsv.a !=0.0f) fail(); } Console::write_line(" Function: ColorHSVf(float h, float s, float v, float a)"); { ColorHSVf hsv(0.1f, 0.2f, 0.3f, 0.4f); if (hsv.h != 0.1f) fail(); if (hsv.s != 0.2f) fail(); if (hsv.v != 0.3f) fail(); if (hsv.a != 0.4f) fail(); } Console::write_line(" Function: ColorHSVf(const ColorHSVf ©)"); { ColorHSVf hsv(0.1f, 0.2f, 0.3f, 0.4f); ColorHSVf hsv_copy(hsv); if (hsv_copy.h != 0.1f) fail(); if (hsv_copy.s != 0.2f) fail(); if (hsv_copy.v != 0.3f) fail(); if (hsv_copy.a != 0.4f) fail(); } Console::write_line(" Function: ColorHSVf(const Colorf &color)"); { Colorf color(1.0f, 0.0f, 0.0f, 0.2f); ColorHSVf hsv(color); if (hsv.h != 0.0f) fail(); if (hsv.s != 1.0f) fail(); if (hsv.v != 1.0f) fail(); if (hsv.a != 0.2f) fail(); } { Colorf color(0.5f, 1.0f, 0.5f, 0.2f); ColorHSVf hsv(color); if (hsv.h != 120.0f) fail(); if (hsv.s != 0.5f) fail(); if (hsv.v != 1.0f) fail(); if (hsv.a != 0.2f) fail(); } { Color color(127, 255, 127, 255); ColorHSVf hsv(color); if (hsv.h != 120.0f) fail(); if (hsv.s < 0.49f) fail(); if (hsv.s > 0.51f) fail(); if (hsv.v != 1.0f) fail(); if (hsv.a != 1.0f) fail(); } { Colorf color(0.0f, 0.0f, 0.5, 0.3f); ColorHSVf hsv(color); if (hsv.h != 240.0f) fail(); if (hsv.s != 1.0f) fail(); if (hsv.v != 0.5f) fail(); if (hsv.a != 0.3f) fail(); } { Colorf color(0.2f, 0.4f, 0.7f, 0.3f); ColorHSVf hsv(color); Colorf color2(hsv); if (color.r < 0.1999f) fail(); if (color.r > 0.2001f) fail(); if (color.g < 0.3999f) fail(); if (color.g > 0.4001f) fail(); if (color.b < 0.6999f) fail(); if (color.b > 0.7001f) fail(); if (color.a < 0.2999f) fail(); if (color.a > 0.3001f) fail(); } Console::write_line(" Class: ColorHSVd"); }
// Construct visual object display list. void Floor::initialize() { float divisionsPerSide = sideLength; VertexData v0, v1, v2, v3; short color = 1; buildShaderProgram(); GLuint VBO, IBO; glGenVertexArrays (1, &vertexArrayObject); glBindVertexArray( vertexArrayObject ); vector<VertexData> v; vector<unsigned int> indices; GLfloat tileWidth = sideLength / divisionsPerSide ; // Find corner of the board GLfloat tileX = -( (divisionsPerSide/2.0f) * tileWidth); GLfloat tileZ = ( (divisionsPerSide/2.0f) * tileWidth); // define the two square colors vec4 color1( 0.9f, 0.9f, 0.9f, 1.0f ); vec4 color2( 0.05f, 0.05f, 0.05f, 1.0f ); vec4 currentColor; GLuint currentIndex = 0; // Loop through rows for ( int j = 0 ; j < divisionsPerSide ; j++ ) { currentColor = (color++)%2 ? color1 : color2 ; // Loop through columns for ( int i = 0 ; i < divisionsPerSide ; i++ ) { currentColor = (color++)%2 ? color1 : color2 ; v0 = VertexData ( vec3(tileX, 0.0f, tileZ-tileWidth ), currentColor ); v.push_back( v0 ); v1 = VertexData ( vec3(tileX, 0.0f, tileZ ), currentColor ); v.push_back( v1 ); tileX += tileWidth; v2 = VertexData ( vec3(tileX, 0.0f, tileZ), currentColor ); v.push_back( v2 ); v3 = VertexData ( vec3(tileX, 0.0f, tileZ-tileWidth), currentColor ); v.push_back( v3 ); indices.push_back(currentIndex); indices.push_back(currentIndex + 1); indices.push_back(currentIndex + 2); indices.push_back(currentIndex); indices.push_back(currentIndex + 2); indices.push_back(currentIndex + 3); currentIndex += 4; } // end for i tileX = - ( (divisionsPerSide/2.0f) * tileWidth); tileZ -= tileWidth; } // end for j glGenBuffers(1, &VBO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, v.size() * sizeof(VertexData), &v[0], GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), 0); glEnableVertexAttribArray(0); glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData),(const GLvoid*)sizeof(vec3)); glEnableVertexAttribArray(2); numberOfIndices = indices.size(); glGenBuffers(1, &IBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); v.clear(); indices.clear(); VisualObject::initialize(); } // end initialize
void PlayState::update() { if (!m_gameOver) { //bool moving = false; m_PlayerPos.x += 0.25 + m_Continuous*(0.05); m_Run.setSpeed((int)((0.25 + m_Continuous*(0.05))*10)); //This is a really funny way to do this bool hit = false; if (m_AnimLock == 6) { if (m_Action == 1) { m_audMan.playStereoSample("hit1", m_PlayerPos.x, m_PlayerPos.y); } if (m_Action == 2) { m_audMan.playStereoSample("hit2", m_PlayerPos.x, m_PlayerPos.y); } if (m_Action == 3) { m_audMan.playStereoSample("hit3", m_PlayerPos.x, m_PlayerPos.y); } for (int i=0; i<MAX_AI; ++i) { if (testPoint(i)) { if (m_Action == 1) { m_Score += 1 + m_Continuous; } if (m_Action == 2) { m_Score += 1 + 2*m_Continuous; } if (m_Action == 3) { m_Score += 1 + 3*m_Continuous; } m_AIs[i].speed += 0.05; m_AIs[i].walking = false; m_AIs[i].run.setVisible(true); m_AIs[i].walk.setVisible(false); m_AIs[i].walk.setSpeed((int)(m_AIs[i].speed*20)); m_AIs[i].run.setSpeed((int)(m_AIs[i].speed*20)); hit = true; m_Continuous += 1; switch ((int)Gosu::random(1.0, 7.0)) { case 1: m_audMan.playStereoSample("hurt1", m_AIs[i].pos.x, m_AIs[i].pos.y); break; case 2: m_audMan.playStereoSample("hurt2", m_AIs[i].pos.x, m_AIs[i].pos.y); break; case 3: m_audMan.playStereoSample("hurt3", m_AIs[i].pos.x, m_AIs[i].pos.y); break; case 4: m_audMan.playStereoSample("hurt4", m_AIs[i].pos.x, m_AIs[i].pos.y); break; } } } if (!hit) { m_Continuous = 0; } } if (m_AnimLock == 0) { m_LPunch.setVisible(false); m_RPunch.setVisible(false); m_HButt.setVisible(false); m_Run.setVisible(true); m_Run.setFrame(0); m_AnimLock -= 1; }else{ m_AnimLock -= 1; } InputManager *iman = InputManager::getCurrentContext(); if (iman->query("Play.PunchLeft") == InputManager::actnBegin) { m_Action = 1; m_LPunch.setVisible(true); m_RPunch.setVisible(false); m_HButt.setVisible(false); m_Run.setVisible(false); m_LPunch.setFrame(0); m_AnimLock = 8; } if (iman->query("Play.PunchRight") == InputManager::actnBegin) { m_Action = 2; m_LPunch.setVisible(false); m_RPunch.setVisible(true); m_HButt.setVisible(false); m_Run.setVisible(false); m_RPunch.setFrame(0); m_AnimLock = 16; } if (iman->query("Play.HeadButt") == InputManager::actnBegin) { m_Action = 3; m_LPunch.setVisible(false); m_RPunch.setVisible(false); m_HButt.setVisible(true); m_Run.setVisible(false); m_HButt.setFrame(0); m_AnimLock = 32; } //Update camera focus m_Focus[0] = m_PlayerPos.x; m_Focus[1] = m_PlayerPos.y - 24.0; m_Idle.setX(m_PlayerPos.x); m_Idle.setY(m_PlayerPos.y); m_Run.setX(m_PlayerPos.x); m_Run.setY(m_PlayerPos.y); int c = Gosu::interpolate<int>(255, 50, m_PlayerPos.x/2000.0); Gosu::Color color(255, c, c); m_Run.setColorMod(color); m_LPunch.setColorMod(color); m_RPunch.setColorMod(color); m_HButt.setColorMod(color); double f = m_PlayerPos.x/2000.0; f = f*f; int a = Gosu::interpolate<int>(0, 250, f); Gosu::Color color2(a, 255, c, c); m_Aura->setColorMod(color2); m_Aura->setX(m_PlayerPos.x); m_Aura->setY(m_PlayerPos.y); m_LPunch.setX(m_PlayerPos.x); m_LPunch.setY(m_PlayerPos.y); m_RPunch.setX(m_PlayerPos.x); m_RPunch.setY(m_PlayerPos.y); m_HButt.setX(m_PlayerPos.x); m_HButt.setY(m_PlayerPos.y); for (int i=0; i<MAX_AI; ++i) { if (m_AIs[i].walking) m_AIs[i].pos.x += m_AIs[i].speed; else m_AIs[i].pos.x += m_AIs[i].speed * 2.5; m_AIs[i].walk.setX(m_AIs[i].pos.x); m_AIs[i].walk.setY(m_AIs[i].pos.y); m_AIs[i].run.setX(m_AIs[i].pos.x); m_AIs[i].run.setY(m_AIs[i].pos.y); } m_rendMan.setCamera( m_Focus[0], m_Focus[1], m_Zoom, m_Rot); m_rendMan.update(); m_Graph.update(); }else{ if (m_creditTimer < 1.0) m_creditTimer += 0.01; if (m_creditTimer >= 1.0) { m_creditTimer = 1.0; if (!m_showCredits) m_GameTime = (Gosu::milliseconds() - m_gameTimer)/1000; m_showCredits = true; } m_fade.setRed(255*(1.0-m_creditTimer)); m_fade.setGreen(255*(1.0-m_creditTimer)); m_fade.setBlue(255*(1.0-m_creditTimer)); } if (m_PlayerPos.x > 1800) { if (m_explosTimer < 1.0) m_explosTimer += 0.2; if (m_explosTimer >= 1.0) m_explosTimer = 1.0; m_fade.setAlpha(255*m_explosTimer); if (!m_gameOver) m_audMan.playStereoSample("explosion", m_PlayerPos.x, m_PlayerPos.y); m_gameOver = true; } }
void MainWindow::createActions() { openAct = new QAction("&Open", this); connect(openAct, SIGNAL(triggered()), this, SLOT(openAndReadFile())); exitAct = new QAction("E&xit", this); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction("&About", this); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); statAct = new QAction("&Stat", this); connect(statAct, SIGNAL(triggered()), this, SLOT(showStat())); resetAct = new QAction("&Reset position", this); resetAct->setStatusTip("Reset the position"); connect(resetAct, SIGNAL(triggered()), this, SLOT(reset())); reseteffectAct = new QAction("&Reset", this); reseteffectAct->setStatusTip("Reset all material"); connect(reseteffectAct, SIGNAL(triggered()), this, SLOT(reseteffect())); //ANIMATION----------------------------------------------------- animationShownAct = new QAction("&Shown", this); animationShownAct->setStatusTip("Show animation"); animationShownAct->setCheckable(true); connect(animationShownAct, SIGNAL(triggered()), this, SLOT(showAnimation())); animationHiddenAct = new QAction("&Hidden", this); animationHiddenAct->setStatusTip("Hide animation"); animationHiddenAct->setCheckable(true); connect(animationHiddenAct, SIGNAL(triggered()), this, SLOT(hideAnimation())); animationGroup = new QActionGroup(this); animationGroup->addAction(animationShownAct); animationGroup->addAction(animationHiddenAct); animationHiddenAct->setChecked(true); //COLOR----------------------------------------------------- color0Act = new QAction("&No light",this); color0Act->setStatusTip("No light"); color0Act->setCheckable(true); connect(color0Act, SIGNAL(triggered()), this, SLOT(color0())); color1Act = new QAction("&Red",this); color1Act->setStatusTip("Red"); color1Act->setCheckable(true); connect(color1Act, SIGNAL(triggered()), this, SLOT(color1())); color2Act = new QAction("&Green",this); color2Act->setStatusTip("Green"); color2Act->setCheckable(true); connect(color2Act, SIGNAL(triggered()), this, SLOT(color2())); color3Act = new QAction("&Blue",this); color3Act->setStatusTip("Blue"); color3Act->setCheckable(true); connect(color3Act, SIGNAL(triggered()), this, SLOT(color3())); color10Act = new QAction("&White",this); color10Act->setStatusTip("White"); color10Act->setCheckable(true); connect(color10Act, SIGNAL(triggered()), this, SLOT(color10())); colorGroup = new QActionGroup(this); colorGroup->addAction(color0Act); colorGroup->addAction(color1Act); colorGroup->addAction(color2Act); colorGroup->addAction(color3Act); colorGroup->addAction(color10Act); color10Act->setChecked(true); //EFFECT----------------------------------------------------- effect0Act = new QAction("&No effect",this); effect0Act->setStatusTip("No effect"); effect0Act->setCheckable(true); connect(effect0Act, SIGNAL(triggered()), this, SLOT(effect0())); effect1Act = new QAction("&Ambient",this); effect1Act->setStatusTip("Ambient"); effect1Act->setCheckable(true); connect(effect1Act, SIGNAL(triggered()), this, SLOT(effect1())); effect2Act = new QAction("&Diffuse",this); effect2Act->setStatusTip("Diffuse"); effect2Act->setCheckable(true); connect(effect2Act, SIGNAL(triggered()), this, SLOT(effect2())); effect10Act = new QAction("&All",this); effect10Act->setStatusTip("All effect"); effect10Act->setCheckable(true); connect(effect10Act, SIGNAL(triggered()), this, SLOT(effect10())); effectGroup = new QActionGroup(this); effectGroup->addAction(effect0Act); effectGroup->addAction(effect1Act); effectGroup->addAction(effect2Act); effectGroup->addAction(effect10Act); effect10Act->setChecked(true); //AMBIENT----------------------------------------------------- ambient0Act = new QAction("&No Ambient",this); ambient0Act->setStatusTip("No Ambient"); ambient0Act->setCheckable(true); connect(ambient0Act, SIGNAL(triggered()), this, SLOT(ambient0())); ambient1Act = new QAction("&Ambient",this); ambient1Act->setStatusTip("Ambient"); ambient1Act->setCheckable(true); connect(ambient1Act, SIGNAL(triggered()), this, SLOT(ambient1())); ambient2Act = new QAction("&Ambient Color",this); ambient2Act->setStatusTip("Ambient Color"); ambient2Act->setCheckable(true); connect(ambient2Act, SIGNAL(triggered()), this, SLOT(ambient2())); ambientGroup = new QActionGroup(this); ambientGroup->addAction(ambient0Act); ambientGroup->addAction(ambient1Act); ambientGroup->addAction(ambient2Act); ambient0Act->setChecked(true); //DIFFUSE----------------------------------------------------- diffuse0Act = new QAction("&No Diffuse",this); diffuse0Act->setStatusTip("No Diffuse"); diffuse0Act->setCheckable(true); connect(diffuse0Act, SIGNAL(triggered()), this, SLOT(diffuse0())); diffuse1Act = new QAction("&Diffuse",this); diffuse1Act->setStatusTip("Diffuse"); diffuse1Act->setCheckable(true); connect(diffuse1Act, SIGNAL(triggered()), this, SLOT(diffuse1())); diffuseGroup = new QActionGroup(this); diffuseGroup->addAction(diffuse0Act); diffuseGroup->addAction(diffuse1Act); diffuse0Act->setChecked(true); //SPECULAR----------------------------------------------------- specular0Act = new QAction("&No Specular",this); specular0Act->setStatusTip("No Specular"); specular0Act->setCheckable(true); connect(specular0Act, SIGNAL(triggered()), this, SLOT(specular0())); specular1Act = new QAction("&Specular",this); specular1Act->setStatusTip("Specular"); specular1Act->setCheckable(true); connect(specular1Act, SIGNAL(triggered()), this, SLOT(specular1())); specularGroup = new QActionGroup(this); specularGroup->addAction(specular0Act); specularGroup->addAction(specular1Act); specular0Act->setChecked(true); //SPECULAR----------------------------------------------------- shininess0Act = new QAction("&No Shininess",this); shininess0Act->setStatusTip("No Shininess"); shininess0Act->setCheckable(true); connect(shininess0Act, SIGNAL(triggered()), this, SLOT(shininess0())); shininess1Act = new QAction("&Low Shininess",this); shininess1Act->setStatusTip("Low Shininess"); shininess1Act->setCheckable(true); connect(shininess1Act, SIGNAL(triggered()), this, SLOT(shininess1())); shininess2Act = new QAction("&High Shininess",this); shininess2Act->setStatusTip("High Shininess"); shininess2Act->setCheckable(true); connect(shininess2Act, SIGNAL(triggered()), this, SLOT(shininess2())); shininessGroup = new QActionGroup(this); shininessGroup->addAction(shininess0Act); shininessGroup->addAction(shininess1Act); shininessGroup->addAction(shininess2Act); shininess0Act->setChecked(true); //EMISSION----------------------------------------------------- emission0Act = new QAction("&No Emission",this); emission0Act->setStatusTip("No Emission"); emission0Act->setCheckable(true); connect(emission0Act, SIGNAL(triggered()), this, SLOT(emission0())); emission1Act = new QAction("&Emission",this); emission1Act->setStatusTip("eEmission"); emission1Act->setCheckable(true); connect(emission1Act, SIGNAL(triggered()), this, SLOT(emission1())); emissionGroup = new QActionGroup(this); emissionGroup->addAction(emission0Act); emissionGroup->addAction(emission1Act); emission0Act->setChecked(true); }
//-------------------------------------------------------------------------------- // Initialize_World // Sets up objects, materials, and lights for tests 1 - 4 //-------------------------------------------------------------------------------- void Initialize_World(Render_World& world,const int width,const int height,const int test_number) { Vector_3D<double> color1(1,0,0); Vector_3D<double> color2(.2,.2,.8); Vector_3D<double> plane_color(1,0.775,0.5431); Plane* plane=new Plane(Vector_3D<double>(),Vector_3D<double>(0,1,0)); Sphere* sphere=new Sphere(Vector_3D<double>(0,1,0),1.0); Sphere* sphere2=new Sphere(Vector_3D<double>(-2,1,-1),1.0); //Sphere* sphere3=new Sphere(Vector_3D<double>(-2,1,-5),1.0); switch(test_number) { case 1: plane->material_shader=new Flat_Shader(world,plane_color); sphere->material_shader=new Flat_Shader(world,color1); sphere2->material_shader=new Flat_Shader(world,color2); world.enable_shadows=false; world.recursion_depth_limit=0; world.camera.Position_And_Aim_Camera(Vector_3D<double>(0,4,-6),Vector_3D<double>(0,1,0),Vector_3D<double>(0,1,0)); world.camera.Focus_Camera(1,(double)width/(double)height,(double)70/(double)180*PI); break; case 2: plane->material_shader=new CheckerBoard_Shader(world,plane_color,plane_color); sphere->material_shader=new Phong_Shader(world,color1,color1); sphere2->material_shader=new Phong_Shader(world,color2,color2); world.enable_shadows=false; world.recursion_depth_limit=0; world.camera.Position_And_Aim_Camera(Vector_3D<double>(0,4,-6),Vector_3D<double>(0,1,0),Vector_3D<double>(0,1,0)); world.camera.Focus_Camera(1,(double)width/(double)height,(double)70/(double)180*PI); break; case 3: plane->material_shader=new Phong_Shader(world,plane_color,plane_color); sphere->material_shader=new Phong_Shader(world,color1,color1); sphere2->material_shader=new Phong_Shader(world,color2,color2); world.enable_shadows=true; world.recursion_depth_limit=0; world.camera.Position_And_Aim_Camera(Vector_3D<double>(0,4,-6),Vector_3D<double>(0,1,0),Vector_3D<double>(0,1,0)); world.camera.Focus_Camera(1,(double)width/(double)height,(double)70/(double)180*PI); break; case 4: plane->material_shader=new Phong_Shader(world,plane_color,plane_color); sphere->material_shader=new Reflective_Shader(world,color1,color1,Vector_3D<double>(1,1,1),50,.5); sphere2->material_shader=new Reflective_Shader(world,color2,color2,Vector_3D<double>(1,1,1),50,.5); world.enable_shadows=true; world.recursion_depth_limit=4; world.camera.Position_And_Aim_Camera(Vector_3D<double>(0,4,-6),Vector_3D<double>(-1,1,0),Vector_3D<double>(0,1,0)); world.camera.Focus_Camera(1,(double)width/(double)height,(double)50/(double)180*PI); break; default: std::cout<<"Unrecognized test number"<<std::endl; exit(1); } // lights Light* point_light=new Point_Light(Vector_3D<double>(-2,7,-3),Vector_3D<double>(1,1,1),.25); Light* point_light2=new Point_Light(Vector_3D<double>(3,5,-3),Vector_3D<double>(1,1,1),.25); world.objects.push_back(plane); world.objects.push_back(sphere); world.objects.push_back(sphere2); world.lights.push_back(point_light); world.lights.push_back(point_light2); // camera world.camera.film.Set_Resolution(width,height); }
void TestApp::test_hsl() { Console::write_line(" Header: color_hsl.h"); Console::write_line(" Class: ColorHSLi"); Console::write_line(" Function: ColorHSLi()"); { ColorHSLi hsl; if (hsl.h !=0) fail(); if (hsl.s !=0) fail(); if (hsl.l !=0) fail(); if (hsl.a !=0) fail(); } Console::write_line(" Function: ColorHSLi(int h, int s, int l, int a)"); { ColorHSLi hsl(1,2,3,4); if (hsl.h != 1) fail(); if (hsl.s != 2) fail(); if (hsl.l != 3) fail(); if (hsl.a != 4) fail(); } Console::write_line(" Function: ColorHSLi(const ColorHSLi ©)"); { ColorHSLi hsl(1,2,3,4); ColorHSLi hsl_copy(hsl); if (hsl_copy.h != 1) fail(); if (hsl_copy.s != 2) fail(); if (hsl_copy.l != 3) fail(); if (hsl_copy.a != 4) fail(); } Console::write_line(" Function: ColorHSLi(const Color &color)"); { Color color(255, 0, 0, 64); ColorHSLi hsl(color); if (hsl.h != 0) fail(); if (hsl.s != 255) fail(); if (hsl.l != 128) fail(); if (hsl.a != 64) fail(); } { Color color(128, 255, 128, 64); ColorHSLi hsl(color); if (hsl.h != 120) fail(); if (hsl.s != 255) fail(); if (hsl.l < 191) fail(); if (hsl.l > 192) fail(); if (hsl.a != 64) fail(); } { Colorf colorf(0.5f, 1.0f, 0.5f, 1.0f); ColorHSLi hsl(colorf); if (hsl.h != 120) fail(); if (hsl.s != 255) fail(); if (hsl.l != 191) fail(); if (hsl.a != 255) fail(); } { Color color(0, 0, 128, 64); ColorHSLi hsl(color); if (hsl.h != 240) fail(); if (hsl.s != 255) fail(); if (hsl.l != 64) fail(); if (hsl.a != 64) fail(); } { Color color(64, 90, 136, 90); ColorHSLi hsl(color); if (hsl.h != 218) fail(); if (hsl.s != 92) fail(); if (hsl.l != 100) fail(); if (hsl.a != 90) fail(); } { Color color(128, 128, 128, 90); ColorHSLi hsl(color); if (hsl.h != 0) fail(); if (hsl.s != 0) fail(); if (hsl.l != 128) fail(); if (hsl.a != 90) fail(); } { Color color(64, 90, 136, 90); ColorHSLi hsl(color); Color color2(hsl); int red = color2.get_red(); int green = color2.get_green(); int blue = color2.get_blue(); int alpha = color2.get_alpha(); if (red < 63) fail(); if (red > 65) fail(); if (green != 90) fail(); if (blue != 136) fail(); if (alpha != 90) fail(); } Console::write_line(" Class: ColorHSLf"); Console::write_line(" Function: ColorHSLf()"); { ColorHSLf hsl; if (hsl.h !=0.0f) fail(); if (hsl.s !=0.0f) fail(); if (hsl.l !=0.0f) fail(); if (hsl.a !=0.0f) fail(); } Console::write_line(" Function: ColorHSLf(float h, float s, float l, float a)"); { ColorHSLf hsl(0.1f, 0.2f, 0.3f, 0.4f); if (hsl.h != 0.1f) fail(); if (hsl.s != 0.2f) fail(); if (hsl.l != 0.3f) fail(); if (hsl.a != 0.4f) fail(); } Console::write_line(" Function: ColorHSLf(const ColorHSLf ©)"); { ColorHSLf hsl(0.1f, 0.2f, 0.3f, 0.4f); ColorHSLf hsl_copy(hsl); if (hsl_copy.h != 0.1f) fail(); if (hsl_copy.s != 0.2f) fail(); if (hsl_copy.l != 0.3f) fail(); if (hsl_copy.a != 0.4f) fail(); } Console::write_line(" Function: ColorHSLf(const Colorf &color)"); { Colorf color(1.0f, 0.0f, 0.0f, 0.2f); ColorHSLf hsl(color); if (hsl.h != 0.0f) fail(); if (hsl.s != 1.0f) fail(); if (hsl.l != 0.5f) fail(); if (hsl.a != 0.2f) fail(); } { Colorf color(0.5f, 1.0f, 0.5f, 0.2f); ColorHSLf hsl(color); if (hsl.h != 120.0f) fail(); if (hsl.s != 1.0f) fail(); if (hsl.l != 0.75f) fail(); if (hsl.a != 0.2f) fail(); } { Color color(127, 255, 127, 255); ColorHSLf hsl(color); if (hsl.h != 120.0f) fail(); if (hsl.s != 1.0f) fail(); if (hsl.l < 0.74f) fail(); if (hsl.l > 0.76f) fail(); if (hsl.a != 1.0f) fail(); } { Colorf color(0.0f, 0.0f, 0.5, 0.3f); ColorHSLf hsl(color); if (hsl.h != 240.0f) fail(); if (hsl.s != 1.0f) fail(); if (hsl.l < 0.24f) fail(); if (hsl.l > 0.26f) fail(); if (hsl.a != 0.3f) fail(); } { Colorf color(0.2f, 0.4f, 0.7f, 0.3f); ColorHSLf hsl(color); Colorf color2(hsl); if (color.r < 0.1999f) fail(); if (color.r > 0.2001f) fail(); if (color.g < 0.3999f) fail(); if (color.g > 0.4001f) fail(); if (color.b < 0.6999f) fail(); if (color.b > 0.7001f) fail(); if (color.a < 0.2999f) fail(); if (color.a > 0.3001f) fail(); } }