question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Paper Size Presets

See original GitHub issue

Something I hate doing is googling for common sizes and converting to/from various units, so I think it could be handy to have a simple way of starting from a ‘preset’.

const canvasSketch = require('canvas-sketch');

const settings = {
  ...canvasSketch.preset('A4')
};

Which leads to { units: 'cm', dimensions: [ 21, 29.7 ] }.

Could support:

  • A1-8, B, C, D…
  • letter
  • legal
  • tabloid
  • postcard (4x6")
  • business-card
  • poster (18x24" according to Photoshop and this random site)

The object can be merged in with your settings using ... or Object.assign({}), and/or the function could also accept other values and merge them into the result:

const settings = canvasSketch.preset('a4', {
  animate: true, // a looping print
  units: 'in', // if you want to work in inches
});

If you pass in units it will do the conversion for you, so you can work in your preferred unit.

Could also support some web defaults like:

  • 1080p, 720p, 480p, 320p, 240p

Which returns { units: 'px', dimensions: [ x, y ] }.

Questions:

  • Is this too much scope creep? I don’t think so since the tool is aiming to be an all-around convenience for generative art and this seems like a common task.
  • Is the above syntax clean/easy or is there another way the function should be imported and used?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mattdeslcommented, Jul 6, 2018

I decided to go with { dimensions: 'A4' } since it’s simple for the end user. Also relevant now is orientation

const settings = {
  dimensions: 'A4',
  units: 'in'
  orientation: 'landscape'
};

Added to docs:

Developing with Physical Units — Paper Size Presets

1reaction
fturcheticommented, Jul 6, 2018

If I understand correctly, yes, that makes sense!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Choose a paper size for your printed document on Mac
On your Mac, choose the paper size to use when printing. ... On your Mac, choose Apple menu > System Settings, then click...
Read more >
Paper Sizes and Formats, the Difference Between A4 and Letter
Paper sizes and formats explained: learn more about the difference ... These presets typically take the form of buttons labelled A3→A4 and so...
Read more >
Printer Is Configured to Use the Wrong Paper Size
Click Start, point to Settings, and the click Printers. · Right-click the appropriate printer, and then click Properties. · Click the Paper tab,...
Read more >
Paper Size and Type Settings
If displayed paper size and type differ from the loaded paper, select the item to change. If the settings match the loaded paper,...
Read more >
Presets - Standard Print Sizes - Lightroom Killer Tips
It would be helpful if Lightroom had an option to forego the printer settings and let you choose options like paper size and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found