processing - 关于 setup() 函数中的 size()
问题描述
为什么我可以在 setup() 中使用 size(1920, 1080) 但如果我使用
setup()
visualContext = new VisualContext(
new Area(0, 0, 1920, 1080),
new Area(158, 150, 1340, 950)
);
size(visualContext.getGlobalArea().getWidth(), visualContext.getGlobalArea().getHeight());
会有错误
When not using the PDE, size() can only be used inside settings().
Remove the size() method from setup(), and add the following:
public void settings() {
size(1920, 1080);
}
我找不到有关此主题的任何文档。
好奇,size只能用常量初始化吗?
解决方案
如果要使用参数调用大小,请使用设置。
VisualContext visualContext = new VisualContext(
new Area(0, 0, 1920, 1080),
new Area(158, 150, 1340, 950)
);
void settings() {
size(visualContext.getGlobalArea().getWidth(), visualContext.getGlobalArea().getHeight()); //<>//
}
推荐阅读
- ios - 在stackview和空格中调整我的textview的大小
- postgresql - CARTO Postgres 频率表(按年份)
- arrays - 在 Fortran 中返回数组的函数
- django - Django - HTML 输入值未在视图中打印
- java - Java DateTime 12 小时格式
- facebook - 从 Facebook 导入好友计数使用 IMPORTXML
- java - @SpringBootTest 装饰器导致 WatchService 的测试卡住
- android - Android buildTypes 与 productFlavors 错误
- asp.net - ASP.NET 按计时器更新数据列表不起作用
- c++ - 从 Redis++ 连接到 Docker 中的 Redis