Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9015303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:43:05+00:00 2026-06-16T03:43:05+00:00

i am using open source code from processing.js.com site,which has frame rate() method, when

  • 0

i am using open source code from processing.js.com site,which has frame rate() method,

when i change frame rate,it shows changes in moving shapes in Java & Javascript mode but not in Android mode,
Why this happens?
How should i increase frame rate to fast my visualization ?

      // Set number of circles
  int count = 25;
  // Set maximum and minimum circle size
  int maxSize = 100;
  int minSize = 20;
  // Build float array to store circle properties
  float[][] e = new float[count][5];
  // Set size of dot in circle center
  float ds=2;
  // Selected mode switch
  int sel = 0;
  // Set drag switch to false
  boolean dragging=false;
  // If use drags mouse...
  void mouseDragged(){
    // Set drag switch to true
    dragging=true;
  }
  // If user releases mouse...
  void mouseReleased(){
    // ..user is no-longer dragging
    dragging=false;
  }

  // Set up canvas
  void setup(){
    // Frame rate
    frameRate(130);
    // Size of canvas (width,height)
    size(600,475);
    // Stroke/line/border thickness
    strokeWeight(1);
    // Initiate array with random values for circles
    for(int j=0;j< count;j++){
      e[j][0]=random(width); // X 
      e[j][1]=random(height); // Y
      e[j][2]=random(minSize,maxSize); // Radius        
      e[j][3]=random(-.5,.5); // X Speed
      e[j][4]=random(-.5,.5); // Y Speed    
    }
  }

  // Begin main draw loop (called 25 times per second)
  void draw(){
    // Fill background black
    background(0);
    // Begin looping through circle array
    for (int j=0;j< count;j++){
    // Disable shape stroke/border
    noStroke();
    // Cache diameter and radius of current circle
    float radi=e[j][2];
    float diam=radi/2;
    // If the cursor is within 2x the radius of current circle...
    if( dist(e[j][0],e[j][1],mouseX,mouseY) < radi ){
    // Change fill color to green.
    fill(64,187,128,100);
    // Remember user has circle "selected"  
    sel=1;
    // If user has mouse down and is moving...
    if (dragging){
      // Move circle to circle position
      e[j][0]=mouseX;
      e[j][1]=mouseY;
      }
    } else {
      // Keep fill color blue
      fill(64,128,187,100);
      // User has nothing "selected"
      sel=0;
    }
    // Draw circle
    ellipse(e[j][0],e[j][1],radi,radi);
    // Move circle
    e[j][0]+=e[j][3];
    e[j][1]+=e[j][4];


    /* Wrap edges of canvas so circles leave the top
    and re-enter the bottom, etc... */ 
    if( e[j][0] < -diam      ){ e[j][0] = width+diam;  } 
    if( e[j][0] > width+diam ){ e[j][0] = -diam;       }
    if( e[j][1] < 0-diam     ){ e[j][1] = height+diam; }
    if( e[j][1] > height+diam){ e[j][1] = -diam;       }

    // If current circle is selected...
    if (sel==1) {
      // Set fill color of center dot to white..
      fill(255,255,255,255);
      // ..and set stroke color of line to green.
      stroke(128,255,0,100);      
    } else {            
      // otherwise set center dot color to black.. 
      fill(0,0,0,255);
      // and set line color to turquoise.
      stroke(64,128,128,255);      
    }

    // Loop through all circles
    for(int k=0;k< count;k++){
      // If the circles are close...
      if( dist(e[j][0],e[j][1],e[k][0],e[k][1]) < radi){
        // Stroke a line from current circle to adjacent circle
        line(e[j][0],e[j][1],e[k][0],e[k][1]);
      }
    }
    // Turn off stroke/border
    noStroke();      
    // Draw dot in center of circle
    rect(e[j][0]-ds,e[j][1]-ds,ds*2,ds*2);
    }
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:43:06+00:00Added an answer on June 16, 2026 at 3:43 am

    To change the speed of the circles in your sketch, it is easier to simply change the speed value.

    In your setup() function, you set the following:

     e[j][3] = random(-.5, .5); // X Speed
     e[j][4] = random(-.5, .5); // Y Speed
    

    These values are used later to move the circles in the draw() function:

    // Move circle
    e[j][0] += e[j][3];
    e[j][1] += e[j][4];
    

    You could simply change the e[j][3] and e[j][4] values being set in your setup() function, or you could replace them with a variable which is assigned in the global scope at the beginning of your code. The following is the quick modification I would make. Take note of the variable float speed = 0.5; set near the beginning of the code. If you make that value larger, the movement of the circles will be faster.

    // Set number of circles
    int count = 25;
    // Set maximum and minimum circle size
    int maxSize = 100;
    int minSize = 20;
    // Set speed
    float speed = 0.5;
    // Build float array to store circle properties
    float[][] e = new float[count][5];
    // Set size of dot in circle center
    float ds = 2;
    // Selected mode switch
    int sel = 0;
    // Set drag switch to false
    boolean dragging = false;
    
    // If use drags mouse...
    void mouseDragged() {
      // Set drag switch to true
      dragging = true;
    }
    
    // If user releases mouse...
    void mouseReleased() {
      // ..user is no-longer dragging
      dragging = false;
    }
    
    // Set up canvas
    void setup() {
      // Size of canvas (width,height)
      size(600, 475);
      // Stroke/line/border thickness
      strokeWeight(1);
      // Initiate array with random values for circles
      for (int j = 0; j < count; j++) {
        e[j][0] = random(width); // X 
        e[j][1] = random(height); // Y
        e[j][2] = random(minSize, maxSize); // Radius
        e[j][3] = random(-speed, speed); // X Speed
        e[j][4] = random(-speed, speed); // Y Speed
      }
    }
    
    // Begin main draw loop (called 25 times per second)
    void draw() {
      // Fill background black
      background(0);
      // Begin looping through circle array
      for (int j = 0; j < count; j++) {
        // Disable shape stroke/border
        noStroke();
        // Cache diameter and radius of current circle
        float radi = e[j][2];
        float diam = radi / 2;
        // If the cursor is within 2x the radius of current circle...
        if (dist(e[j][0], e[j][1], mouseX, mouseY) < radi) {
          // Change fill color to green.
          fill(64, 187, 128, 100);
          // Remember user has circle "selected"
          sel = 1;
          // If user has mouse down and is moving...
          if (dragging) {
            // Move circle to circle position
            e[j][0] = mouseX;
            e[j][1] = mouseY;
          }
        } else {
          // Keep fill color blue
          fill(64, 128, 187, 100);
          // User has nothing "selected"
          sel = 0;
        }
        // Draw circle
        ellipse(e[j][0], e[j][1], radi, radi);
        // Move circle
        e[j][0] += e[j][3];
        e[j][1] += e[j][4];
    
    
        /* Wrap edges of canvas so circles leave the top
        and re-enter the bottom, etc... */
        if (e[j][0] < -diam) {
          e[j][0] = width + diam;
        }
        if (e[j][0] > width + diam) {
          e[j][0] = -diam;
        }
        if (e[j][1] < 0 - diam) {
          e[j][1] = height + diam;
        }
        if (e[j][1] > height + diam) {
          e[j][1] = -diam;
        }
    
        // If current circle is selected...
        if (sel == 1) {
          // Set fill color of center dot to white..
          fill(255, 255, 255, 255);
          // ..and set stroke color of line to green.
          stroke(128, 255, 0, 100);
        } else {
          // otherwise set center dot color to black.. 
          fill(0, 0, 0, 255);
          // and set line color to turquoise.
          stroke(64, 128, 128, 255);
        }
    
        // Loop through all circles
        for (int k = 0; k < count; k++) {
          // If the circles are close...
          if (dist(e[j][0], e[j][1], e[k][0], e[k][1]) < radi) {
            // Stroke a line from current circle to adjacent circle
            line(e[j][0], e[j][1], e[k][0], e[k][1]);
          }
        }
        // Turn off stroke/border
        noStroke();
        // Draw dot in center of circle
        rect(e[j][0] - ds, e[j][1] - ds, ds * 2, ds * 2);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I am using some open source code called OrderedDictionary that is derived from
Using code from open source MusicDroid with the following code that I found during
Im using an open source code from EvilDicom . Unfortunately, these codes are in
I am using svn to download the source code to an open source project.
I am using an open source .Net library which uses MSMQ underneath. After about
I have used an open source code from CodeProject to read email from incoming
i have source code of a open source project in python, the project has
I downloaded the source code from http://construct.svn.sourceforge.net/viewvc/construct/ using tar ball http://construct.svn.sourceforge.net/viewvc/construct/?view=tar There is a
I am using open source C++ library DCMTK from http://dicom.offis.de/dcmtk.php.en . I have successfully
hello all i have code from open source project that im integrating into my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.