作者 主题: 急!!!导出pdf有问题!!!  (阅读 2969 次)

xurenfang

  • Newbie
  • *
  • 帖子: 6
急!!!导出pdf有问题!!!
« 于: 七月 09, 2012, 09:16:38 上午 »
2个小程序想导出pdf,无奈都报错。一个是颜色不对,提示light()函数不适应,另一个直接translate()不适应,画面一片黑。据哪位大侠能帮忙看下。。
人像程序
程序代码
import processing.opengl.*;

import processing.pdf.*;



PImage img;       
int cellsize = 2;
float yOffset;
boolean recordOrNot = false;

void setup() {

  size(500, 600, P3D);

  frameRate(30);
  smooth();
  imageMode(CENTER);
  zOffset=0;



  img = loadImage( "1230.jpg" );
}

void draw() {

  if (recordOrNot) {
    beginRecord(PDF, "Output.pdf");
  }
  background(0);
  img.loadPixels();

  for (int i = 0; i < width/2; i++ ) {

    for (int j = 0; j < height/2; j++ ) {


      int x = i*2 + 1;
      int y = j*2 + 1;

      int loc = x + y*width;         
      color c = img.pixels[loc];       
      float z = zOffset * brightness(color(c));


      pushMatrix();
      translate(x, y, z);
      stroke(c);
      point(0, 0);

      popMatrix();
    }
  }

  zOffset+=0.005;


  if (recordOrNot) {
    endRecord();
    recordOrNot = false;
  }
}

void mousePressed() {
  recordOrNot = true;
}



圆圈程序
程序代码
import processing.pdf.*;
import processing.opengl.*;


float spacing;
float yStart;
float xStart;
float a;
float cSeed;
float c;
float r;
boolean recordOrNot = false;

void setup() {
  size(500, 500,OPENGL);
  smooth();
  colorMode(HSB);
  //spacing=20;
  frameRate(8);
  //cSeed=random(20);
 
}


void draw() {
  if(recordOrNot) {
    beginRecord(PDF, "Output.pdf");
  }
 
  background(0);
  lights();
  translate(width/2, width/2);
  for (int i=0;i<1000;i++) {
    noStroke();
    fill(random(100), 360, 255);
    c=noise(cSeed);
    cSeed+=1;
    pushMatrix();
 
   
 
   translate(cos (a)*r,sin( a)*r );
a= degrees((i+1)*19);
r=dist(mouseX,mouseY,width/2, width/2);
 ellipse (cos (a)*r,sin( a)*r,1.7,1.7);
  //sphere(4);
 popMatrix();
 
 
 pushMatrix();
   translate(cos (a)*(r-15),sin( a)*(r-15));
a= degrees(i);
r=dist(mouseX,mouseY,width/2, width/2);

//rotateZ(((radians(frameCount)+i)));
//rotateX(((radians(frameCount)+i)));
//sphere(2);
//  box(dist(mouseX,mouseY,width/2, width/2)*3,20, 20);
    //translate(100,0 );
    //sphere(5);
    //translate(-200,0 );
   popMatrix();
   
       pushMatrix();
   translate(cos (a)*(r-30),sin( a)*(r-30) );
a= degrees((i+1)*10);
r=dist(mouseY,mouseX/2.4,width/2, width/2);
ellipse (cos (a)*r,sin( a)*r,0.6,0.6);
  //sphere(1);
 popMatrix();
 
 

       pushMatrix();
 
   translate(cos (a)*r,sin( a)*r );
a= degrees((i+1)*3.777);
r=dist(mouseX,mouseY,width/2, width/2);
ellipse (cos (a)*r,sin( a)*r,2,2);
  //sphere(8);
popMatrix();
  }
 
   if(recordOrNot) {
    endRecord();
    recordOrNot = false;
  }
}
void mousePressed() {
  recordOrNot = true;
}

报错语句:translate(), or this particular variation of it, is not available with this renderer.
isRecording(), or this particular variation of it, is not available with this renderer.


lights() is not available with this renderer.
isRecording(), or this particular variation of it, is not available with this renderer.


RavenKwok

  • Sr. Member
  • ****
  • 帖子: 277
  • Artist/ Animator/ Coder/ Cynical Asshole
Re: 急!!!导出pdf有问题!!!
« 回复 #1 于: 七月 09, 2012, 08:57:51 下午 »

xurenfang

  • Newbie
  • *
  • 帖子: 6
Re: 急!!!导出pdf有问题!!!
« 回复 #2 于: 七月 10, 2012, 03:13:00 下午 »
多谢郭老师。。。

Tags: