bool CSTransform::Scale(std::string scale, bool concatenate) { double matrix[16]; std::vector<std::string> scale_vec = SplitString2Vector(scale, ','); if ((scale_vec.size()>1) && (scale_vec.size()!=3)) std::cerr << "CSTransform::Scale: Warning: Number of arguments for operation: \"Scale\" with arguments: \"" << scale << "\" is larger than expected, skipping unneeded! " << std::endl; else if (scale_vec.size()<1) { std::cerr << "CSTransform::Scale: Error: Number of arguments for operation: \"Scale\" with arguments: \"" << scale << "\" is invalid! Skipping" << std::endl; return false; } if (scale_vec.size()>=3) { ParameterScalar ps_scale[3]; double scale_double_vec[3]; for (int n=0;n<3;++n) { ps_scale[n].SetParameterSet(m_ParaSet); ps_scale[n].SetValue(scale_vec.at(n)); int EC = ps_scale[n].Evaluate(); if (EC!=0) return false; scale_double_vec[n]=ps_scale[n].GetValue(); } if (ScaleMatrix(matrix, scale_double_vec)==false) return false; ApplyMatrix(matrix,concatenate); AppendList(SCALE3,ps_scale,3); return true; } if(scale_vec.size()>=1) { ParameterScalar ps_scale(m_ParaSet, scale); int EC = ps_scale.Evaluate(); if (EC!=0) return false; if (ScaleMatrix(matrix, ps_scale.GetValue())==false) return false; ApplyMatrix(matrix,concatenate); AppendList(SCALE,&ps_scale,1); return true; } std::cerr << "CSTransform::Scale: Error: Number of arguments for operation: \"Scale\" with arguments: \"" << scale << "\" is invalid! Skipping" << std::endl; return false; }
void on_draw(ps_context* gc) { int i; ps_color color = {1, 1, 1, 1}; ps_set_source_color(gc, &color); ps_clear(gc); ps_set_line_cap(gc, LINE_CAP_BUTT); ps_set_composite_operator(gc, COMPOSITE_SRC_OVER); ps_identity(gc); ps_set_matrix(gc, adjust); ps_scale(gc, (float)scale, (float)scale); // draw background ps_set_source_gradient(gc, shadowGradient); ps_set_path(gc, shadowPath); ps_fill(gc); // draw quadrant ps_set_source_gradient(gc, quadrantGradient); ps_set_path(gc, quadrantPath); ps_fill(gc); ps_identity(gc); ps_scale(gc, (float)scale, (float)scale); // draw inner bevel ps_set_source_gradient(gc, bevelsGradient); ps_set_fill_rule(gc, FILL_RULE_EVEN_ODD); ps_set_path(gc, innerBevelPath); ps_fill(gc); ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, (float)PI); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_source_gradient(gc, bevelsGradient); ps_set_fill_rule(gc, FILL_RULE_EVEN_ODD); ps_set_path(gc, outerBevelPath); ps_fill(gc); // draw seconds tags { ps_color sc = {0.11f, 0.12f, 0.13f, 0.65f}; ps_set_line_width(gc, 2.0f); ps_set_line_cap(gc, LINE_CAP_ROUND); ps_set_stroke_color(gc, &sc); for (i = 0; i < 60; i++) { if ((i % 5) != 0) { ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, 2 * PI - ((float)i/60.0f) * PI * 2); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, secondTagPath); ps_stroke(gc); } } // draw hours and milliseconds tags for (i = 0; i < 12; i++) { float rot = 2 * PI - (((float)i / 12.0f) * PI * 2); ps_set_line_width(gc, 7.0); ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, (float)rot); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, hourTagPath); ps_stroke(gc); ps_set_line_width(gc, 2.0); ps_identity(gc); ps_translate(gc, -356, -256); ps_rotate(gc, (float)rot); ps_translate(gc, 356, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, msTagPath); ps_stroke(gc); } } //draw cursors { time_t ctime; struct tm *ltime; ctime = time(NULL); ltime = localtime(&ctime); drawCursors(gc, ltime->tm_hour, ltime->tm_min, ltime->tm_sec, millsecons); } //draw glass { ps_color gcol = {0.04f, 0.045f, 0.05f, 0.8f}; ps_identity(gc); ps_set_matrix(gc, adjust); ps_scale(gc, (float)scale, (float)scale); ps_set_composite_operator(gc, COMPOSITE_PLUS); ps_set_source_color(gc, &gcol); ps_set_path(gc, glassPath); ps_fill(gc); } }
static void drawCursors(ps_context*gc, unsigned hours, unsigned minutes, unsigned seconds, unsigned milliseconds) { float hh, mm, ss, ks; ps_color col; if (hours < 13) hh = (((float)hours / 12.0f + (float)minutes / 720.0f) * PI * 2) - PI; else hh = (((float)(hours - 12.0f) / 12.0f + (float)minutes / 720.0f) * PI * 2) - PI; mm = (((float)minutes / 60.0f + (float)seconds / 3600.0f) * 2 * PI) - PI; ss = (((float)seconds / 60.0f) * 2 * PI) - PI; ks = (((float)milliseconds / 1000.0f) * 2 * PI) - PI; // milliseconds col.r = 0.0f; col.g = 0.2f; col.b = 0.6f; col.a = 1.0f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -356, -256); ps_rotate(gc, (float)ks); ps_translate(gc, 356, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, msCursorPath); ps_fill(gc); // seconds shadow col.r = 0.3f; col.g = 0.3f; col.b = 0.3f; col.a = 0.25f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -255, -257); ps_rotate(gc, (float)ss); ps_translate(gc, 255, 257); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, secondCursorPath); ps_fill(gc); // minutes shadow ps_identity(gc); ps_translate(gc, -255.5f, -256.5f); ps_scale(gc, 1.25f, 1.01f); ps_rotate(gc, (float)mm); ps_translate(gc, 255.5f, 256.5f); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, minuteCursorPath); ps_fill(gc); // hours shadow ps_identity(gc); ps_translate(gc, -255.5f, -256.5f); ps_scale(gc, 1.25f, 1.01f); ps_rotate(gc, (float)hh); ps_translate(gc, 255.5f, 256.5f); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, hourCursorPath); ps_fill(gc); // hours col.r = 0.2f; col.g = 0.2f; col.b = 0.22f; col.a = 1.0f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -256, -256); ps_rotate(gc, (float)hh); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, hourCursorPath); ps_fill(gc); // draw screw ps_identity(gc); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, cursorScrewPath); ps_fill(gc); // minutes ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, (float)mm); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, minuteCursorPath); ps_fill(gc); // seconds col.r = 0.65f; col.g = 0.1f; col.b = 0.075f; col.a = 1.0f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -256, -256); ps_rotate(gc, (float)ss); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, secondCursorPath); ps_fill(gc); }