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

Dev fixbounds #298

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Dev fixbounds #298

wants to merge 2 commits into from

Conversation

ffd8
Copy link
Member

@ffd8 ffd8 commented Nov 12, 2018

Fixed a few issues in bounds() when using canvasMode(MARGIN) or canvasMode(FACING_MARGINS). BLEED, FACING_BLEEDS, PAGE, FACING_PAGES are all working fine too.

Only thing that still remains, is when getting the bounds(pages()) in one of the FACING_ modes, which was already an issue and can be solved later.

Here's a test script using bounds() of a few items:

// @includepath ~/Documents/;%USERPROFILE%Documents; 
// @include basiljs/basil.js; 
 
function draw() { 
  var output = layer("output");
  clear(output);
  
  canvasMode(MARGIN);
  //canvasMode(FACING_MARGINS);

  // first rect
  var r = rect(0, 0, width, height);
  var bnds = bounds(r);
  
  // 2nd rect overlay
  fill(255, 0, 0);
  var r2 = rect(bnds.left, bnds.top, bnds.width, bnds.height);
 
  // text, with bounds of letter
  fill(0, 255, 0);
  var tf = text("hello", 0, 0, width, height);
  typo(tf, "pointSize", 150);
  characters(tf, function(obj){
    if(obj.contents.toLowerCase() == 'h'){
      var bnds = bounds(obj);
      rectMode(CORNERS);
      fill(0, 0, 255);
      var r= rect(bnds.left, bnds.xHeight, bnds.right, bnds.baseline);
      referencePoint(CENTER);
      transform(r, "rotation", 45);
    }
  });

  // issue with bounds(page()) remains in FACING mode
  var bnd = bounds(page());
  fill(gradient(color(50), color(200)));
  var bg = rect(bnd.left, bnd.top, bnd.width, bnd.height);
  arrange(bg, BACK);
} 

- i think this simple + -> - might have fixed all issues with `bounds()` when using `canvasMode(MARGIN)` and `canvasMode(FACING_MARGINS)`?
- nearly fixed `bounds()`, when getting bounds of `page()`, just needs some love for FACING_PAGES/MARGINS/BLEEDS
@trych
Copy link
Contributor

trych commented Nov 12, 2018

@ffd8 There is a large list of issues with bounds() still, as you can see in #166. It basically needs a proper rewrite. I started a branch on this once and it soon turned into a huge task. That's why I would vote to not implement a fix hastily now that leaves many of the problems in place, but to either rewrite the function to adress these issues, or – and that's what I am voting for – to replace the bounds function by measure(), as I suggested in #295 .

The bounds functionality itself could be kept by implementing something like measure(item, "bounds"). Either way. All measuring should be handled by the inner functionality of transform() as this is currently the only function that handles measurements correctly, even with applied matrix transformations.

I would vote to close this pull request and not merge it.

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

Successfully merging this pull request may close these issues.

2 participants