void MultiplesTangentes::draw() { if(Dessinable()) { ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, Alpha() * 255); ofSetLineWidth(lineWidth()); float distance(Tools::getDistance(*Origine(), *Destination())); float angle(Tools::getAngle(*Origine(), *Destination())); ofVec2f milieu(Origine()->getMiddle(*Destination())); tangente()->Origine(&milieu); tangente()->rayon(distance / 2.); tangente()->Dessinable(Dessinable()); tangente()->Alpha(Alpha()); tangente()->lineWidth(lineWidth()); for(int i = 0; i < nombreDeTangentesMax(); i += _step) { tangente()->angle(angle * (1 + i / (float)nombreDeTangentesMax() * M_PI)); tangente()->draw(); } ofDisableAlphaBlending(); ofPopStyle(); } }
void Ship::draw() { int a = 255; if (muteki) a = 150; if (cnt % 10 < 5) TextureAsset(L"atoi")(0, 0, 300, 430).scale(0.2).drawAt(pos, Alpha(a)); else TextureAsset(L"atoi")(300, 0, 300, 430).scale(0.2).drawAt(pos, Alpha(a)); if (slowMove) Circle(pos, rad).draw({ 255, 0, 0, 255 }); }
void SUIPictureBox::Draw( float timeDelta ) { SRectangle texRect = GetTexRect(); picture->Draw(timeDelta); if (transformation && transformation->State() != Hidden) { if (targetPicture) { targetPicture->Draw(timeDelta); transformation->SetTarget(targetPicture->GetTarget()); } //SPSpriteManager::GetSingleton()->RenderOnScreen(picture->GetTarget(), // transformation, texRect, SPColor::White, 1, childTarget ); SPSpriteManager::GetSingleton()->RenderWithMatrix(picture->GetTarget(), transformation, TransformMatrixImage(), ImageSrcRect().CRect(), D3DXVECTOR3(0,0,0), PositionImage(), Alpha() * (D3DXCOLOR)SPColor::White, childTarget); } else { //SPSpriteManager::GetSingleton()->RenderOnScreen(picture->GetTarget(), // NULL, texRect, SPColor::White, 1, childTarget ); SPSpriteManager::GetSingleton()->RenderWithMatrix(picture->GetTarget(), NULL, TransformMatrixImage(), ImageSrcRect().CRect(), D3DXVECTOR3(0,0,0), PositionImage(), Alpha() * (D3DXCOLOR)SPColor::White, childTarget); } }
int LearnCV(TMatrix input, TVariables output, unsigned int minFeatures, unsigned int upToPower, unsigned int folds, TPoint *ray, unsigned int *power){ bool oldOUT_ALPHA = OUT_ALPHA; OUT_ALPHA = false; unsigned int optDegree = 0; unsigned int optError = INT_MAX; unsigned int shortFolds = folds - 1; /* Get the optimal degree (outer cross-validation loop) */ vector<TMatrix> spaceExtensions(upToPower); for (unsigned int i = 0; i < upToPower; i++){ ExtendWithProducts(input, i + 1, &spaceExtensions[i]); // get the (i + 1)-th space extention Initialization(spaceExtensions[i], output, minFeatures); // initialize /* Prepare slider and start to cut data */ unsigned sliderSize = (unsigned)ceil((double)n / folds); unsigned chSizeVal = n%folds - 1; TMatrix xSlider(sliderSize); TVariables ySlider(sliderSize); for (unsigned int j = 0; j < sliderSize; j++){ xSlider[j] = TPoint(d); for (unsigned int k = 0; k < d; k++){xSlider[j][k] = x[k][j*shortFolds]; x[k].erase(x[k].begin() + j*shortFolds);} ySlider[j] = y[j*shortFolds]; y.erase(y.begin() + j*shortFolds); difference -= ySlider[j]; if (ySlider[j] > 0){numMore--;}else{numLess--;} } n -= sliderSize; /* Cross-validation for the (i + 1)-th space extension (inner cross-validation loop) */ unsigned int error = 0; TPoint p(0); double tmpXSliderVal; int tmpYSliderVal; for (unsigned int j = 0; j < folds; j++){ /* Estimate the current cut */ Alpha(&p); TVariables res(0); Classify(xSlider, p, &res); for (unsigned int k = 0; k < sliderSize; k++){error += abs(res[k] - ySlider[k])/2;} /* Increment the pointer */ if (j == shortFolds){break;} /* Replace the slider */ if (j == chSizeVal){ for (unsigned int l = 0; l < d; l++){x[l].push_back(xSlider[sliderSize - 1][l]);} y.push_back(ySlider[sliderSize - 1]); n++; difference += ySlider[sliderSize - 1]; if (ySlider[sliderSize - 1] > 0){numMore++;}else{numLess++;} sliderSize--; xSlider.erase(xSlider.begin() + sliderSize); ySlider.erase(ySlider.begin() + sliderSize); // for (unsigned int j = 0; j < d; j++){x[j].shrink_to_fit();} y.shrink_to_fit(); - IT IS TOO DANGEROUS } for (unsigned int k = 0; k < sliderSize; k++){ for (unsigned int l = 0; l < d; l++){tmpXSliderVal = x[l][k*shortFolds + j]; x[l][k*shortFolds + j] = xSlider[k][l]; xSlider[k][l] = tmpXSliderVal;} difference += ySlider[k]; if (ySlider[k] > 0){numMore++;}else{numLess++;} tmpYSliderVal = y[k*shortFolds + j]; y[k*shortFolds + j] = ySlider[k]; ySlider[k] = tmpYSliderVal; difference -= ySlider[k]; if (ySlider[k] > 0){numMore--;}else{numLess--;} } } /* Check if we've got a better result */ if (error < optError){optError = error; optDegree = i + 1; if (optError == 0){break;}} } OUT_ALPHA = oldOUT_ALPHA; /* Eventually get the classification ray */ Initialization(spaceExtensions[optDegree - 1], output, minFeatures); // initialize power[0] = optDegree; return Alpha(ray); }
void LRMachine::trainByNormalEcuation() { // Actualizo aqui el número de características int nFeaturesCuad = 2*C_nFeatures; // Obtengo la X arma::mat X = arma::mat(C_trainingSet.size(), nFeaturesCuad+1); for(unsigned int i = 0; i < C_trainingSet.size(); i++){ for(int j = 0; j < C_nFeatures+1; j++){ if(j==0){ X(i,j) = 1.0; } else{ X(i,j) = C_trainingSet[i].getInput()[j-1]; } } } // Elementos cuadráticos for(unsigned int i = 0; i < C_trainingSet.size(); i++){ for(int j = 0; j < C_nFeatures; j++){ X(i,C_nFeatures+j+1) = pow(C_trainingSet[i].getInput()[j],2.0); } } // Obtengo la Y arma::mat y = arma::mat(C_trainingSet.size(), C_trainingSet[0].getResult().size()); for(unsigned int i=0; i<C_trainingSet.size(); i++){ for(unsigned int j=0; j<C_trainingSet[0].getResult().size(); j++){ y(i,j) = C_trainingSet[i].getResult()[j]; } } // Calculo la matriz de alpha arma::mat Alpha(nFeaturesCuad+1, nFeaturesCuad+1); Alpha.eye(); Alpha(0,0)=0; alphaTrain*Alpha; // std::cout << Alpha; // Inicializo theta arma::mat theta = arma::mat(nFeaturesCuad+1, 1); // Calculo vectorialmente theta = arma::pinv(X.t()*X+Alpha)*X.t()*y; // std::cout << theta; C_theta.clear(); for(int i=0; i<nFeaturesCuad+1; i++){ C_theta.push_back(theta(i)); } }
//----------------------------------------------------------------------------- void mglGraph::CloudP(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch, mreal alpha, bool rnd) { register long i,j,k,n=a.nx,m=a.ny,l=a.nz; if(n<2 || m<2 || l<2) { SetWarn(mglWarnLow,"CloudP"); return; } bool both = x.nx*x.ny*x.nz==n*m*l && y.nx*y.ny*y.nz==n*m*l && z.nx*z.ny*z.nz==n*m*l; if(!(both || (x.nx==n && y.nx==m && z.nx==l))) { SetWarn(mglWarnDim,"CloudP"); return; } static int cgid=1; StartGroup("CloudP",cgid++); if(alpha<0) alpha = AlphaDef; if(sch && strchr(sch,'-')) alpha = -alpha; SetScheme(sch); alpha /= pow(n*m*l,1./3)/CloudFactor/15; if(alpha>1) alpha = 1; // x, y -- матрицы как и z bool al=Alpha(true); register mreal xx,yy,zz,aa; if(both) { for(i=0;i<n*m*l;i++) { if(rnd) { xx=x.a[i]; yy=y.a[i]; zz=z.a[i]; aa=a.a[i]; } else { register mreal tx,ty; tx=mgl_rnd(); ty=mgl_rnd(); zz=mgl_rnd(); aa=a.Spline1(tx,ty,zz); xx=x.Spline1(tx); yy=y.Spline1(ty); zz=z.Spline1(zz); } AVertex(xx,yy,zz,aa,alpha); } } else // x, y -- вектора { for(i=0;i<n;i++) for(j=0;j<m;j++) for(k=0;k<l;k++) { if(rnd) { xx=x.a[i]; yy=y.a[j]; zz=z.a[k]; aa=a.a[i+n*(j+m*k)]; } else { xx=mgl_rnd(); yy=mgl_rnd(); zz=mgl_rnd(); aa=a.Spline1(xx,yy,zz); xx=x.Spline1(xx); yy=y.Spline1(yy); zz=z.Spline1(zz); } AVertex(xx,yy,zz,aa,alpha); } } Alpha(al); EndGroup(); }
//----------------------------------------------------------------------------- // // CloudQ series // //----------------------------------------------------------------------------- void mglGraph::Cloud(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch, mreal alpha) { long i,j,k,n=a.nx,m=a.ny,l=a.nz; register int i0,i1; if(n<2 || m<2 || l<2) { SetWarn(mglWarnLow,"CloudQ"); return; } bool both = x.nx*x.ny*x.nz==n*m*l && y.nx*y.ny*y.nz==n*m*l && z.nx*z.ny*z.nz==n*m*l; if(!(both || (x.nx==n && y.nx==m && z.nx==l))) { SetWarn(mglWarnDim); return; } static int cgid=1; StartGroup("CloudQ",cgid++); int tx=1,ty=1,tz=1; if(MeshNum>1) { tx=(n-1)/(MeshNum-1); ty=(m-1)/(MeshNum-1); tz=(l-1)/(MeshNum-1);} if(tx<1) tx=1; if(ty<1) ty=1; if(tz<1) tz=1; if(alpha<0) alpha = AlphaDef; if(sch && strchr(sch,'-')) alpha = -alpha; alpha /= pow(n/tx*m/ty*l/tz,1./3)/CloudFactor/5; if(alpha>1) alpha = 1; SetScheme(sch); mreal *pp = new mreal[3*n*m*l]; if(!pp) { SetWarn(mglWarnMem); return; } mreal *aa = new mreal[n*m*l]; // x, y -- матрицы как и z if(both) for(i=0;i<n/tx;i++) for(j=0;j<m/ty;j++) for(k=0;k<l/tz;k++) { i0 = i+(n/tx)*(j+(m/ty)*k); i1 = i*tx+n*(j*ty+m*k*tz); pp[3*i0] = x.a[i1]; pp[3*i0+1]= y.a[i1]; pp[3*i0+2]= z.a[i1]; aa[i0] = a.a[i1]; } // x, y -- вектора else for(i=0;i<n/tx;i++) for(j=0;j<m/ty;j++) for(k=0;k<l/tz;k++) { i0 = i+(n/tx)*(j+(m/ty)*k); pp[3*i0] = x.a[i*tx]; pp[3*i0+1]= y.a[j*ty]; pp[3*i0+2]= z.a[k*tz]; aa[i0] = a.a[i*tx+n*(j*ty+m*k*tz)]; } bool al=Alpha(true); cloud_plot(n/tx,m/ty,l/tz,pp,aa,alpha); Alpha(al); EndGroup(); delete []pp; delete []aa; }
LKColor LKColor::MixColors(const LKColor& Color2, double fFact1) const { double fFact2 = 1.0f - fFact1; #ifdef GREYSCALE int Luminosity1 = GetLuminosity(); int Luminosity2 = Color2.GetLuminosity(); int Luminosity = (int) (fFact1 * (double) Luminosity1 + fFact2 * (double) Luminosity2); if (Luminosity > 255) Luminosity = 255; return Color(Luminosity, Alpha()); #else uint8_t red1 = Red(); uint8_t green1 = Green(); uint8_t blue1 = Blue(); uint8_t red2 = Color2.Red(); uint8_t green2 = Color2.Green(); uint8_t blue2 = Color2.Blue(); int red = (int) (fFact1 * (double) red1 + fFact2 * (double) red2); if (red > 255) red = 255; int green = (int) (fFact1 * (double) green1 + fFact2 * (double) green2); if (green > 255) green = 255; int blue = (int) (fFact1 * (double) blue1 + fFact2 * (double) blue2); if (blue > 255) blue = 255; return LKColor((uint8_t) red, (uint8_t) green, (uint8_t) blue); #endif }
/*-------------------------------------------------------------------------* * Chart * * * * Generate samples from the current spherical triangle. If x1 and x2 are * * random variables uniformly distributed over [0,1], then the returned * * points are uniformly distributed over the solid angle. * * * *-------------------------------------------------------------------------*/ Vec3 SphericalTriangle::Chart( float x1, float x2 ) const { // Use one random variable to select the area of the sub-triangle. // Save the sine and cosine of the angle phi. register float phi = x1 * area - Alpha(); register float s = sin( phi ); register float t = cos( phi ); // Compute the pair (u,v) that determines the new angle beta. register float u = t - cos_alpha; register float v = s + product ; // sin_alpha * cos_c // Compute the cosine of the new edge b. float q = ( cos_alpha * ( v * t - u * s ) - v ) / ( sin_alpha * ( u * t + v * s ) ); // Compute the third vertex of the sub-triangle. Vec3 C_new = q * A() + Sqrt( 1.0 - q * q ) * U; // Use the other random variable to select the height z. float z = 1.0 - x2 * ( 1.0 - C_new * B() ); // Construct the corresponding point on the sphere. Vec3 D = C_new / B(); // Remove B component of C_new. return z * B() + Sqrt( ( 1.0 - z * z ) / ( D * D ) ) * D; }
/*-------------------------------------------------------------------------* * Coord * * * * Compute the two coordinates (x1,x2) corresponding to a point in the * * spherical triangle. This is the inverse of "Chart". * * * *-------------------------------------------------------------------------*/ Vec2 SphericalTriangle::Coord( const Vec3 &P1 ) const { Vec3 P = Unit( P1 ); // Compute the new C vertex, which lies on the arc defined by B-P // and the arc defined by A-C. Vec3 C_new = Unit( ( B() ^ P ) ^ ( C() ^ A() ) ); // Adjust the sign of C_new. Make sure it's on the arc between A and C. if( C_new * ( A() + C() ) < 0.0 ) C_new = -C_new; // Compute x1, the area of the sub-triangle over the original area. float cos_beta = CosDihedralAngle( A(), B(), C_new ); float cos_gamma = CosDihedralAngle( A(), C_new , B() ); float sub_area = Alpha() + acos( cos_beta ) + acos( cos_gamma ) - Pi; float x1 = sub_area / SolidAngle(); // Now compute the second coordinate using the new C vertex. float z = P * B(); float x2 = ( 1.0 - z ) / ( 1.0 - C_new * B() ); if( x1 < 0.0 ) x1 = 0.0; if( x1 > 1.0 ) x1 = 1.0; if( x2 < 0.0 ) x2 = 0.0; if( x2 > 1.0 ) x2 = 1.0; return Vec2( x1, x2 ); }
void cUIControlAnim::StartAlphaAnim( const eeFloat& From, const eeFloat& To, const cTime& TotalTime, const bool& AlphaChilds, const Ease::Interpolation& Type, cInterpolation::OnPathEndCallback PathEndCallback ) { if ( NULL == mAlphaAnim ) mAlphaAnim = eeNew( cInterpolation, () ); mAlphaAnim->ClearWaypoints(); mAlphaAnim->AddWaypoint( From ); mAlphaAnim->AddWaypoint( To ); mAlphaAnim->SetTotalTime( TotalTime ); mAlphaAnim->Start( PathEndCallback ); mAlphaAnim->Type( Type ); Alpha( From ); if ( AlphaChilds ) { cUIControlAnim * AnimChild; cUIControl * CurChild = mChild; while ( NULL != CurChild ) { if ( CurChild->IsAnimated() ) { AnimChild = reinterpret_cast<cUIControlAnim*> ( CurChild ); AnimChild->StartAlphaAnim( From, To, TotalTime, AlphaChilds ); } CurChild = CurChild->NextGet(); } } }
void Graphics3DExtrude::drawArc(const Pnt2f& Center, const Real32& Width, const Real32& Height, const Real32& StartAngleRad, const Real32& EndAngleRad, const Real32& LineWidth, const UInt16& SubDivisions, const Color4f& Color, const Real32& Opacity) const { GLfloat previousLineWidth; glGetFloatv(GL_LINE_WIDTH, &previousLineWidth); Real32 angleNow = StartAngleRad; Real32 angleDiff = (EndAngleRad-StartAngleRad)/(static_cast<Real32>(SubDivisions)); //If andle difference is bigger to a circle, set it to equal to a circle if(EndAngleRad-StartAngleRad > 2*3.1415926535) angleDiff = 2*3.1415926535/static_cast<Real32>(SubDivisions); Real32 Alpha(Color.alpha() * Opacity * getOpacity()); if(Alpha < 1.0) { //Setup the blending equations properly glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); } glLineWidth(LineWidth); glBegin(GL_LINE_STRIP); glColor4f(Color.red(), Color.green(), Color.blue(), Alpha ); //draw vertex lines for(UInt16 i = 0 ; i<SubDivisions+1 ; ++i) { glVertex2f( static_cast<Real32>(Center.x()) + static_cast<Real32>(Width)*osgCos(angleNow ),static_cast<Real32>(Center.y()) +static_cast<Real32>(Height)*osgSin(angleNow)); //glVertex2f(Center.x() + Width*osgCos(angleNow + angleDiff), Center.y() + Height*osgSin(angleNow+angleDiff)); angleNow += angleDiff; } glEnd(); if(Alpha < 1.0) { glDisable(GL_BLEND); } glLineWidth(previousLineWidth); }
void Graphics3DExtrude::drawText(const Pnt2f& Position, const std::string& Text, const UIFontUnrecPtr TheFont, const Color4f& Color, const Real32& Opacity) const { TextLayoutParam layoutParam; layoutParam.spacing = 1.1; layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN; layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN; TextLayoutResult layoutResult; TheFont->layout(Text, layoutParam, layoutResult); TheFont->getTexture()->activate(getDrawEnv()); Real32 Alpha(Color.alpha() * Opacity * getOpacity()); //Setup the blending equations properly glPushAttrib(GL_COLOR_BUFFER_BIT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(Color.red(), Color.green(), Color.blue(), Alpha ); glPushMatrix(); glTranslatef(Position.x(), Position.y(), 0.0); glScalef(TheFont->getSize(), TheFont->getSize(), 1); drawCharacters(layoutResult, TheFont); glPopMatrix(); TheFont->getTexture()->deactivate(getDrawEnv()); glDisable(GL_BLEND); glPopAttrib(); }
Image TextureResourceLoader::clipImage(const Image& baseImage, const RectF& rectClip, const ColorF& transColor) { // from Siv3D Slack auto new_image = baseImage.clip(rectClip); for (auto& p : new_image) if (p == transColor) p = Alpha(0); return new_image; }
void TextObject::Draw(ID3D10Device * device, Camera2D * camera) { DrawableObject::Draw(device, camera); if (Alpha() <= 0.0f && mHasShown) { return; } Vector2 worldPos = Vector2(m_position.X - (m_dimensions.X * 0.5f), m_position.Y); Vector2 screenPos = Utilities::WorldToScreen(worldPos); mFontColor.a = Alpha(); RECT bounds = { screenPos.X, screenPos.Y, screenPos.X + m_dimensions.X, screenPos.Y + m_dimensions.Y }; mFont->DrawText(0, mCachedWideString, -1, &bounds, mNoClip ? DT_NOCLIP : DT_WORDBREAK, mFontColor); }
DnaPolygon() { vertex_.push_back(DnaPoint(RangeRand(Settings::ScreenWidth), RangeRand(Settings::ScreenHeight))); vertex_.push_back(DnaPoint(RangeRand(Settings::ScreenWidth), RangeRand(Settings::ScreenHeight))); vertex_.push_back(DnaPoint(RangeRand(Settings::ScreenWidth), RangeRand(Settings::ScreenHeight))); Color(R255, R255, R255); Alpha(IntervalRand(Settings::AlphaMin, Settings::AlphaMax)); }
void Perpendiculaire::draw() { if(Dessinable()) { ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, Alpha() * 255); ofSetLineWidth(lineWidth()); float angle(Tools::getAngle(*Origine(), *Destination())); ofVec2f AB(Destination()->x - Origine()->x, Destination()->y - Origine()->y); ofPushMatrix(); ofTranslate(*Origine() + positionRelative * AB); ofRotateZ(angle); if(showSymbole) { float tailleSymbole(ofClamp(10 * lineWidth(), 15, 50)); ofLine(0, tailleSymbole, tailleSymbole, tailleSymbole); ofLine(tailleSymbole, 0, tailleSymbole, tailleSymbole); } ofVec2f from(0, -ofGetHeight() * 2); ofVec2f to(0, ofGetHeight() * 2); if(typeTrace() == TRACE_POINTILLES) { SegmentDroite pointilles(ofxOscRouterBaseNode::getFirstOscNodeAlias() + "-segment", '@', &from, &to, TRACE_POINTILLES); pointilles.Alpha(Alpha()); pointilles.Dessinable(Dessinable()); pointilles.lineWidth(lineWidth()); pointilles.offset(offset()); pointilles.draw(); } else { ofLine(from, to); } ofPopMatrix(); ofDisableAlphaBlending(); ofPopStyle(); } }
/** * Returns the shadowed version of this color. */ constexpr Color Shadow() const { #ifdef GREYSCALE return Color(GetLuminosity() * 15u / 16u); #else return Color(Red() * 15u / 16u, Green() * 15u / 16u, Blue() * 15u / 16u, Alpha()); #endif }
TSIL_COMPLEX dBds_analytic (TSIL_REAL x, TSIL_REAL y, TSIL_COMPLEX s, TSIL_REAL qq) { TSIL_REAL thxy, psxy, sqrtx, sqrty, alphax, alphay, temp; TSIL_COMPLEX Btemp, result; if (x < y) {temp = y; y = x; x = temp;} if (x + TSIL_CABS(s) < TSIL_TOL) { TSIL_Warn("dBds_analytic", "dBds(0,0) is undefined when s=0."); return TSIL_Infinity; } if (TSIL_CABS(s/x) < TSIL_TOL) return BprimeAtZero (x, y, qq); thxy = Th2 (x, y); psxy = Ps2 (x, y); sqrtx = TSIL_SQRT(x); sqrty = TSIL_SQRT(y); alphax = Alpha(x,qq); alphay = Alpha(y,qq); if (TSIL_CABS(1.0L - s/thxy) < TSIL_TOL) { TSIL_Warn("dBds_analytic", "dBds(x,y) is undefined at threshold."); return TSIL_Infinity; } if (TSIL_CABS(1.0L - s/psxy) < TSIL_TOL) { return (0.5L * alphax * (1.0L + sqrty/sqrtx) - 0.5L * alphay * (1.0L + sqrtx/sqrty) + 2.0L * (sqrty - sqrtx) )/TSIL_POW(sqrtx - sqrty,3); } Btemp = B (x, y, s, qq); result = (0.5L/s) * ( (thxy * Btemp - s + (sqrtx + sqrty)*(alphax + alphay))/(s - thxy) + (psxy * Btemp - s + (sqrtx - sqrty)*(alphax - alphay))/(s - psxy)); return result; }
virtual std::ostream& Print (std::ostream& os) const { Operator<T>::Print(os); os << " image size: rank(" << Rank() << ") side(" << ImageSize() << ") nodes(" << KSpaceSize() << ")" << std::endl; os << " nfft: maxit(" << Maxit() << ") eps(" << Epsilon() << ") alpha(" << Alpha() << ") m("<< m_m <<") sigma(" << Sigma() << ")" << std::endl; os << " have_kspace(" << m_have_kspace << ") have_weights(" << m_have_weights << ") have_b0(" << m_have_b0 << ")" << std::endl; os << " ft-threads(" << m_np << ")"; if (m_3rd_dim_cart) os << " 3rd dimension (" << m_ncart << ") is Cartesian."; return os; }
void TextObject::XmlRead(TiXmlElement * element) { DrawableObject::XmlRead(element); mStringId = XmlUtilities::ReadAttributeAsString(element, "font_properties", "string_id"); mFontName = XmlUtilities::ReadAttributeAsString(element, "font_properties", "name"); mFontSize = XmlUtilities::ReadAttributeAsFloat(element, "font_properties", "size"); mFontColor.r = XmlUtilities::ReadAttributeAsFloat(element, "font_color", "r"); mFontColor.g = XmlUtilities::ReadAttributeAsFloat(element, "font_color", "g"); mFontColor.b = XmlUtilities::ReadAttributeAsFloat(element, "font_color", "b"); mFontColor.a = Alpha(); }
static UINT Fire(UINT what) { switch (what) { case 0: return FALL_THROUGH; case FIRE_NOTHING: break; case FIRE_POWER: Power(); break; case FIRE_EJECT: Eject(); break; case FIRE_FLIP3D: Flip3D(); break; case FIRE_BRIGHT_DN: Bright(-BRIGHT_STEP); break; case FIRE_BRIGHT_UP: Bright(+BRIGHT_STEP); break; case FIRE_ALPHA_DN: Alpha(-ALPHA_DELTA); break; case FIRE_ALPHA_UP: Alpha(+ALPHA_DELTA); break; default: if (FIRE_CMD_0 <= what && what < FIRE_CMD_0 + ARRAYSIZE(config_szCmds)) Exec(config_szCmds[what - FIRE_CMD_0]); else SendKey(what); } return FIRED; }
// 毎フレーム update() の次に呼ばれる void Rule::draw() const { int t = System::FrameCount()*3; game1_m.draw(t % (1280 * 3) - 1280, 0, Alpha(50)); game2_m.draw((t+1280) % (1280 * 3) - 1280, 0, Alpha(50)); game3_m.draw((t + 2560) % (1280 * 3) - 1280, 0, Alpha(50)); for (int i = 0; i < 40; i++) { cir[i].draw(); } RoundRect(Rect(700, 700).setCenter(Window::Center()).movedBy(0, 0), 20).draw(Color(Palette::White, 180)).drawFrame(0.0, 3.0, Palette::Black); mainimage.drawAt(Window::Width() / 2, Window::Height() * 3 / 4 - 90); title(L"ルール!").drawCenter({ Window::Width() / 2, title.size }, Color(255, 0, 0)); text(L"これはガベージコレクションをするゲームです").drawCenter({ Window::Width() / 2, (title.size + text.size) * 2 }, Color(0, 0, 0)); subtitle(L"やり方").drawCenter({ Window::Width() / 2, (title.size + text.size + subtitle.size) * 2 }, Color(0, 0, 0)); button_m.draw(); clickable::Button::drawEffect(); Cir::drawEffect(); }
void ShadingResult::composite_over_linear_rgb(const ShadingResult& background) { // // Shading results use premultiplied alpha. // // References and interesting resources on alpha compositing: // // http://keithp.com/~keithp/porterduff/p253-porter.pdf // http://en.wikipedia.org/wiki/Alpha_compositing // http://dvd-hq.info/alpha_matting.php // http://my.opera.com/emoller/blog/2012/08/28/alpha-blending // assert(m_color_space == ColorSpaceLinearRGB); assert(background.m_color_space == ColorSpaceLinearRGB); const Alpha contrib = Alpha(1.0f) - m_main.m_alpha; m_main.m_color[0] += contrib[0] * background.m_main.m_color[0]; m_main.m_color[1] += contrib[0] * background.m_main.m_color[1]; m_main.m_color[2] += contrib[0] * background.m_main.m_color[2]; m_main.m_alpha += contrib * background.m_main.m_alpha; const size_t aov_count = m_aovs.size(); for (size_t i = 0; i < aov_count; ++i) { const ShadingFragment& background_aov = background.m_aovs[i]; ShadingFragment& aov = m_aovs[i]; const Alpha contrib = Alpha(1.0f) - aov.m_alpha; aov.m_color[0] += contrib[0] * background_aov.m_color[0]; aov.m_color[1] += contrib[0] * background_aov.m_color[1]; aov.m_color[2] += contrib[0] * background_aov.m_color[2]; aov.m_alpha += contrib * background_aov.m_alpha; } }
LKColor LKColor::ChangeBrightness(double fBrightFact) const { #ifdef GREYSCALE int Luminosity = GetLuminosity()*fBrightFact; if (Luminosity > 255) Luminosity = 255; return Color(Luminosity, Alpha()); #else int red = (int) (fBrightFact * (double) Red()); if (red > 255) red = 255; int blue = (int) (fBrightFact * (double) Blue()); if (blue > 255) blue = 255; int green = (int) (fBrightFact * (double) Green()); if (green > 255) green = 255; return LKColor((uint8_t) red, (uint8_t) green, (uint8_t) blue); #endif }
void Alpha(CStringArray& aszS) { int i=0; while(i<aszS.GetSize()) { CString tempS; Alpha(aszS[i],tempS); if(tempS.IsEmpty()) aszS.RemoveAt(i); else { aszS.SetAt(i,tempS); i++; } } }
int main(int argc, char* argv[ ]) { double v, w, x, y, z; double timer = omp_get_wtime(); int thread_count = 1; if (argc>1) thread_count = strtol(argv[1], NULL, 10); # pragma omp parallel num_threads(thread_count) { # pragma omp sections { # pragma omp section { v = Alpha( ); printf("v = %lf\n", v); } # pragma omp section { w = Beta( ); printf("w = %lf\n", w); } } # pragma omp sections { # pragma omp section { x = Gamma(v, w); printf("x = %lf\n", x); } # pragma omp section { y = Delta( ); printf("y = %lf\n", y); } } } z = Epsilon(x, y); printf("z = %lf\n", z); timer = omp_get_wtime() - timer; printf("timer = %lf\n", timer); return 0; }
void cUIControlAnim::Update() { cUIDragable::Update(); if ( NULL != mMoveAnim && mMoveAnim->Enabled() ) { mMoveAnim->Update( Elapsed() ); Pos( (eeInt)mMoveAnim->GetPos().x, (eeInt)mMoveAnim->GetPos().y ); if ( mMoveAnim->Ended() ) eeSAFE_DELETE( mMoveAnim ); } if ( NULL != mAlphaAnim && mAlphaAnim->Enabled() ) { mAlphaAnim->Update( Elapsed() ); Alpha( mAlphaAnim->GetRealPos() ); if ( mAlphaAnim->Ended() ) { if ( ( mControlFlags & UI_CTRL_FLAG_CLOSE_FO ) ) Close(); if ( ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ) ) { mControlFlags &= ~UI_CTRL_FLAG_DISABLE_FADE_OUT; Visible( false ); } eeSAFE_DELETE( mAlphaAnim ); } } if ( NULL != mScaleAnim && mScaleAnim->Enabled() ) { mScaleAnim->Update( Elapsed() ); Scale( mScaleAnim->GetPos() ); if ( mScaleAnim->Ended() ) eeSAFE_DELETE( mScaleAnim ); } if ( NULL != mAngleAnim && mAngleAnim->Enabled() ) { mAngleAnim->Update( Elapsed() ); Angle( mAngleAnim->GetRealPos() ); if ( mAngleAnim->Ended() ) eeSAFE_DELETE( mAngleAnim ); } }
/** @brief alpha test */ TEST_F(TestCaseInfExact, AlphaTest) { // Expected value Vector Alpha(5); Alpha << 0.445390157193336f, -0.225664997833041f, -0.233476969822487f, 9.969938572168159f, -9.583958155557667f; // Actual value // pAlpha1, pAlpha2 // Test TEST_MACRO::COMPARE(*pAlpha1, *pAlpha2, __FILE__, __LINE__); TEST_MACRO::COMPARE(Alpha, *pAlpha1, __FILE__, __LINE__, EPS_SOLVER); // maxAbsDiff = 1.411e-4 TEST_MACRO::COMPARE(Alpha, *pAlpha2, __FILE__, __LINE__, EPS_SOLVER); // maxAbsDiff = 1.449e-4 }
void Graphics3DExtrude::drawQuad(const Pnt2f& p1, const Pnt2f& p2, const Pnt2f& p3, const Pnt2f& p4, const Vec2f& t1, const Vec2f& t2, const Vec2f& t3, const Vec2f& t4, const MaterialUnrecPtr Material, const Real32& Opacity) const { Real32 Alpha( Opacity * getOpacity()); if(Alpha < 1.0 || Material->isTransparent()) { //Setup the Blending equations properly glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); } StateUnrecPtr state = NULL; if(Material != NULL) { state = Material->finalize(MaterialMapKey(),getDrawEnv()->getWindow())->getState(); state->activate(getDrawEnv()); } glBegin(GL_QUADS); glColor4f(1.0, 1.0, 1.0, Alpha ); glTexCoord2fv(t1.getValues()); glVertex2fv(p1.getValues()); glTexCoord2fv(t2.getValues()); glVertex2fv(p2.getValues()); glTexCoord2fv(t3.getValues()); glVertex2fv(p3.getValues()); glTexCoord2fv(t4.getValues()); glVertex2fv(p4.getValues()); glEnd(); if(state != NULL) { state->deactivate(getDrawEnv()); } if(Alpha < 1.0 || Material->isTransparent()) { glDisable(GL_BLEND); } }