Tabnine Logo
PApplet.constrain
Code IndexAdd Tabnine to your IDE (free)

How to use
constrain
method
in
processing.core.PApplet

Best Java code snippets using processing.core.PApplet.constrain (Showing top 20 results out of 315)

origin: poqudrof/PapARt

public int worldToPixel(float x, float y, float z) {
  // Reprojection 
  float invZ = 1.0f / z;
  int px = PApplet.constrain(PApplet.round((x * invZ * fx) + cx), 0, w - 1);
  int py = PApplet.constrain(PApplet.round((y * invZ * fy) + cy), 0, h - 1);
  return (int) (py * w + px);
}
origin: poqudrof/PapARt

public int worldToPixel(PVector pt) {
  // Reprojection 
  float invZ = 1.0f / pt.z;
  int px = PApplet.constrain(PApplet.round((pt.x * invZ * fx) + cx), 0, w - 1);
  int py = PApplet.constrain(PApplet.round((pt.y * invZ * fy) + cy), 0, h - 1);
  return (int) (py * w + px);
}
origin: mirador/mirador

private void initHeight() {
 float h = (height * height) / handler.totalSize();
 sliderh = PApplet.constrain(h, minHandleHeight, height/2);
}
origin: mirador/mirador

private void initWidth() {
 float w = (width * width) / handler.totalSize();
 sliderw = PApplet.constrain(w, minSliderWidth, width/2);
}
origin: mirador/mirador

public int getFirstItemIndex() {
 int i0 = PApplet.constrain((int)(visX0.getTarget() / itemWidth), 0, getCount() - 1);
 return i0;
}
origin: poqudrof/PapARt

public PVector worldToPixel(PVector pt, boolean undistort) {
  // Reprojection 
  float invZ = 1.0f / pt.z;
  int px = PApplet.constrain(PApplet.round((pt.x * invZ * fx) + cx), 0, w - 1);
  int py = PApplet.constrain(PApplet.round((pt.y * invZ * fy) + cy), 0, h - 1);
  if (undistort && this.handleDistorsion) {
    double[] out = device.distort(px, py);
    return new PVector((float) out[0], (float) out[1]);
  } else {
    return new PVector(px, py);
  }
}
origin: mirador/mirador

String getColLabel() {
 if (view != null && (viewTask == null || viewTask.isDone())) {
  float x0 = x.get() - visX0.get() + padding;
  float y0 = y.get() + padding;
  float w0 = w - 2 * padding;
  float h0 = h.get() - 2 * padding;
  
  double valx = PApplet.constrain((mouseX - x0) / w0, 0, 1);
  double valy = PApplet.constrain((mouseY - y0) / h0, 0, 1);
  
  return view.getLabelX(valx, valy);
 }
 return "";  
}

origin: mirador/mirador

String getRowLabel() {
 if (view != null && (viewTask == null || viewTask.isDone())) {
  float x0 = x.get() - visX0.get() + padding;
  float y0 = y.get() + padding;
  float w0 = w - 2 * padding;
  float h0 = h.get() - 2 * padding;
  
  double valx = PApplet.constrain((mouseX - x0) / w0, 0, 1);
  double valy = PApplet.constrain((mouseY - y0) / h0, 0, 1);
  
  return view.getLabelY(valx, valy);  
 }
 return "";
}   

origin: poqudrof/PapARt

public PVector worldToPixelCoord(Vec3D pt) {
  // Reprojection 
  float invZ = 1.0f / pt.z();
  int px = PApplet.constrain(PApplet.round((pt.x() * invZ * fx) + cx), 0, w - 1);
  int py = PApplet.constrain(PApplet.round((pt.y() * invZ * fy) + cy), 0, h - 1);
  return new PVector(px, py);
}
origin: mirador/mirador

void mouseDragged() {
 if (focused) {
  dragging = true;        
  float value = 0;
  if (side == LEFT) {
   value = PApplet.constrain(mouseX + dx0, 0, rightHandle.x0.get()); 
  } else if (side == RIGHT) {
   value = PApplet.constrain(mouseX + dx0, leftHandle.x0.get(), width);
  }
  value = PApplet.map(value, 0, width, 0, 1);        
  if (side == LEFT) {    
   intf.invoke(NumericalRangeSelector.class, "setLeftValue", selVar, value, true);
  } else if (side == RIGHT) {
   intf.invoke(NumericalRangeSelector.class, "setRightValue", selVar, value, true);
  }
  resort = false;        
  requestedRangeUpdate = true;
 }
}

origin: mirador/mirador

public float drag(float newp, float maxd) {
 float x1 = PApplet.constrain(newp, 0, maxd);
 int tot = colLabels.getTotItemsCount() - 1;
 int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot));
 mira.browser.openColumn(idx);
 return x1;
}
public void stopDrag() {
origin: mirador/mirador

public float press(float pos, float maxd) {
 float x1 = PApplet.constrain(pos, 0, maxd);
 int tot = rowBrowser.getChildrenCount() - 1;
 int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot));
 goTo(idx);
 return x1;
}
public int pressSlider(float pos, float size) {
origin: mirador/mirador

public float press(float pos, float maxd) {
 float x1 = PApplet.constrain(pos, 0, maxd);
 int tot = colLabels.getTotItemsCount() - 1;
 int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot));
 mira.browser.openColumn(idx);
 return x1;
}
public int pressSlider(float pos, float size) {
origin: mirador/mirador

public float drag(float newp, float maxd) {
 float x1 = PApplet.constrain(newp, 0, maxd);
 int tot = rowBrowser.getChildrenCount() - 1;
 int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot));
 goTo(idx);
 return x1;
}
public void stopDrag() {
origin: mirador/mirador

public float drag(float newp, float maxd) {
 float y1 = PApplet.constrain(newp, 0, maxd);
 int tot = rowBrowser.getTotItemsCount() - 1;
 int n = PApplet.round(PApplet.map(y1, 0, maxd, 0, tot));
 RowScroller scroller = rowBrowser.getScroller();
 scroller.jumpTo(n);
 return y1;
}
public void stopDrag() {
origin: mirador/mirador

public float press(float pos, float maxd) {
 float y1 = PApplet.constrain(pos, 0, maxd);
 int tot = rowBrowser.getTotItemsCount() - 1;
 int n = PApplet.round(PApplet.map(y1, 0, maxd, 0, tot - 1));
 RowScroller scroller = rowBrowser.getScroller();
 scroller.jumpTo(n);
 return y1;
}
public int pressSlider(float pos, float size) {
origin: mirador/mirador

public void snap() {
 if (getCount() == 0) return;
 
 float x0 = visX0.getTarget();
 float x1 = visX1.getTarget();
 int i0 = PApplet.constrain(PApplet.round(x0 / itemWidth), 0, getCount() - 1);  
 int i1 = PApplet.constrain(PApplet.round(x1 / itemWidth), 0, getCount() - 1);    
 if (PApplet.abs(i0 * itemWidth - x0) < SNAP_THRESHOLD) {
  visX0.setTarget(i0 * itemWidth);
 } else if (PApplet.abs(i1 * itemWidth - x1) < SNAP_THRESHOLD) {
  visX1.setTarget(i1 * itemWidth);
 }
} 

origin: mirador/mirador

protected void resetValuesImpl(Variable var) {
 if (selVar != var) return;
 leftValue = 0;
 rightValue = 1;
 
 rangeBar.leftStr.set(selVar.formatValue(leftValue));    
 double sp = selVar.discrete() ? (leftValue < 1 ? 0.5d : 1d) / selVar.getCount() : 0;
 float svalue = PApplet.constrain((float)(leftValue - sp), 0, 1);    
 rangeBar.targetLeft(svalue);    
 leftHandle.target(svalue);
 
 rangeBar.rightStr.set(selVar.formatValue(rightValue));    
 sp = selVar.discrete() ? (0 < rightValue ? 0.5d : 1d) / selVar.getCount() : 0;
 svalue = PApplet.constrain((float)(rightValue + sp), 0, 1);
 rangeBar.targetRight(svalue);
 rightHandle.target(svalue);    
}

origin: mirador/mirador

protected void targetRightValueImpl(Variable var, Float value, Boolean normalized) {    
 if (selVar != var) return;
 rightValue = normalized ? value : selVar.normalize(value);
 rangeBar.rightStr.set(selVar.formatValue(rightValue));    
 double sp = selVar.discrete() ? (0 < rightValue ? 0.5d : 1d) / selVar.getCount() : 0;
 float svalue = PApplet.constrain((float)(rightValue + sp), 0, 1);
 rangeBar.targetRight(svalue);
 rightHandle.target(svalue);
}

origin: mirador/mirador

protected void targetLeftValueImpl(Variable var, Float value, Boolean normalized) {
 if (selVar != var) return;
 leftValue = normalized ? value : selVar.normalize(value);  
 rangeBar.leftStr.set(selVar.formatValue(leftValue));    
 double sp = selVar.discrete() ? (leftValue < 1 ? 0.5d : 1d) / selVar.getCount() : 0;
 float svalue = PApplet.constrain((float)(leftValue - sp), 0, 1);    
 rangeBar.targetLeft(svalue);    
 leftHandle.target(svalue);  
}

processing.corePAppletconstrain

Javadoc

( begin auto-generated from constrain.xml ) Constrains a value to not exceed a maximum and minimum value. ( end auto-generated )

Popular methods of PApplet

  • createGraphics
    Create an offscreen graphics surface for drawing, in this case for a renderer that writes to a file
  • loadStrings
    ( begin auto-generated from loadStrings.xml ) Reads the contents of a file or url and creates a Stri
  • saveStrings
    ( begin auto-generated from saveStrings.xml ) Writes an array of strings to a file, one line per str
  • abs
  • createImage
    ( begin auto-generated from createImage.xml ) Creates a new PImage (the datatype for storing images)
  • createShape
  • createWriter
    ( begin auto-generated from createWriter.xml ) Creates a new file in the sketch folder, and a PrintW
  • loadImage
  • main
    main() method for running this class from the command line. Usage: PApplet [options] [s
  • max
  • parseInt
  • random
    ( begin auto-generated from random.xml ) Generates random numbers. Each time the random() function
  • parseInt,
  • random,
  • round,
  • split,
  • sqrt,
  • unhex,
  • arrayCopy,
  • ceil,
  • checkExtension

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • setScale (BigDecimal)
  • findViewById (Activity)
  • Menu (java.awt)
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now