search()

Find the optimal encoding

search(permutation,fn,opt)

  • permutation: use permute() to generate
  • fn: function that receives qr and returns an object with 'score' value
  • opt:
    • capacity: number of top-scoring items to retain
    • ecl: ECL level (0-3)
    • version: Version number (1-40)
    • batch:
      • start: index to start at
      • stride: amount to increment index byte
      • limit: number of items to iterate over
      • loop: number to loop around (usually permutation.total)

Search for URL with the most black pixels

import { permute, search } from 'qrsart/search'

let results = search(
  permute('url','https://qrs.art',{ protoclCaps: true }),
  function priority(qr){
    let count = 0
    for(let [x,y] of qr.grid.tiles(1)){
      count++
    }
    return { score: count }
  },
  {
    capacity: 6,
    ecl: 2,
    version: 2
  }
)