<canvas>
element;ImageMARK
object passing to its constructor your canvas element and cofiguration;<canvas id="mycanvas" width="800" height="600"></canvas> <script src="http://izhuk.com/mark/2/"></script> <script> var imagemark = new ImageMARK(document.getElementById('mycanvas'),config); imagemark.loadBackgroundImage('myimage.jpg'); </script>
Optionally you can display cliparts that users can insert in their comments, for example
imagemark.setCliparts( ['dir/img1.gif', 'dir/img2.gif' 'dir/img3.gif', 'dir/img4.gif'], 4, 1);
To save the user's comments (annotation) call getAnnotation()
.
This method returns data as a string which you can save on the server and load later for editing.
To display an annotation saved before call method setAnnotation(annotation)
If you want to save the annotation in a raster image (e.g. PNG or JPEG)
use method exportImage()
which returns the image in Data URL format.
But remember that raster images can't be edited in ImageMARK,
you can only draw comments on top of them.
ImageMARK(canvas,config) |
Creates an instance of ImageMARK.canvas - canvas element to display ImagaMARKconfig - configuration parameters
|
||||||||
loadBackgroundImage(url) |
Loads the image to be commented.url - image's url |
||||||||
setSolidBackground(width,height,color) |
Specifies to use solid background instead of image. Can be used to draw without the background image.width - background widthheight - background heightcolor - background color specified as #RRGGBB string
|
||||||||
setCliparts(urls,rows,cols) |
Sets cliparts for insertion in the annotationurls - array of urls of clipart imagesrows - number of rows to arrange the clipartscols - number of columns to arrange the cliparts
|
||||||||
getAnnotation() |
Returns annotation data (as a string) which can be saved and loaded later. |
||||||||
setAnnotation(data) |
Sets the annotation data obtained earlier from getAnnotation() data - annotation data
|
||||||||
loadAnnotation(url) |
Loads annotation data from the serverurl - URL of the annotation data
|
||||||||
exportImage(options) |
Returns the annotation as a raster image. The image is returned in Data URL format, for example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAA... The parameter options is an object where the following fields are recognized:
|
||||||||
isEmpty() |
Returns true if current annotation is empty.
|
||||||||
isChanged() |
Returns true if the annotation has been changed by the user.
|
An example of configuration file is included in the package.