java里面text_java-处理中的text()

我正在与Processing一起玩,以查看一切工作原理,但是在处理text()方法时,似乎存在加载时间问题.

我简单的代码将一个PNG图像加载到屏幕上,然后是3个4个字母,大小为24个单词.当我只在其中保留图像加载代码时,应用程序立即启动,但是当我将text()代码放入时,加载大约需要3-4秒.

上面是直接从Processing应用程序完成的,但是我实际上是在JFrame中开发它的,所以在开始的4秒钟中,我实际上看到了一个空白的JFrame,这非常丑陋.

我对你们的问题是,你们中的每个人是否都知道text()的问题,或者是否有逻辑上的理由来解释为什么加载需要这么长时间.

-在四核计算机上运行Java 7

这是相关的代码

PImage backgroundImage;

PFont font;

/**

* PApplet method - performs all setup actions

*/

public void setup(){

this.size( 1400, 900);

backgroundImage = loadImage( "EG_dark.png" );

backgroundImage.resize( width, height );

this.background(backgroundImage);

font = createFont("AmericanTypewriter", 24);

textFont(font);

}

/**

* PApplet method - All drawing occurs here

*/

public void draw(){

if(backgroundImage.width != width || backgroundImage.height != height){

backgroundImage.resize( width, height );

}

this.background(backgroundImage);

fill(0, 102, 153);

text("word", 15, 30);

fill(0, 102, 153);

text("word", 15, 60);

fill(0, 102, 153);

text("word", 15, 90);

}

解决方法:

您所描述的是处理createFont的正确行为.

直接从文档中引用:

createFont():

Dynamically converts a font to the format used by Processing from

either a font name that’s installed on the computer, or from a .ttf or

.otf file inside the sketches “data” folder. This function is an

advanced feature for precise control. On most occasions you should

create fonts through selecting “Create Font…” from the Tools menu.

通过处理应用程序创建vlw字体文件可以更好地处理您要执行的操作:menu / tools / Create Font …(将结果文件复制到应用程序的数据文件夹中)

PFont font;

font = loadFont("AmericanTypewriter.vlw");

textFont(font, 24);

...

text("word", 15, 50);

标签:lag,fonts,graphics,java,processing

来源: https://codeday.me/bug/20191101/1986266.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值