# Low frameRate, my code gives 10 - 15 frames

**URL:** <https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053>\
**Category:** Coding Questions\
**Created:** [August 5, 2020, 7:13am UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053 "2020-08-05T07:13:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![yhlaskerimov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yhlaskerimov/32/9725_2.png) [@yhlaskerimov](https://discourse.processing.org/u/yhlaskerimov)\
**Post date:** [August 5, 2020, 7:13am UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/1 "2020-08-05T07:13:45Z")

</div>

Hello everyone. My code doesnt give me 30 frameRate even i dont do much thing there ! Help me please, thanks.

```auto
String s = "belli";
PFont font;
int tileCount = 25;
float tileWidth, tileHeight;

void setup() {
  size(800, 800);
  tileWidth = 25;
  tileHeight = 30;
  font = createFont("aktif.otf", 200);
  textFont(font);
  textSize(18);
  //textAlign(CENTER, CENTER);
  noCursor();
} 

void draw() {
  background(255);
  for (int gridY=0; gridY<tileCount-3; gridY++) {
    for (int gridX=0; gridX<tileCount; gridX++) {
      float posX = tileWidth*gridX+100;
      float posY = tileHeight*gridY+80;
      float angle = atan2(mouseY-posY, mouseX-posX) + radians(90);
      pushMatrix();
      translate(posX, posY);
      rotate (angle);
      fill(0);
      text(s.charAt((gridX+gridY)%5), 0, 0);
      popMatrix();
    }
  }
  fill(255, 0, 0);
  noStroke();
  circle(mouseX, mouseY, 30);
  fill(0);
  text(""+frameRate+"", 90, 20);
}

```

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [August 5, 2020, 10:45am UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/2 "2020-08-05T10:45:21Z")

</div>

Your fonts are causing an issue.

 ![Screenshot_20200805-114439](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3bebc997d95533e39777c5adb991896e851e987e.jpeg)

---

<div class="post-metadata">

**Author:** ![Bobby54](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bobby54/32/9302_2.png) [@Bobby54](https://discourse.processing.org/u/Bobby54)\
**Post date:** [August 5, 2020, 11:18am UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/3 "2020-08-05T11:18:23Z")

</div>

The font issue is because I(and you probably too) haven’t installed the font.  
For me it is running a pretty stable frameCount between 58 and 60.  
Mybe try setting frameCount manually to 60 by using `frameRate(60);`, however is 60 the default frame rate set by processing, so if your processor isn’t fast enough 60fps can’t be achieved (see [https://processing.org/reference/frameRate\_.html](https://processing.org/reference/frameRate_.html)).

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 5, 2020, 11:18am UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/4 "2020-08-05T11:18:42Z")

</div>

I made the same observation…

A solid 60 fps commenting the fonts:

```auto
  //font = createFont("aktif.otf", 200);
  //textFont(font);

```

`:)`

---

<div class="post-metadata">

**Author:** ![yhlaskerimov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yhlaskerimov/32/9725_2.png) [@yhlaskerimov](https://discourse.processing.org/u/yhlaskerimov)\
**Post date:** [August 5, 2020, 12:21pm UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/5 "2020-08-05T12:21:08Z")

</div>

@glv @Bobby54 @paulgoux I have to use that font. Do I have a chance to get 30fps ?

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [August 5, 2020, 12:34pm UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/6 "2020-08-05T12:34:23Z")

</div>

> [@yhlaskerimov](#):
>
> ```auto
> font = createFont("aktif.otf", 200);
> textFont(font);
> textSize(18);
> 
> ```

Try `font = createFont("aktif.otf", 18);` and remove `textSize(18);`.

If that doesn’t work, rasterise each character into a PImage and replace `text()` with `image()`.

---

<div class="post-metadata">

**Author:** ![Bobby54](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bobby54/32/9302_2.png) [@Bobby54](https://discourse.processing.org/u/Bobby54)\
**Post date:** [August 5, 2020, 12:44pm UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/7 "2020-08-05T12:44:59Z")

</div>

> [@micycle](#):
>
> If that doesn’t work, rasterise each character into a PImage and replace `text()` with `image()` .

I don’t think that’s a good idea since loading and drawing images takes longer and has a bigger impact on the processor.

---

<div class="post-metadata">

**Author:** ![yhlaskerimov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yhlaskerimov/32/9725_2.png) [@yhlaskerimov](https://discourse.processing.org/u/yhlaskerimov)\
**Post date:** [August 5, 2020, 1:03pm UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/8 "2020-08-05T13:03:46Z")

</div>

1st variant helped a little, now i got 20 - 22 fps… better) Thanks.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [August 5, 2020, 1:35pm UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/9 "2020-08-05T13:35:52Z")

</div>

If I were you make a class Letter with position and char etc. and fill an 1D-array of Letter with the data (in setup())

Then in draw() you would have less calculating.

Still you would have 25x25 pushMatrix calls which is expensive.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 5, 2020, 4:46pm UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/10 "2020-08-05T16:46:47Z")

</div>

Hello,

Try it with another renderer and report (just curious) your frame rates:

```auto
  size(800, 800);
  //size(800, 800, FX2D);
  //size(800, 800, P2D);
  //size(800, 800, P3D);

```

[https://processing.org/reference/environment/](https://processing.org/reference/environment/)  
[https://www.processing.org/tutorials/rendering/](https://www.processing.org/tutorials/rendering/)

I am getting solid frame rates while actively moving mouse with one of the other renderers.

`:)`

---

<div class="post-metadata">

**Author:** ![yhlaskerimov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yhlaskerimov/32/9725_2.png) [@yhlaskerimov](https://discourse.processing.org/u/yhlaskerimov)\
**Post date:** [August 6, 2020, 6:42am UTC](https://discourse.processing.org/t/low-framerate-my-code-gives-10-15-frames/23053/11 "2020-08-06T06:42:23Z")

</div>

Hello, thank u @glv!  
size(800, 800, P2D) and size(800, 800, P3D) are helped ! 60 fps, wonderfull !
