PDF export doesn't work with Hyper framework

Hello,

I recently used Joshua Davis’ fantastic hype framework for a poster design. It worked great, until I decided to export to a pdf as a vector. All I get is an empty pdf with no graphics. Pls help me if there any one out there who also uses this great framework and can get pdf with vectors.

Thank you so much!

Oh, I just watched Joshua’s videos on Skillshare and he actually shows how to get vectors out, very clearly. Thank you Joshua :slight_smile:

So problem solved, case closed :slight_smile:

1 Like

@buraquex that’s great news! Do you mind posting the link to Joshua’s videos for future readers please?

I think that is:

https://www.skillshare.com/classes/Programming-Graphics-I-Introduction-to-Generative-Art/782118657

oh yes, this is the one. Close to the last chapters, he shows how to output image and vector files.

1 Like

@buraquex it sounds like I am having the same problem you were, only I can’t get proper vector output by following Joshua’s process, it renders but only as a pixel based image. I would be super grateful if for any insight as to what I am missing: Export to PDF will not render vectors

1 Like

Hi @Hub33s, here is how you do it:

  1. First add this line to the beginning of your code: import processing.pdf.*;

  2. Also don’t forget to add the hype framework: import hype.*;

  3. Don’t forget to add this code in setup() function: H.init(this).background(#FFFFFF);

  4. In your draw() function add this code:

void draw() {
  PGraphics tmp = null;

  if (record) {
    tmp = beginRecord(PDF, "render-######.pdf");
  }

  if (tmp == null) {
    H.drawStage();
  } else {
    PGraphics g = tmp;
    boolean uses3D = false;
    float alpha = 1;
    H.stage().paintAll(g, uses3D, alpha);
  }

  if (record) {
    endRecord();
    record = false;
  }
}
  1. And finally add this code outside of any other functions:
void keyPressed() {
  if (key == 's') {
    record = true;
    draw();
  }
}

Each time you press ‘s’ key, a new version of the pdf will be saved to where the project is.

Hope this helps!

1 Like

Thank you, much appreciated.

Hi. I can’t print 3D in PDF HBox. I suggest I can print 3D projection in Hype.
It prints 2D as expected with HRect and H.stage().paintAll(g, false, 1);

Second param in paintAll is boolean usesZ.

Here is simplified not working example with HBox and H.stage().paintAll(g, true, 1);

import hype.*;
import processing.pdf.*;

boolean record = false;

void setup() {
  size(600, 600, P3D);
  H.init(this).background(#ff00ff).autoClear(true);
  
  HBox d = new HBox();
  d
    // .depth(20)
    .loc( width/2, height/2, 10 )
    .width(20)
    .height(20)
  ;

  H.add(d);
}

void draw() {
  PGraphics tmp = null;

  if (record) {
    tmp = beginRecord(PDF, "render-HBox.pdf");
  }

  if (tmp == null) {
    H.drawStage();
  } else {
    PGraphics g = tmp;
    H.stage().paintAll(g, true, 1);
  }

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

void keyPressed() {
  if (key == 's') {
    record = true;
    // draw();
  }
}