Last active
March 14, 2017 12:07
-
-
Save bjoerge/841a9a7e9f5dc81785e93a9439844409 to your computer and use it in GitHub Desktop.
gen-hotspot-styles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const calculateStyles = require('@sanity/imagetool/calculateStyles').default | |
const options = JSON.parse(process.argv.slice(-1)[0].trim()) | |
process.stdout.write(JSON.stringify(calculateStyles(options))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
def generate_hotspot_styles(options) | |
JSON.parse(`node generate_hotspot_styles.js '#{options.to_json}'`) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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