Giter VIP home page Giter VIP logo

Comments (7)

sojamo avatar sojamo commented on September 7, 2024

I can confirm that 50k characters long text using PFont (that is if you apply for example .setFont(createFont("arial",12)) to a textarea) and the default renderer results in slow scrolling.

Fix:
Changing PFont to the default controlP5 pixel font gives me smooth scrolling (mousewheel and scrollbar) for 400k+ characters. When changing the default renderer to P3D or P2D, both, the pixel font as well as PFont give me smooth scrolling results for 400k+ characters. (I am using a modified version of the ControlP5Textarea example that comes with controlP5 where I append 50k junks of lorem ipsum text read from a file on keyPressed).

from controlp5.

feklee avatar feklee commented on September 7, 2024

Changing PFont to the default controlP5 pixel font gives me smooth scrolling (mousewheel and scrollbar) for 400k+ characters.

Indeed this works, thanks for the suggestion! However, the default font has a couple of disadvantages:

  1. It’s tiny.
  2. It’s not fixed width.

Can it be swapped for another font?

When changing the default renderer to P3D or P2D, both, the pixel font as well as PFont give me smooth scrolling results for 400k+ characters.

Doesn’t work for me, i.e. with fonts set by PFont scrolling is painfully slow also for P3D and P2D. I’m using:

PFont font = createFont("Consolas", 12);

from controlp5.

sojamo avatar sojamo commented on September 7, 2024

Can it be swapped for another font?

you can manually set the font with cp5.setFont() for all controllers.

PFont font = createFont("Consolas", 12);
ControlP5 cp5 = ControlP5(this);
cp5.setFont(font);

Doesn’t work for me

Do you have more details about your os, processing version, controlP5 version. A working example which only highlights the issue you are encountering would be useful.

from controlp5.

sojamo avatar sojamo commented on September 7, 2024

since there was no follow up, closing issue.

from controlp5.

feklee avatar feklee commented on September 7, 2024

Example code:

import controlP5.*;

void setup() {
  size(800, 600);

  Textarea ta = new ControlP5(this).addTextarea("").setSize(800, 600);

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 1000; j++) {
      ta.append(" " + i);
    }
    ta.append("\n");
  }
}

void draw() {
  background(0);
}

Here a scroll bar appears, but scrolling does not work at all.

Memory consumption is insane. For one line, I have two Java processes, each using about 100,000 MB. For ten lines, one of the processes uses about 300,000 MB.

Environment: Processing 3.0.1 (same with 3.0.1), Windows 7 x64

from controlp5.

sojamo avatar sojamo commented on September 7, 2024

Hi, I dont find the memory behavior surprising, a lot more characters have to be drawn per frame which consequently will consume more memory. For example the following code consumes ~750MB right after running the sketch for rendering text across the window (I am on osx, Processing's maximum available memory is set to 2048MB):

String txt;
void setup() {
  size(800,600);
  txt = "";
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 1000; j++) {
      txt += (" " + i);
    }
    txt += ("\n");
  }
}

void draw() {
  background(0);
  text(txt,0,0,800,600);
}

your given example starts with consuming 250MB for me and increases when scrolling, though settles at ~770MB after continuously scrolling up and down. This is not an unusual memory management behaviour, if memory is available it will be used. Try to decrease the allocated memory for a sketch inside Processing's preferences and you will see that memory usage will behave differently.

Again, scrolling works well for me in both P3D/P2D and default JAVA mode.

from controlp5.

sojamo avatar sojamo commented on September 7, 2024

no follow up, closing issue.

from controlp5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.