在探索处理中的 saveFrame 选项时如何解决“背景限制”?

问题描述 投票:0回答:1

简介 我需要你的帮助,因为我被困住了。 首先,我是一名图形艺术家,而不是编码员和/或程序员。这些年来我通过自学和尝试学习了基础、方案、标志、处理和Python。

因此,请在指导我时保持易于理解和直截了当的态度。谢谢。

目标 对于我当前的动画项目,我使用的是处理 2.2.1,主要是因为 HSB 色彩空间功能。同时,Fry & reas 的《处理。视觉设计师和艺术家的编程手册》+ Shifmann 的《学习处理》是我的指南。

什么? 简而言之,我想创建一个由 1 + 4 + 16 + 64 帧组成的动画(gif 或 .mp4),这些帧是通过处理交付的。因此我制作了 4 个独立的子程序,它们都运行得非常顺利,提供了整齐编号的输出(帧)等等。 .

但是 在 Photoshop 中导入/收集帧堆栈后,在运行动画时,似乎只有第一帧需要所谓的黑色背景。因此,所有其他剩余帧的背景需要不可见(或者更透明)才能生成混合方块流。

可能的解决方案? 我期望下一个代码:背景(0,0,0,0)[=“透明”黑色],或者: 背景(0,0,10,0)[=“透明”白色]来解决这个问题,因为最后一个数字(零),即[10=不透明,而0=透明]。但事实并非如此。事实上,即使删除后台调用也没有任何效果。

摘自《如何制作完全透明的背景?》在这里讨论,我知道没有真正的解决方案。 shifmann 的“16.6 背景去除”解决方案(第 293 页)对我来说太复杂了。

有人知道可能的(快速)解决方法吗?或者,有什么想法吗?

样品 第三个子的一些代码,“绘制”16个100x100px的正方形随机分布:

// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 2.2.1
// ANIMATED DYNAMIC SELF ORGANISING REPEAT PATTERNS
// - - - - - - - - - - - - - - - - - - - - - - - - - - to prepare
// - - - - - - - - - - - - - - - - - - - - - - - - - - 20241231
// A01c_1300x900px_sizE100frameC16_H180a90onK.pde      title
// extended canvas - - - - - - - - - - - - - - - - - - 1300x900px
// art - - - - - - - - - - - - - - - - - - - - - - - - 800x800px
// + + + + + + + + + + + + + + + + + + + + + + + + + + DECLARE
int x0;
int y0=150;
int x1;
int y1;
int x2;
int y2;  
int count=1;
int H90;
// + + + + + + + + + + + + + + + + + + + + + + + + + + MAIN
void setup() {
  size(1300,900);                                   // extended
  colorMode(HSB,360,10,10,10); 
  background(0,0,0,0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - LOOP
void draw() {   
  colorMode(HSB,360,10,10,10);
  strokeWeight(100);
  strokeCap(SQUARE);
  smooth();
                                                    // OR noLoop();
// - - - - - - - - - - - - - - - - - - - - - - - - - - frameCount 16
  while (frameCount <= 16) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - 8rows8columns
    for (x0=350; x0 < 1050; x0=x0+200) { 
      squareC16(); 
      what90();    
      stroke(H90,10,10,10);
      line(x1,y1,x2,y2);
      saveFrame("3-##.jpg");
// - - - - - - - - - - - - - - - - - - - - - - - - - - trafficer  
      println(frameCount);
      println(count);
      println();
      frameCount=frameCount+1;
      count=count+1;
    }
// - - - - - - - - - - - - - - - - - - - - - - - - - - transport  
   y0=y0+200;
   }
 }
// + + + + + + + + + + + + + + + + + + + + + + + + + + FUNCTIONS
// - - - - - - - - - - - - - - - - - - - - - - - - - - ONE x 16
void squareC16() {
// - - - - - - - - - - - - - - - - - - - - - - - - - - dice
  int dice = int(random(4)+1);                            
// - - - - - - - - - - - - - - - - - - - - - - - - - - 1 top/left
  if (dice==1) {
    x1=x0;
    y1=y0-50;
    x2=x0-100;
    y2=y0-50;
// - - - - - - - - - - - - - - - - - - - - - - - - - - 2 top/right      
   } else if (dice==2) {
    x1=x0;
    y1=y0-50;
    x2=x0+100;
    y2=y0-50;
// - - - - - - - - - - - - - - - - - - - - - - - - - - 3 bottom/left      
   } else if (dice==3) {
    x1=x0;
    y1=y0+50;
    x2=x0+100;
    y2=y0+50;
// - - - - - - - - - - - - - - - - - - - - - - - - - - 4 bottom/right        
   } else {
    x1=x0;
    y1=y0+50;
    x2=x0-100;
    y2=y0+50;
   }
}
background processing opacity transparent
1个回答
0
投票

万岁! 经过一些关于嵌套命令顺序的实验,我能够生成非常想要的输出,即包括透明背景的 x 帧数。 唉,PGraphics 不接受方便的“saveFrame”命令,但最终我找到了一个可接受的解决方法。正如你自己看到的,因为这是子程序B的代码:

// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 2.2.1
// ANIMATED DYNAMIC SELF ORGANISING REPEAT PATTERN     20250105
// - - - - - - - - - - - - - - - - - - - - - - - - - - PGraphics                                                            
// PG0105pBn3g_count4_H225T10a45.pde                   current
//                                                     REDUCED SIZE
// extended canvas - - - - - - - - - - - - - - - - - - 1300x900px
// ART - - - - - - - - - - - - - - - - - - - - - - - - 800x800px
// - - - - - - - - - - - - - - - - - - - - - - - - - - TO PREPARE
// 4 + 3 + 2 + 1 = A + B + C + D > 4 = last > 1 = top
// - - - - - - - - - - - - - - - - - - - - - - - - - - calculus
// 1200:3 = 400                                        A 
//  900:3 = 300
//  600:3 = 200                                  > > > B [3]
//  300:3 = 100                                        C 
//  150:3 =  50                                        D
//   75:3 =  25                                        E     
// + + + + + + + + + + + + + + + + + + + + + + + + + + DECLARE
int x0;
int y0=250;
int x1;
int y1;
int x2;
int y2;  
int count=1;
int H225;
// + + + + + + + + + + + + + + + + + + + + + + + + + + MAIN
// - - - - - - - - - - - - - - - - - - - - - - - - - - call
PGraphics pg;
//
void setup() {
size(1300,900);                                      
pg=createGraphics(width,height);
pg.colorMode(HSB,360,10,10,10);
pg.background(0,0,10,0); 
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - NO LOOP
void draw() { 
colorMode(HSB,360,10,10,10);
smooth();
noLoop();
// - - - - - - - - - - - - - - - - - - - - - - - - - - start PG 
pg.beginDraw(); 
// - - - - - - - - - - - - - - - - - - - - - - - - - - 4x4 frames  
while (frameCount <= 4) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - one row
    for (x0=450; x0<1050; x0=x0+400) {
    pg.strokeCap(SQUARE);
    pg.strokeWeight(200); 
    pg.colorMode(HSB,360,10,10,10);
    squareC4(); 
    what225();
    pg.stroke(H225,10,10,10);
    pg.line(x1,y1,x2,y2);

///// INSERT since /// saveFrame("B-##.png"); /// is alas not valid! 

    if (frameCount==1) {
        pg.save("B-01.png");
        } else if (frameCount==2) {
        pg.save("B-02.png");
        } else if (frameCount==3) {
        pg.save("B-03.png");
        } else {
        pg.save("B-04.png");  
        }
// - - - - - - - - - - - - - - - - - - - - - - - - - - trafficer   
        println(frameCount);
        println(count);
        println();
        frameCount=frameCount+1;
        count=count+1;
        }
// - - - - - - - - - - - - - - - - - - - - - - - - - - transport  
        y0=y0+400;                                 
    }
// - - - - - - - - - - - - - - - - - - - - - - - - - - END PG
    pg.endDraw();
// - - - - - - - - - - - - - - - - - - - - - - - - - - on screen           
    image(pg,0,0);
} 
// ::::::::::::::::::::::::::::::::::::::::::::::::::: PROCEDURES
// 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 > B [H 225]
void squareC4() {
// - - - - - - - - - - - - - - - - - - - - - - - - - - dice
int dice = int(random(4)+1);                            
// - - - - - - - - - - - - - - - - - - - - - - - - - - 1 top/left
if (dice==1) {
        x1=x0;
        y1=y0-100;
        x2=x0-200;
        y2=y0-100;
// - - - - - - - - - - - - - - - - - - - - - - - - - - 2 top/right      
    } else if (dice==2) {
        x1=x0;
        y1=y0-100;
        x2=x0+200;
        y2=y0-100;
// - - - - - - - - - - - - - - - - - - - - - - - - - - 3 bottom/left      
    } else if (dice==3) {
        x1=x0;
        y1=y0+100;
        x2=x0+200;
        y2=y0+100;
// - - - - - - - - - - - - - - - - - - - - - - - - - - 4 bottom/right        
    } else {
        x1=x0;
        y1=y0+100;
        x2=x0-200;
    y2=y0+100;
    }
}
// + + + + + + + + + + + + + + + + + + + + + + + + + + GOSUB
void what225(){
    H225=int(random(90)+225);
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.