void blend_ass_image(AVPicture *dest, const ASS_Image *image, int imgw, int imgh, enum PixelFormat pixel_format) { uint8_t rgba_color[] = { AR(image->color), AG(image->color), AB(image->color), AA(image->color) }; uint8_t rect_r, rect_g, rect_b, rect_a; int dest_r, dest_g, dest_b, dest_a; int x, y; uint32_t *dst2; uint8_t *src, *src2; uint8_t *dst = dest->data[0]; if (pixel_format != PIX_FMT_RGBA) return; dst += image->dst_y * dest->linesize[0] + image->dst_x * 4; src = image->bitmap; for (y = 0; y < image->h; y++) { dst2 = (uint32_t *) dst; src2 = src; for (x = 0; x < image->w; x++) { uint8_t image_pixel = *(src2++); uint32_t *pixel = (dst2++); rect_r = image_pixel & rgba_color[0]; rect_g = image_pixel & rgba_color[1]; rect_b = image_pixel & rgba_color[2]; rect_a = image_pixel & rgba_color[3]; RGBA_IN(dest_r, dest_g, dest_b, dest_a, pixel); // write subtitle on the image dest_r = ALPHA_BLEND_RGB(dest_r, rect_r, rect_a); dest_g = ALPHA_BLEND_RGB(dest_g, rect_g, rect_a); dest_b = ALPHA_BLEND_RGB(dest_b, rect_b, rect_a); RGBA_OUT(pixel, dest_r, dest_g, dest_b, dest_a); } dst += dest->linesize[0]; src += image->stride; } }
//compute a drawing of the clique around node center and save its size //the call to circular will later be replaced by an dedicated computation DRect UMLGraph::circularBound(node center) { //TODO: hier computecliqueposition(0,...) benutzen, rest weglassen DRect bb; CircularLayout cl; Graph G; GraphAttributes AG(G); NodeArray<node> umlOriginal(G); //TODO: we need to assure that the circular drawing //parameters fit the drawing parameters of the whole graph //umlgraph clique parameter members? OGDF_ASSERT(center->degree() > 0) node lastNode = nullptr; node firstNode = nullptr; adjEntry ae = center->firstAdj(); do { node w = ae->twinNode(); node v = G.newNode(); umlOriginal[v] = w; if (!firstNode) firstNode = v; AG.width(v) = width(w); AG.height(v) = height(w); ae = ae->cyclicSucc(); if (lastNode != nullptr) G.newEdge(lastNode, v); lastNode = v; } while (ae != center->firstAdj()); G.newEdge(lastNode, firstNode); cl.call(AG); for(node v : G.nodes) { m_cliqueCirclePos[umlOriginal[v]] = DPoint(AG.x(v), AG.y(v)); } bb = AG.boundingBox(); return bb; }//circularBound
RGB8 Renderer_gl2::lookupColormap(RGB8 inC, int op) { #define R(k,j) (colormap[k][j].r/255.0) #define G(k,j) (colormap[k][j].g/255.0) #define B(k,j) (colormap[k][j].b/255.0) #define A(k,j) (colormap[k][j].a/255.0) #define AR(k,j) (A(k,j)*R(k,j)) #define AG(k,j) (A(k,j)*G(k,j)) #define AB(k,j) (A(k,j)*B(k,j)) int i1 = inC.r; int i2 = inC.g; int i3 = inC.b; float o1,o2,o3; // o1=o2=o3=0; if (op==OP_MAX) { o1 = MAX(AR(1,i1), MAX(AR(2,i2), AR(3,i3))); o2 = MAX(AG(1,i1), MAX(AG(2,i2), AG(3,i3))); o3 = MAX(AB(1,i1), MAX(AB(2,i2), AB(3,i3))); } else if (op==OP_ADD) { o1 = AR(1,i1) + AR(2,i2) + AR(3,i3); o2 = AG(1,i1) + AG(2,i2) + AG(3,i3); o3 = AB(1,i1) + AB(2,i2) + AB(3,i3); } RGB8 oC; oC.r = o1*255; oC.g = o2*255; oC.b = o3*255; return oC; }
int main(int argc, char*argv[]){ // GalPot Pot("../../Torus/pot/PJM11.Tpot"); Logarithmic Pot(220.,1.,0.9); if(argc<8){ std::cerr<<"Need to pass phase-space point and filename\n"; return 0; } VecDoub X(6,0.); for(unsigned i=0;i<6;++i) X[i]=atof(argv[i+1]); Orbit O(&Pot); // Fudge Actions_AxisymmetricStackel_Fudge AA(&Pot,-30.); // Iterative Torus // IterativeTorusMachine Tor(&AA,&Pot,1e-8,5,1e-3); // Generating Function Actions_Genfunc AG(&Pot,"axisymmetric"); // Average generating Function Actions_Genfunc_Average AGav(&Pot,"axisymmetric"); // uvorb uv_orb UV(&Pot,1.,20.,10,10,"example.delta_uv"); // Polar Adiabatic Actions_PolarAdiabaticApproximation PAA(&Pot,"example.paa",true,false); // Spheroidal Adiabatic Actions_SpheroidalAdiabaticApproximation SAA(&Pot,"example.saa",true,false,-30.); // Spheroidal Adiabatic Actions_StackelFit SF(&Pot); double tt = 10.; if(argc>8) tt=atof(argv[8]); O.integrate(X,tt*Pot.torb(X),0.01*Pot.torb(X)); // O.plot(0,2); std::ofstream outfile; outfile.open(argv[7]); outfile<<"# Fudge Genfunc GenfuncAv uvOrb PAA SAA FIT\n"; int guess_alpha=1; VecDoub Fudge, ITorus, Genfunc, GenfuncAv, uvAct, paaAct, saaAct, fitAct; for(auto i:O.results()){ Fudge = AA.actions(i,&guess_alpha); // ITorus = Tor.actions(i); Genfunc = AG.actions(i); GenfuncAv = AGav.actions(i); uvAct = UV.actions(i); paaAct = PAA.actions(i); saaAct = SAA.actions(i,&guess_alpha); fitAct = SF.actions(i); outfile <<Fudge[0]<<" "<<Fudge[2]<<" " // <<ITorus[0]<<" "<<ITorus[2]<<" " <<Genfunc[0]<<" "<<Genfunc[2]<<" " <<GenfuncAv[0]<<" "<<GenfuncAv[2]<<" " <<uvAct[0]<<" "<<uvAct[2]<<" " <<paaAct[0]<<" "<<paaAct[2]<<" " <<saaAct[0]<<" "<<saaAct[2]<<" " <<fitAct[0]<<" "<<fitAct[2]<<" "; for(auto j:i) outfile<<j<<" "; outfile <<std::endl; } outfile.close(); }
int PlanRepInc::genusLayout(Layout &drawing) const { Graph testGraph; GraphAttributes AG(testGraph, GraphAttributes::nodeGraphics | GraphAttributes::edgeGraphics | GraphAttributes::nodeStyle | GraphAttributes::edgeStyle ); Layout xy; NodeArray<node> tcopy(*this, 0); EdgeArray<bool> finished(*this, false); EdgeArray<edge> eOrig(testGraph, 0); Color invalid(0,0,0,0); EdgeArray<Color> eCol(*this, invalid); if (numberOfNodes() == 0) return 0; int nIsolated = 0; for(node v : nodes) if (v->degree() == 0) ++nIsolated; NodeArray<int> component(*this); int nCC = connectedComponents(*this,component); AdjEntryArray<bool> visited(*this,false); int nFaceCycles = 0; int colBase = 3; int colBase2 = 250; for(node v : nodes) { Color col =Color(colBase,colBase2,colBase); colBase = (colBase*3) % 233; colBase2 = (colBase*2) % 233; if (tcopy[v] == 0) { node u = testGraph.newNode(); tcopy[v] = u; AG.x(u) = drawing.x(v); AG.y(u) = drawing.y(v); AG.fillColor(u) = col; AG.strokeColor(u) = Color::Red; AG.strokeWidth(u) = 8; }//if for(adjEntry adj1 : v->adjEdges) { bool handled = visited[adj1]; adjEntry adj = adj1; do { node z = adj->theNode(); if (tcopy[z] == 0) { node u1 = testGraph.newNode(); tcopy[z] = u1; AG.x(u1) = drawing.x(z); AG.y(u1) = drawing.y(z); AG.fillColor(u1) = col; }//if not yet inserted in the copy if (!finished[adj->theEdge()]) { node w = adj->theEdge()->opposite(z); if (tcopy[w] != 0) { edge e; if (w == adj->theEdge()->source()) e = testGraph.newEdge(tcopy[w], tcopy[z]); else e = testGraph.newEdge(tcopy[z], tcopy[w]); eOrig[e] = adj->theEdge(); if (eCol[adj->theEdge()] == invalid) AG.strokeColor(e) = eCol[adj->theEdge()]; else { eCol[adj->theEdge()] = col; AG.strokeColor(e) = col; } finished[adj->theEdge()] = true; } /* else { eCol[adj->theEdge()] = col; }*/ } visited[adj] = true; adj = adj->faceCycleSucc(); } while (adj != adj1); if (handled) continue; ++nFaceCycles; } } //insert the current embedding order by setting bends //for(node v : testGraph.nodes) //{ // adjEntry ad1 = v->firstAdj(); //} int genus = (numberOfEdges() - numberOfNodes() - nIsolated - nFaceCycles + 2*nCC) / 2; //if (genus != 0) { GraphIO::writeGML(AG, "GenusErrorLayout.gml"); } return genus; }
static void overlay_ass_image(AssContext *ass, AVFrame *picref, const ASS_Image *image) { for (; image; image = image->next) { uint8_t rgba_color[] = {AR(image->color), AG(image->color), AB(image->color), AA(image->color)}; FFDrawColor color; ff_draw_color(&ass->draw, &color, rgba_color); ff_blend_mask(&ass->draw, &color, picref->data, picref->linesize, picref->width, picref->height, image->bitmap, image->stride, image->w, image->h, 3, 0, image->dst_x, image->dst_y); } }