void pix_puzzle :: shuffle() { int i, a, b, c; if (!blockpos) return; if (blocknum == 1){ blockpos[0]=0; return; /* nothing to be done for us here */ } for(i=0; i<20*blockw; i++) { /* the number of shuffling times is a rule of thumb. */ a = fastrand()%(blocknum-1); b = fastrand()%(blocknum-1); if(a == b) b = (b+1)%(blocknum-1); c = blockpos[a]; blockpos[a] = blockpos[b]; blockpos[b] = c; } setPixModified(); }
///////////////////////////////////////////////////////// // moveMess // ///////////////////////////////////////////////////////// void pix_puzzle :: moveMess(int direction) { if (!blockpos)return; if (direction==5)m_game=!m_game; if (!m_game)return; int nextpos, tmp; int x = spacepos % blockw; int y = spacepos / blockw; switch (direction) { case 8: // up y--; break; case 2: // down y++; break; case 4: // left x++; break; case 6: // right x--; default: break; } if (x<0)x=0; if (x>=blockw)x=blockw-1; if (y<0)y=0; if (y>=blockh)y=blockh-1; nextpos=y*blockw + x; tmp = blockpos[spacepos]; blockpos[spacepos] = blockpos[nextpos]; blockpos[nextpos] = tmp; spacepos = nextpos; setPixModified(); }
//////////////////////////////////// // Set Message // /////////////////////////////////// void pix_histo :: setMess(int argc, t_atom *argv) { t_atom *ap=argv; int n=argc; if (!(argc==1 || argc==3 || argc==4)) { error("only 1, 3 or 4 arguments are allowed"); m_mode=0; return; } while(n--) { if (ap->a_type != A_SYMBOL) { error("only symbolic table-names are accepted"); return; } ap++; } m_mode=3; ap=argv; switch (argc) { case 1: name_R=name_G=name_B=name_A=atom_getsymbol(ap); m_mode=1; break; /* coverity[unterminated_case] */ case 4: name_A=atom_getsymbol(ap+3); m_mode=4; default: name_R=atom_getsymbol(ap); name_G=atom_getsymbol(ap+1); name_B=atom_getsymbol(ap+2); } setPixModified(); }
///////////////////////////////////////////////////////// // saturated math // ///////////////////////////////////////////////////////// void pix_offset :: saturateMess(int sat) { m_saturate=(sat!=0); setPixModified(); }
///////////////////////////////////////////////////////// // flipMess // ///////////////////////////////////////////////////////// void pix_flip :: flipMess(FlipType type) { m_flip = type; setPixModified(); }
///////////////////////////////////////////////////////// // otheralphaMess // ///////////////////////////////////////////////////////// void pix_alpha :: otheralphaMess(float alpha) { m_otheralpha = CLAMP(alpha * 255.f); setPixModified(); }
void pix_crop :: offYMess(int y) { offsetY=y; setPixModified(); }
void pix_crop :: offXMess(int x) { offsetX=x; setPixModified(); }
void pix_crop :: offsetMess(int x, int y){ offsetX=x; offsetY=y; setPixModified(); }
void pix_crop :: dimYMess(int y){ if(y<0)y=0; wantSizeY=y; setPixModified(); }
void pix_crop :: dimXMess(int x){ if(x<0)x=0; wantSizeX=x; setPixModified(); }
void pix_posterize :: limitMess(int l) { limit = l; setPixModified(); }
void pix_posterize :: factorMess(float f) { factor = static_cast<int>(f*255.f); setPixModified(); }