void Gizmo::transform(ComponentIndex camera, int x, int y, int relx, int rely, bool use_step) { if (!m_is_transforming) return; if (m_mode == Mode::ROTATE) { rotate(relx, rely, use_step); } else { Vec3 intersection = getMousePlaneIntersection(camera, x, y); Vec3 delta = intersection - m_transform_point; if (!use_step || delta.length() > float(getStep())) { if (use_step) delta = delta.normalized() * float(getStep()); Array<Vec3> new_positions(m_editor.getAllocator()); for (int i = 0, ci = m_editor.getSelectedEntities().size(); i < ci; ++i) { Vec3 pos = m_editor.getUniverse()->getPosition(m_editor.getSelectedEntities()[i]); pos += delta; new_positions.push(pos); } m_editor.setEntitiesPositions(&m_editor.getSelectedEntities()[0], &new_positions[0], new_positions.size()); if (m_is_autosnap_down) m_editor.snapDown(); m_transform_point = intersection; } } }
template<> inline void CounterImpl<UInt32CounterDesc>::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { if((IncTriggerFieldMask | DecTriggerFieldMask) != (whichField & (IncTriggerFieldMask | DecTriggerFieldMask))) { if(0x0000 != (whichField & IncTriggerFieldMask)) { setValue(getValue() + getStep()); } if(0x0000 != (whichField & DecTriggerFieldMask)) { if(getStep() <= getValue()) { setValue(getValue() - getStep()); } else { setValue(TypeTraits<ValueType>::getZeroElement()); } } } Inherited::changed(whichField, origin, details); }
void ActionWithAveraging::update() { if( (clearstride!=1 && getStep()==0) || !onStep() ) return; // Clear if it is time to reset if( myaverage ) { if( myaverage->wasreset() ) clearAverage(); } // Calculate the weight for all reweighting if ( weights.size()>0 ) { double sum=0; for(unsigned i=0; i<weights.size(); ++i) sum+=weights[i]->get(); lweight=sum; cweight = exp( sum ); } else { lweight=0; cweight=1.0; } // Prepare to do the averaging prepareForAveraging(); // Run all the tasks (if required if( useRunAllTasks ) runAllTasks(); // This the averaging if it is not done using task list else performOperations( true ); // Update the norm if( myaverage ) myaverage->setNorm( cweight + myaverage->getNorm() ); // Finish the averaging finishAveraging(); // By resetting here we are ensuring that the grid will be cleared at the start of the next step if( myaverage ) { if( getStride()==0 || (clearstride>0 && getStep()%clearstride==0) ) myaverage->reset(); } }
bool SymbolicList::checkAsIndex(const GVN::Value * dim) { if (symbolic) { if (getStep()->poly->constant > 0 && getStep()->poly->isCoeffPositive(false)) { // step is positive } else if (getStep()->poly->constant < 0 && getStep()->poly->isCoeffNegative(false)) { // step is negative } else { } } else { } return true; }
std::ostream& Sequence::getCout( std::ostream& os ) const { bfs::path dir; if( showAbsolutePath() ) { dir = bfs::absolute( _directory ); dir = boost::regex_replace( dir.string(), boost::regex( "/\\./" ), "/" ); } os << std::left; if( showProperties() ) { os << std::setw( PROPERTIES_WIDTH ) << "s "; } if( showRelativePath() ) { dir = _directory; dir = boost::regex_replace( dir.string(), boost::regex( "/\\./" ), "/" ); os << std::setw( NAME_WIDTH_WITH_DIR ) << _kColorSequence + ( dir / getStandardPattern() ).string() + _kColorStd; } else { os << std::setw( NAME_WIDTH ) << _kColorSequence + ( dir / getStandardPattern() ).string() + _kColorStd; } os << " [" << getFirstTime() << ":" << getLastTime(); if( getStep() != 1 ) os << "x" << getStep(); os << "] " << getNbFiles() << " file" << ( ( getNbFiles() > 1 ) ? "s" : "" ); if( hasMissingFile() ) { os << ", " << _kColorError << getNbMissingFiles() << " missing file" << ( ( getNbMissingFiles() > 1 ) ? "s" : "" ) << _kColorStd; } return os; }
TC_Position GetPassBallPositon(TC_Handle hHero) { int flag=0; TC_Position target; target.x=-1; target.y=-1; TC_Position hero; if(hHero==hHero_1) hero=iHero_1.pos; else hero=iHero_2.pos; int a=512; int step1=9; int step2=9; int dis1; int dis2; if(iAttackDirection==TC_DIRECTION_RIGHT) { dis1=iEnemy_1.pos.x-hero.x-abs(iEnemy_1.pos.y-hero.y); dis2=iEnemy_2.pos.x-hero.x-abs(iEnemy_2.pos.y-hero.y); step1=getStep(dis1); step2=getStep(dis2); } else { dis1=hero.x-iEnemy_1.pos.x-abs(iEnemy_1.pos.y-hero.y); dis2=hero.x-iEnemy_2.pos.x-abs(iEnemy_2.pos.y-hero.y); step1=getStep(dis1); step2=getStep(dis2); a=-512; } int ddis1=abs(iEnemy_1.pos.x-hero.x)+abs(iEnemy_1.pos.y-hero.y); int ddis2=abs(iEnemy_2.pos.x-hero.x)+abs(iEnemy_2.pos.y-hero.y); bool resultJu2=(iEnemy_2.steps_before_next_snatch>step2||iEnemy_2.abnormal_type==TC_SPELLED_BY_MALFOY||iEnemy_2.abnormal_type==TC_SPELLED_BY_FREEBALL||step2<=0); bool resultJu1=(iEnemy_1.steps_before_next_snatch>step1||iEnemy_1.abnormal_type==TC_SPELLED_BY_MALFOY||iEnemy_1.abnormal_type==TC_SPELLED_BY_FREEBALL||step1<=0); if((resultJu1&&resultJu2)||(resultJu1&&ddis2>512)||(resultJu2&&ddis1>512)||(ddis1>512&ddis2>512)) { if(a>0) target=dealPos(iGhostBall.pos,0); else target=dealPos(iGhostBall.pos,1);//ballThroughEnemy(hero,iEnemy_1); flag=1; } if(flag==1) { if(iAttackDirection==TC_DIRECTION_RIGHT) { if(target.x>=iForbiddenArea.right.left-64) target.x=iForbiddenArea.right.left-64; } else { if(target.x<=iForbiddenArea.left.right) target.x=iForbiddenArea.left.right; } } return target; }
void DynProgProbLim::update () // updates dynamic prog probs { assert (getValueFct ()); assert (getDimInputProb ()); assert (getInputProb ()); assert (0 < getArrayCapacity ()); Int4 i = 0; size_t j = 0; const double *oldArray = 0; double *array = 0; Int4 value = 0; Int4 valueLower = 0; Int4 valueUpper = 0; size_t arrayPos = 0; double prob = 0.0; oldArray = getArray () [getStep () % 2]; array = lgetArray () [(getStep () + 1) % 2]; valueLower = kMax_I4; valueUpper = kMin_I4; MemUtil::memZero (array, sizeof (double) * getArrayCapacity ()); for (i = getValueLower (); i < getValueUpper (); i++) { if (oldArray [getArrayPos (i)] == 0.0) continue; for (j = 0; j < getDimInputProb (); j++) { if (getInputProb () [j] == 0.0) continue; value = getValueFct () (i, j); prob = oldArray [getArrayPos (i)] * getInputProb () [j]; if (value < getValueBegin () || getValueEnd () <= value) { d_probLost += prob; } else { if (value < valueLower) valueLower = value; if (valueUpper < value) valueUpper = value; // add the probability assert (getValueBegin () <= i); assert (i < getValueEnd ()); array [getArrayPos (value)] += prob; } } } lgetValueLower () = valueLower; lgetValueUpper () = valueUpper + 1; lgetStep ()++; }
void AdaptivePath::update() { double weight2 = -1.*mypathv->dx; double weight1 = 1.0 + mypathv->dx; if( weight1>1.0 ) { weight1=1.0; weight2=0.0; } else if( weight2>1.0 ) { weight1=0.0; weight2=1.0; } // Add projections to dispalcement accumulators ReferenceConfiguration* myref = getReferenceConfiguration( mypathv->iclose1 ); myref->extractDisplacementVector( getPositions(), getArguments(), mypathv->cargs, false, displacement ); getReferenceConfiguration( mypathv->iclose2 )->extractDisplacementVector( myref->getReferencePositions(), getArguments(), myref->getReferenceArguments(), false, displacement2 ); displacement.addDirection( -mypathv->dx, displacement2 ); pdisplacements[mypathv->iclose1].addDirection( weight1, displacement ); pdisplacements[mypathv->iclose2].addDirection( weight2, displacement ); // Update weight accumulators wsum[mypathv->iclose1] *= fadefact; wsum[mypathv->iclose2] *= fadefact; wsum[mypathv->iclose1] += weight1; wsum[mypathv->iclose2] += weight2; // This does the update of the path if it is time to if( (getStep()>0) && (getStep()%update_str==0) ) { wsum[fixedn[0]]=wsum[fixedn[1]]=0.; for(unsigned inode=0; inode<getNumberOfReferencePoints(); ++inode) { if( wsum[inode]>0 ) { // First displace the node by the weighted direction getReferenceConfiguration( inode )->displaceReferenceConfiguration( 1./wsum[inode], pdisplacements[inode] ); // Reset the displacement pdisplacements[inode].zeroDirection(); } } // Now ensure all the nodes of the path are equally spaced PathReparameterization myspacings( getPbc(), getArguments(), getAllReferenceConfigurations() ); myspacings.reparameterize( fixedn[0], fixedn[1], tolerance ); } if( (getStep()>0) && (getStep()%wstride==0) ) { pathfile.printf("# PATH AT STEP %d TIME %f \n", getStep(), getTime() ); std::vector<std::unique_ptr<ReferenceConfiguration>>& myconfs=getAllReferenceConfigurations(); std::vector<SetupMolInfo*> moldat=plumed.getActionSet().select<SetupMolInfo*>(); if( moldat.size()>1 ) error("you should only have one MOLINFO action in your input file"); SetupMolInfo* mymoldat=NULL; if( moldat.size()==1 ) mymoldat=moldat[0]; std::vector<std::string> argument_names( getNumberOfArguments() ); for(unsigned i=0; i<getNumberOfArguments(); ++i) argument_names[i] = getPntrToArgument(i)->getName(); PDB mypdb; mypdb.setArgumentNames( argument_names ); for(unsigned i=0; i<myconfs.size(); ++i) { pathfile.printf("REMARK TYPE=%s\n", myconfs[i]->getName().c_str() ); mypdb.setAtomPositions( myconfs[i]->getReferencePositions() ); for(unsigned j=0; j<getNumberOfArguments(); ++j) mypdb.setArgumentValue( getPntrToArgument(j)->getName(), myconfs[i]->getReferenceArgument(j) ); mypdb.print( atoms.getUnits().getLength()/0.1, mymoldat, pathfile, ofmt ); } pathfile.flush(); } }
void ContentSlider::stepDn() { int content_pos = position_ * (content_size_ - view_size_) + view_size_; int dst = content_pos + getStep(); if (dst > content_size_) { if (1 != position_) { position_ = 1; emit postionChanged(position_); update(); } } else { position_ = (double)(dst - view_size_) / (double)(content_size_ - view_size_); if (position_ < 0) position_ = 0; else if (position_ > 1) position_ = 1; emit postionChanged(position_); update(); } }
void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *data) { float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float multiplier_accum = 0.0f; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; rcti &rect = *inputBuffer->getRect(); int xmin = max_ii(x, rect.xmin); int ymin = max_ii(y - m_filtersize, rect.ymin); int ymax = min_ii(y + m_filtersize + 1, rect.ymax); int index; int step = getStep(); const int bufferIndexx = ((xmin - bufferstartx) * 4); for (int ny = ymin; ny < ymax; ny += step) { index = (ny - y) + this->m_filtersize; int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth); const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; } mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum); }
void CalendarTemplateElement::toParametersMap( util::ParametersMap& map, bool withAdditionalParameters, boost::logic::tribool withFiles /*= boost::logic::indeterminate*/, std::string prefix /*= std::string() */ ) const { map.insert(TABLE_COL_ID, getKey()); map.insert( CalendarTemplateElementTableSync::COL_CALENDAR_ID, getCalendar() ? getCalendar()->getKey() : RegistryKeyType(0) ); map.insert( CalendarTemplateElementTableSync::COL_RANK, getRank() ); map.insert( CalendarTemplateElementTableSync::COL_MIN_DATE, getMinDate().is_special() ? string() : to_iso_extended_string(getMinDate()) ); map.insert( CalendarTemplateElementTableSync::COL_MAX_DATE, getMaxDate().is_special() ? string() : to_iso_extended_string(getMaxDate()) ); map.insert( CalendarTemplateElementTableSync::COL_INTERVAL, boost::lexical_cast<std::string>(static_cast<int>(getStep().days())) ); map.insert( CalendarTemplateElementTableSync::COL_POSITIVE, static_cast<int>(getOperation()) ); map.insert( CalendarTemplateElementTableSync::COL_INCLUDE_ID, getInclude() ? getInclude()->getKey() : RegistryKeyType(0) ); }
void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, void *data) { const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; int miny = y - this->m_rad; int maxy = y + this->m_rad; int minx = x; int maxx = x; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */ int step = getStep(); /* gauss */ float alpha_accum = 0.0f; float multiplier_accum = 0.0f; /* dilate */ float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */ float distfacinv_max = 1.0f; /* 0 to 1 */ for (int ny = miny; ny < maxy; ny += step) { int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); const int index = (ny - y) + this->m_rad; float value = finv_test(buffer[bufferindex], do_invert); float multiplier; /* gauss */ { multiplier = this->m_gausstab[index]; alpha_accum += value * multiplier; multiplier_accum += multiplier; } /* dilate - find most extreme color */ if (value > value_max) { multiplier = this->m_distbuf_inv[index]; value *= multiplier; if (value > value_max) { value_max = value; distfacinv_max = multiplier; } } } /* blend between the max value and gauss blue - gives nice feather */ const float value_blur = alpha_accum / multiplier_accum; const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max)); color[0] = finv_test(value_final, do_invert); }
//________________________________________________________________________ void notevisitor::print (ostream& out) const { if (isGrace()) out << "grace "; if (isCue()) out << "cue "; int type = getType(); if (type == kUndefinedType) out << "type undefined"; else if (type == kUnpitched) { out << "unpitched note - duration " << getDuration() << " "; } else if (type == kRest) { out << "rest - duration " << getDuration() << " "; } else if (type == kPitched) { out << "note " << getStep(); int alter = int(getAlter()); float diff = getAlter() - alter; if (diff >= 0.5) alter++; else if (diff <= -0.5) alter--; while (alter < 0) { out << 'b'; alter++; } while (alter > 0) { out << '#'; alter--; } out << getOctave() << " (" << getMidiPitch() << ")"; out << " - duration " << getDuration() << " "; } else out << "unknown type " << type << " "; if (inChord()) out << "in chord "; if (getTie() & StartStop::start) out << "- tie start "; if (getTie() & StartStop::stop) out << "- tie stop "; string instr = getInstrument(); if (!instr.empty()) out << "instrument " << instr << " "; if (getDynamics() >= 0) out << "dynamics " << getDynamics(); }
bool MgCmdDrawGrid::draw(const MgMotion* sender, GiGraphics* gs) { if (getStep() == 2) { gs->drawHandle(dynshape()->getHandlePoint(8), kGiHandleVertex); } return MgCmdDrawRect::draw(sender, gs); }
void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *data) { float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float multiplier_accum = 0.0f; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; int miny = y; int minx = x - this->m_rad; int maxx = x + this->m_rad; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxx = min(maxx, inputBuffer->getRect()->xmax - 1); int step = getStep(); int offsetadd = getOffsetAdd(); int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); for (int nx = minx, index = (minx - x) + this->m_rad; nx <= maxx; nx += step, index += step) { const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; bufferindex += offsetadd; } mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum); }
void ViewLightGL::paintGL() { Vector3 pos(Vector3::Spherical(__distance,__azimuth*GEOM_RAD,(__elevation)*GEOM_RAD)); if(fabs(pos.x()) < GEOM_EPSILON && fabs(pos.y()) < GEOM_EPSILON && fabs(pos.z()) < GEOM_EPSILON){ pos = Vector3(0,0,1); } glGeomLightPosition(GL_LIGHT0,pos); Vector3 dir(pos); dir *= -1; dir.normalize(); glGeomLightDirection(GL_LIGHT0,dir); switchOn(); if(__show){ glPushMatrix(); glGeomTranslate(pos); glGeomMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, __ambient); glutSolidSphere(getStep()*0.1,8,8); glPopMatrix(); } GEOM_GL_ERROR; }
void ContentSlider::stepUp() { int content_pos = position_ * (content_size_ - view_size_); int dst = content_pos - getStep(); if (dst < 0) { if (0 != dst) { position_ = 0; emit postionChanged(position_); update(); } } else { position_ = (double)dst / (double)(content_size_ - view_size_); if (position_ < 0) position_ = 0; else if (position_ > 1) position_ = 1; emit postionChanged(position_); update(); } }
void GridPrintingBase::update(){ if( getStep()==0 || getStride()==0 ) return ; OFile ofile; ofile.link(*this); ofile.setBackupString("analysis"); ofile.open( filename ); printGrid( ofile ); ofile.close(); }
void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data) { float color_accum[4]; float tempBoundingBox[4]; float bokeh[4]; this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST); if (tempBoundingBox[0] > 0.0f) { float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; const float max_dim = max(this->getWidth(), this->getHeight()); int pixelSize = this->m_size * max_dim / 100.0f; zero_v4(color_accum); if (pixelSize < 2) { this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST); multiplier_accum[0] = 1.0f; multiplier_accum[1] = 1.0f; multiplier_accum[2] = 1.0f; multiplier_accum[3] = 1.0f; } int miny = y - pixelSize; int maxy = y + pixelSize; int minx = x - pixelSize; int maxx = x + pixelSize; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); int step = getStep(); int offsetadd = getOffsetAdd() * COM_NUM_CHANNELS_COLOR; float m = this->m_bokehDimension / pixelSize; for (int ny = miny; ny < maxy; ny += step) { int bufferindex = ((minx - bufferstartx) * COM_NUM_CHANNELS_COLOR) + ((ny - bufferstarty) * COM_NUM_CHANNELS_COLOR * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { float u = this->m_bokehMidX - (nx - x) * m; float v = this->m_bokehMidY - (ny - y) * m; this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST); madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]); add_v4_v4(multiplier_accum, bokeh); bufferindex += offsetadd; } } output[0] = color_accum[0] * (1.0f / multiplier_accum[0]); output[1] = color_accum[1] * (1.0f / multiplier_accum[1]); output[2] = color_accum[2] * (1.0f / multiplier_accum[2]); output[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } else { this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST); } }
bool Slider::handleEvent( Window* parent, SDL_Event* event, int x, int y ) { inside = isInside( x, y ); if ( inside ) parent->setLastWidget( this ); else dragging = false; // handle it switch ( event->type ) { case SDL_KEYUP: if ( hasFocus() ) { if ( event->key.keysym.sym == SDLK_LEFT ) { if ( pos ) pos -= 10 * getStep(); if ( pos < 0 ) pos = 0; return true; } else if ( event->key.keysym.sym == SDLK_RIGHT ) { if ( pos < getWidth() - BUTTON_SIZE / 2 ) pos += 10 * getStep(); if ( pos >= getWidth() - BUTTON_SIZE / 2 ) pos = getWidth() - BUTTON_SIZE / 2; return true; } } break; case SDL_MOUSEMOTION: if ( inside && dragging ) { pos = x - getX(); if ( pos >= getWidth() - BUTTON_SIZE / 2 ) pos = getWidth() - BUTTON_SIZE / 2; if ( pos < 0 ) pos = 0; return true; } break; case SDL_MOUSEBUTTONUP: if ( inside ) { dragging = false; pos = x - getX(); if ( pos >= getWidth() - BUTTON_SIZE / 2 ) pos = getWidth() - BUTTON_SIZE / 2; if ( pos < 0 ) pos = 0; return true; } case SDL_MOUSEBUTTONDOWN: if ( event->button.button != SDL_BUTTON_LEFT ) return false; if ( inside ) { dragging = true; } break; default: break; } return false; }
bool MgCmdDrawEllipse::draw(const MgMotion* sender, GiGraphics* gs) { if (getStep() > 0 && sender->dragging()) { GiContext ctxshap(0, GiColor(0, 0, 255, 128), kGiLineDash); gs->drawRect(&ctxshap, dynshape()->shape()->getExtent()); } return MgCmdDrawRect::draw(sender, gs); }
void AlaLed::fadeOut() { int s = getStep(animStartTime, speed, maxOut); for(int x=0; x<numLeds; x++) { leds[x] = abs(maxOut-s); } }
void AlaLed::blinkAlt() { int t = getStep(animStartTime, speed, 2); for(int x=0; x<numLeds; x++) { leds[x] = ((t+x)%2)*maxOut; } }
std::vector<boost::filesystem::path> Sequence::getFiles() const { std::vector<boost::filesystem::path> allPaths; for( Time t = getFirstTime(); t <= getLastTime(); t += getStep() ) { allPaths.push_back( getAbsoluteFilenameAt( t ) ); } return allPaths; }
inline const LedAnimationStep * const currentStep() const { const LedAnimationStep * const result = getStep(m_runtime.step); if (result == NULL || !thisLedStep(result)) { return &g_DefaultStep; } return result; }
void AlaLed::strobo() { int t = getStep(animStartTime, speed, ALA_STROBODC); for(int x=0; x<numLeds; x++) { leds[x] = (t==0)*maxOut; } }
void AlaLed::pixelShiftLeft() { int t = getStep(animStartTime, speed, numLeds); for(int x=0; x<numLeds; x++) { leds[x] = (x==(numLeds-1-t) ? 1:0)*maxOut; } }
void AlaLed::fadeInOut() { int s = getStep(animStartTime, speed, 2*maxOut) - maxOut; for(int x=0; x<numLeds; x++) { leds[x] = abs(maxOut-abs(s)); } }
void AlaLed::pixelBounce() { int t = getStep(animStartTime, speed, 2*numLeds-2); for(int x=0; x<numLeds; x++) { leds[x] = (x==(-abs(t-numLeds+1)+numLeds-1) ? 1:0)*maxOut; } }
void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, void *data) { const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; rcti &rect = *inputBuffer->getRect(); int xmin = max_ii(x - m_filtersize, rect.xmin); int xmax = min_ii(x + m_filtersize + 1, rect.xmax); int ymin = max_ii(y, rect.ymin); /* *** this is the main part which is different to 'GaussianXBlurOperation' *** */ int step = getStep(); int offsetadd = getOffsetAdd(); int bufferindex = ((xmin - bufferstartx) * 4) + ((ymin - bufferstarty) * 4 * bufferwidth); /* gauss */ float alpha_accum = 0.0f; float multiplier_accum = 0.0f; /* dilate */ float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */ float distfacinv_max = 1.0f; /* 0 to 1 */ for (int nx = xmin; nx < xmax; nx += step) { const int index = (nx - x) + this->m_filtersize; float value = finv_test(buffer[bufferindex], do_invert); float multiplier; /* gauss */ { multiplier = this->m_gausstab[index]; alpha_accum += value * multiplier; multiplier_accum += multiplier; } /* dilate - find most extreme color */ if (value > value_max) { multiplier = this->m_distbuf_inv[index]; value *= multiplier; if (value > value_max) { value_max = value; distfacinv_max = multiplier; } } bufferindex += offsetadd; } /* blend between the max value and gauss blue - gives nice feather */ const float value_blur = alpha_accum / multiplier_accum; const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max)); output[0] = finv_test(value_final, do_invert); }