emigre / openseadragon-annotations

Draw annotations over deep zoom images
BSD 3-Clause "New" or "Revised" License
97 stars 40 forks source link

Draw annotations programmatically. #15

Closed apricea4 closed 4 years ago

apricea4 commented 7 years ago

I want to draw shapes programmatically and change the color of the stroke. Is there any documentation about all methods exposed to me? My initial thought is I would call annotations.get(), push that array of arrays and pass the new index to annotations.set() to set the name and info to fill the object that describes the shape(location, height, width etc). Does this seem reasonable? Where is the object in the source code that describes the annotation, or what are it's members? Is it possible to change the color of the stroke? Thank you

emigre commented 7 years ago

Dear @apricea4. I never consider of allowing users to draw programmatically but it's an interesting possibility. Yes, you could get the current annotations and set them again later modified or enhanced. That would allow you to programatically draw new shapes, I'd say.

This is the action that creates new annotations on press. As you say it creates an array of two members. This array describes a SVG element: the first item is the type of element (path) and the second its attributes. Then the store stores this array and if you continue drawing it modifies it.

I never considered the possibility of allowing the change of the stroke color, but it is a good idea and I will have it in mind.

The code right now is quite messy and I would like to release a new refactored version with code that I am satisfied with. I did this as a hobby and in a hurry, I would not consider it a great example. If I have the time I'll improve it and perhaps add these features that you suggest. Thanks for the interest.