annotorious / annotorious-v1

Project has moved to http://github.com/annotorious/annotorious
https://annotorious.com
MIT License
592 stars 142 forks source link

anno.setProperties with OpenSeadragon #187

Open apricea4 opened 7 years ago

apricea4 commented 7 years ago

anno.setProperties breaks annotorious on the line anno.makeAnnotatable(viewer) in my code with the stack trace pointing to anno.min.js as well. I have tried putting it before and after the makeAnnotatable call. Has anyone successfully set the properties of an OpenSeadragon x annotorious annotation? I would like to be able to change the color and font of the text, change the color of the rectangle and make the annotations persist throughout the session.

Also, how might I get the height and width of an annotation in pixels? I see one can do annotation.text and so I imagine it would be annotation.height, but how can I guarantee pixels?

Thank you

nasedil commented 6 years ago

@apricea4 you can get annotation relative width and height as following:

annotation.shapes[0].geometry.width
annotation.shapes[0].geometry.height

The values would be in range 0..1. To convert to pixels you can multiply the values by the image width and height, respectively.

Regarding anno.setProperties, it also breaks in my case, during the anno.makeAnnotatable call, saying:

TypeError: $annotator$$1$$.$setProperties$ is not a function:
annotorious.debug.js:2043:76

$JSCompiler_StaticMethods__initAnnotator$$
http://annotorious.github.com/latest/annotorious.debug.js:2043:76
$$JSCompiler_prototypeAlias$$$$makeAnnotatable$$
http://annotorious.github.com/latest/annotorious.debug.js:2181:34
$$JSCompiler_prototypeAlias$$$$makeAnnotatable$$
http://annotorious.github.com/latest/annotorious.debug.js:4375:19