int valueForPiecesPosition(BitMap * piecesPosition, int pieceType, int pieceColor, int phase){ if ( piecesPosition == NULL ) { logChess(FATAL, "The position is null."); return ERROR_NULL_POSITION; } int retValue=0; int piecesPositionFound [8]; int result=getPiecePosition(piecesPosition, pieceType, piecesPositionFound); if(result ==SUCCESS)//if not return SUCCESS the table is empty { int i; for(i=0; i < 8; i++) { if(piecesPositionFound[i] == -1 || piecesPositionFound[i] == -9) break;//exit from the loop if there's not more piece of these type int position=getRelativePosition(piecesPositionFound[i],pieceColor); retValue+=getValueForPosition(position,pieceType, phase);//here we sum every value of position for every piece } } return retValue; }
void CtrlrXYSurface::modulatorMoved() { const Point<int> c = surfaceModulator->getBounds().getCentre(); if (destinationX) { destinationX->getProcessor().setValueFromGUI (getValueForPosition(c.getX(), true)); } if (destinationY) { destinationY->getProcessor().setValueFromGUI (getValueForPosition(c.getY(), false)); } repaint(); }
void ofxBKDoubleSlider::mouseDragged(ofMouseEventArgs &e) { float targetVal = getValueForPosition(getMousePosition().x)-mouseDragOffset; if(currentDraggingValue == 1) setValue(targetVal); else if(currentDraggingValue == 2) setValue2(targetVal); }
void ofxBKDoubleSlider::mousePressed(ofMouseEventArgs &e) { currentDraggingValue = getNearestValueIndex(getValueForPosition(getMousePosition().x)); mouseDragOffset = getValueForPosition(getMousePosition().x) - (currentDraggingValue == 1?value:value2); ofHideCursor(); #ifdef _WIN32 LPPOINT pt = LPPOINT(); int x = ofGetWindowPositionX()+getGlobalBounds().x + (currentDraggingValue == 1?value:value2)*width; int y = ofGetWindowPositionY()+getGlobalBounds().y+getMousePosition().y; SetCursorPos(x,y); mouseDragOffset = 0; #endif isDragging = true; }
//============================================================================== void CtrlrXYSurface::paint (Graphics& g) { //[UserPrePaint] Add your own custom painting code here.. //[/UserPrePaint] //[UserPaint] Add your own custom painting code here.. gradientFromProperty (g, usableRectangle.getSmallestIntegerContainer(), getObjectTree(), Ids::uiXYSurfaceBgGradientType, Ids::uiXYSurfaceBackgroundColour1, Ids::uiXYSurfaceBackgroundColour2); g.fillRoundedRectangle ((float)usableRectangle.getTopLeft().getX(), (float)usableRectangle.getTopLeft().getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight(), getProperty(Ids::uiXYSurfaceCornerSize)); gradientFromProperty (g, usableRectangle.getSmallestIntegerContainer(), getObjectTree(), Ids::uiXYSurfaceOutlineGradientType, Ids::uiXYSurfaceOutlineColour1, Ids::uiXYSurfaceOutlineColour2); g.drawRoundedRectangle ((float)usableRectangle.getX(), (float)usableRectangle.getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight(), getProperty(Ids::uiXYSurfaceCornerSize), getProperty(Ids::uiXYSurfaceOutlineThickness)); const int snapSize = (int)getProperty (Ids::uiXYSurfaceGradientGrain, 8); Colour colour = VAR2COLOUR(getProperty(Ids::uiXYSurfaceGradientColour)); if (snapSize > 0) { Image backgroundFill(Image::ARGB, snapSize, snapSize, true); Graphics g1(backgroundFill); if (snapSize > 2) { g1.setColour (colour); g1.drawRect (0, 0, snapSize + 1, snapSize + 1); } g.setTiledImageFill (backgroundFill, 0, 0, 1.0f); g.fillRoundedRectangle ((float)usableRectangle.getX(), (float)usableRectangle.getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight(), getProperty(Ids::uiXYSurfaceCornerSize)); } if (backgroundImage.isValid()) { if ((int)getProperty (Ids::uiXYSurfaceBgImageLayout) == 8192) { g.setTiledImageFill (backgroundImage, 0, 0, (float)getProperty (Ids::uiXYSurfaceBgImageAlpha)/255.0f); g.fillRect ((float)usableRectangle.getX(), (float)usableRectangle.getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight()); } else { g.setColour (Colours::black.withAlpha ((float)getProperty (Ids::uiXYSurfaceBgImageAlpha)/255.0f)); g.drawImageWithin (backgroundImage, usableRectangle.getX(), usableRectangle.getX(), usableRectangle.getWidth(), usableRectangle.getHeight(), RectanglePlacement(getProperty (Ids::uiXYSurfaceBgImageLayout))); } } if (getProperty (Ids::uiXYSurfaceXTrackEnabled)) { const Point<int> c = surfaceModulator->getBounds().getCentre(); g.setColour (VAR2COLOUR(getProperty(Ids::uiXYSurfaceYTrackColour))); g.drawLine ((float)c.getX(), (float)usableRectangle.getY(), (float)c.getX(), (float)usableRectangle.getBottom(), getProperty(Ids::uiXYSurfaceYTrackThickness)); g.setColour (VAR2COLOUR(getProperty(Ids::uiXYSurfaceXTrackColour))); g.drawLine ((float)usableRectangle.getX(), (float)c.getY(), (float)usableRectangle.getWidth(), (float)c.getY(), getProperty(Ids::uiXYSurfaceXTrackThickness)); } if ((bool)getProperty(Ids::uiXYSurfaceInfoLabelVisible)) { // const int xScale = (int)getProperty(Ids::uiXYSurfaceMaxX); // const int yScale = (int)getProperty(Ids::uiXYSurfaceMaxY); const Point<int> c = surfaceModulator->getBounds().getCentre(); g.setColour (VAR2COLOUR(getProperty (Ids::uiXYSurfaceInfoLabelColour))); g.setFont (STR2FONT(getProperty(Ids::uiXYSurfaceInfoLabelFont))); g.drawText ("X="+String(getValueForPosition(c.getX(), true))+" Y="+String(getValueForPosition(c.getY(), false)), usableRectangle.getX() + 8, usableRectangle.getY() + 8, usableRectangle.getWidth()-16, usableRectangle.getHeight()-16, justificationFromProperty(getProperty (Ids::uiXYSurfaceInfoLabelLocation)), true); } //[/UserPaint] }