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

How to use
round
method
in
processing.core.PApplet

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

origin: mirador/mirador

final protected void updateMouse(int mx, int my, int pmx, int pmy) {
 mouseX = PApplet.round(mx - left);
 mouseY = PApplet.round(my - top);    
 pmouseX = PApplet.round(pmx - left);
 pmouseY = PApplet.round(pmy - top);
}

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: ajavamind/Processing-Cardboard

long delay = PApplet.round((lastTime + avgTimePerFrame - now) / 1e6f);
try {
 if (delay > 0) Thread.sleep(delay);
origin: ajavamind/Processing-Cardboard

/**
 * Create a bitmap font on the fly from either a font name that's
 * installed on the system, or from a .ttf or .otf that's inside
 * the data folder of this sketch.
 * <p/>
 * Use 'null' for the charset if you want to dynamically create
 * character bitmaps only as they're needed.
 */
public PFont createFont(String name, float size,
            boolean smooth, char[] charset) {
  String lowerName = name.toLowerCase();
  Typeface baseFont = null;
  if (lowerName.endsWith(".otf") || lowerName.endsWith(".ttf")) {
    AssetManager assets = activity.getAssets();
    baseFont = Typeface.createFromAsset(assets, name);
  } else {
    baseFont = (Typeface) PFont.findNative(name);
  }
  return new PFont(baseFont, round(size), smooth, charset);
}
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: poqudrof/PapARt

/**
 * Handle distorsions
 *
 * @param pt
 * @return
 */
public PVector worldToPixelCoord(PVector pt, boolean undist) {
  // 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 (this.handleDistorsion && undist) {
    double[] out = device.undistort(px, py);
    px = (int) (out[0]);
    py = (int) (out[1]);
  }
  return new PVector(px, py);
}
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

public int getAlpha(int max) {
 if (parent != null && inner) {
  // Constraining by the opacity of the parent in case this is an "inner"
  // widget.
  max = PApplet.min(max, parent.getAlpha(255));
 }
 return PApplet.round(opacity.get() * max);
}  

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 BoxplotSelection getPercentileSelection(float x0, float x1, 
                         float v0, float v1, float p, 
                         double valx, double valy,
                         int counts, boolean shift) {
 float y0 = 1 - v1;
 float dy =  v1 - v0;          
 float y1 = y0 + dy;
 if (x0 <= valx && valx <= x1 && y0 <= valy && valy <= y1) {
  BoxplotSelection sel = new BoxplotSelection(x0, y0, x1 - x0, dy);
  sel.setColor(mixColors(WHITE, COLOR, 0.5f));
  if (shift) {
   sel.setLabel(PApplet.round(p * counts) + "/" + counts);
  } else {
   sel.setLabel(PApplet.nfc(100 * p, 2) + "%");
  }
  return sel; 
 }
 
 return null;
}

origin: mirador/mirador

public Selection getSelection(double valx, double valy, boolean shift) {
 if (canDraw()) {
  float binw = 1.0f / binCount;          
  for (int bx = 0; bx < binCount; bx++) {        
   float p = density[bx];
   float h = PApplet.map(p, 0, maxProb, 0, 0.5f);
   float x0 = binw * bx;
   float x1 = binw * bx + binw;
   if (x0 < valx && valx < x1) {
    Selection sel = new Selection(x0, (1 - h), binw, h);
    if (shift) {
     sel.setLabel(PApplet.round(sampleSize * p) + "/" + sampleSize);
    } else {
     sel.setLabel(PApplet.nfc(100 * p, 2) + "%");  
    }
    
    return sel;
   }        
  }
 } else {
  return getUnavailableSelection();
 }
 return null;
}
origin: mirador/mirador

public Selection getSelection(double valx, double valy, boolean shift) {
 if (canDraw()) {
  float binw = 1.0f / binCountX;
  float binh = 1.0f / binCountY;
  for (int bx = 0; bx < binCountX; bx++) {
   for (int by = 0; by < binCountY; by++) {
    float x0 = binw * bx;
    float y0 = 1 - binh * by - binh;
    float x1 = x0 + binw; 
    float y1 = y0 + binh;
    if (x0 <= valx && valx <= x1 && y0 <= valy && valy <= y1) {
     Selection sel = new Selection(x0, y0, binw, binh);
     float p = density[bx][by];
     float np = PApplet.map(p, 0, maxProb, 0, 1);
     sel.setColor(mixColors(WHITE, COLOR, np));
     if (shift) {
      sel.setLabel(PApplet.round(sampleSize * p) + "/" + sampleSize);
     } else {
      sel.setLabel(PApplet.nfc(100 * p, 2) + "%");
     }
     return sel;
    }
   }
  }
 } else {
  return getUnavailableSelection();
 }
 return null;
}
origin: mirador/mirador

if (shift) {            
 float count = (density[bx][by] / dx) * sampleCounts[bx];
 sel.setLabel(PApplet.round(count) + "/" + sampleCounts[bx]);           
} else {
processing.corePAppletround

Javadoc

( begin auto-generated from round.xml ) Calculates the integer closest to the value parameter. For example, round(9.2) returns the value 9. ( end auto-generated )

Popular methods of PApplet

  • constrain
  • 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
  • max,
  • parseInt,
  • random,
  • split,
  • sqrt,
  • unhex,
  • arrayCopy,
  • ceil,
  • checkExtension

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • BoxLayout (javax.swing)
  • Join (org.hibernate.mapping)
  • Top plugins for WebStorm
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