Skip to content

Instantly share code, notes, and snippets.

@bjoerge
Last active March 14, 2017 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerge/841a9a7e9f5dc81785e93a9439844409 to your computer and use it in GitHub Desktop.
Save bjoerge/841a9a7e9f5dc81785e93a9439844409 to your computer and use it in GitHub Desktop.
gen-hotspot-styles
node_modules
require_relative 'generate_hotspot_styles'
result = generate_hotspot_styles({
"image" => {"height" => 100, "width" => 100},
"crop" => {
"bottom" => 0.12606837606837606,
"left" => 0.022792022792022918,
"right" => 0.1396011396011395,
"top" => 0.11538461538461486
},
"hotspot" => {
"height" => 0.2628205128205133,
"width" => 0.40170940170940117,
"x" => 0.4344729344729348,
"y" => 0.5566239316239308
}
})
puts "Result: #{result.inspect}"
const calculateStyles = require('@sanity/imagetool/calculateStyles').default
const options = JSON.parse(process.argv.slice(-1)[0].trim())
process.stdout.write(JSON.stringify(calculateStyles(options)))
require 'json'
def generate_hotspot_styles(options)
JSON.parse(`node generate_hotspot_styles.js '#{options.to_json}'`)
end
{
"private": true,
"dependencies": {
"@sanity/imagetool": "^0.103.13"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment