我正在處理7680x1080投影的可視化。 處理:分屏= 1畫布?
我如何在Processing中這樣做,以便Processing仍將此視爲1大畫布,並且我可以在整個寬度上具有無縫圖形?
謝謝! Serge
我正在處理7680x1080投影的可視化。 處理:分屏= 1畫布?
我如何在Processing中這樣做,以便Processing仍將此視爲1大畫布,並且我可以在整個寬度上具有無縫圖形?
謝謝! Serge
在處理繪圖以PGraphics
和PImage
對象來完成(這裏瞭解更多:https://processing.org/reference/PImage.html)
然後,您可以讀取你把你的PGraphics畫布的象素和2它們分裂出來PImage對象
例子:
int w = 500;
int h = 500;
PImage topCanvas;
PImage bottomCanvas;
PGraphics mainCanvas;
void setup() {
background(255);
size(w, h, P3D);
mainCanvas = createGraphics(w, h, P2D);
mainCanvas.beginDraw();
for(int i=0; i<w; i++){
for(int j=0; j<h; j++){
mainCanvas.stroke(random(255), random(255), random(255), random(255));
mainCanvas.point(i, j);
}
}
mainCanvas.endDraw();
}
void draw(){
topCanvas = mainCanvas.get(0,0,w, h/2);
bottomCanvas = mainCanvas.get(0,h/2,w, h/2);
image(topCanvas, 0, 0);
image(bottomCanvas, 0, h/2);
}
處理已經是一大畫布。您可以控制您繪製的內容以及繪製它的位置。
你可能只是保持你的視口的大小和位置的軌道,然後分頭行動繪圖進功能:
float viewportTwoX;
float viewportTwoY;
float viewportWidth;
float viewportHeight;
void setup() {
size(768, 108);
viewportTwoX = width/2;
viewportTwoY = 0;
viewportWidth = width/2;
viewportHeight = height;
}
void draw() {
background(0);
drawViewportOne();
drawViewportTwo();
}
void drawViewportOne() {
fill(64);
noStroke();
rect(0, 0, viewportWidth, viewportHeight);
fill(255);
text("viewport 1", viewportWidth/2, viewportHeight/2);
}
void drawViewportTwo() {
translate(viewportTwoX, viewportTwoY);
fill(128);
noStroke();
rect(0, 0, viewportWidth, viewportHeight);
fill(255);
text("viewport 2", viewportWidth/2, viewportHeight/2);
}
這時如果你想改變第二視窗的位置,你只需要改變這些變量的值:
void setup() {
size(384, 216);
viewportTwoX = 0;
viewportTwoY = height/2;
viewportWidth = width;
viewportHeight = height/2;
}
我想這正是我要找的!會玩這個有點。謝謝! – sjespers