Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content layout interface #9

Open
quinkennedy opened this issue Jul 12, 2015 · 1 comment
Open

content layout interface #9

quinkennedy opened this issue Jul 12, 2015 · 1 comment

Comments

@quinkennedy
Copy link
Contributor

I'm thinking that each atomic piece of content (heading, quote, image, footer, page num, etc) should have a rendering function which takes a rect and a float as arguments, and the renderer is allowed to use a percentage of the specified rect area for rendering its content.

This might be something like:

rect heading(String text, rect area, float amount){
  text(text, area.x, area.y, area.w, area.h*amount);
  return rect(area.x, area.y+area.h*amount, area.w, area.h*(1-amount));
}

rect image(PImage img, rect area, float amount){
  if (image.width > image .height){
    image(img, area.x, area.y, area.w, area.h*amount);
    return rect(area.x, area.y+area.h*amount, area.w, area.h*(1-amount));
  } else {
    image(img, area.x, area.y, area.w*amount, area.h);
    return rect(area.x+area.w*amount, area.y, area.w*(1-amount), area.h);
  }
}

void render(PageData pd){
  rect r = heading(pd.heading, rect(0, 0, pd.contentWidthPx, pd.contentHeightPx), .25);
  r = image(pd.imageContent[0], r, 2.0/3);
}
@quinkennedy
Copy link
Contributor Author

We started working toward this with commit 5211bd4

Currently we have a ContentBox render(...) interface, this might want to be expanded to include a query or layout interface for pre-render calculations. the render function returns a Rectangle representing the actual area that the element used (whereas the Rectangle argument is the area available)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant