Giter VIP home page Giter VIP logo

openseadragonselection's Introduction

OpenSeadragonSelection

An OpenSeadragon plugin that provides functionality for selecting a rectangular part of an image.

Demo

https://picturae.github.io/openseadragonselection/

Usage

Include dist/openseadragonselection.js after OpenSeadragon in your html. Then after you create a viewer:

var selection = viewer.selection(options);

Then you can alter the selection state with any of these:

selection.enable();
selection.disable();
selection.toggleState();

Options

viewer.selection({
    element:                 null, // html element to use for overlay
    showSelectionControl:    true, // show button to toggle selection mode
    toggleButton:            null, // dom element to use as toggle button
    showConfirmDenyButtons:  true,
    styleConfirmDenyButtons: true,
    returnPixelCoordinates:  true,
    keyboardShortcut:        'c', // key to toggle selection mode
    rect:                    null, // initial selection as an OpenSeadragon.SelectionRect object
    allowRotation:           true, // turn selection rotation on or off as needed
    startRotated:            false, // alternative method for drawing the selection; useful for rotated crops
    startRotatedHeight:      0.1, // only used if startRotated=true; value is relative to image height
    restrictToImage:         false, // true = do not allow any part of the selection to be outside the image
    onSelection:             function(rect) {}, // callback
    prefixUrl:               null, // overwrites OpenSeadragon's option
    navImages:               { // overwrites OpenSeadragon's options
        selection: {
            REST:   'selection_rest.png',
            GROUP:  'selection_grouphover.png',
            HOVER:  'selection_hover.png',
            DOWN:   'selection_pressed.png'
        },
        selectionConfirm: {
            REST:   'selection_confirm_rest.png',
            GROUP:  'selection_confirm_grouphover.png',
            HOVER:  'selection_confirm_hover.png',
            DOWN:   'selection_confirm_pressed.png'
        },
        selectionCancel: {
            REST:   'selection_cancel_rest.png',
            GROUP:  'selection_cancel_grouphover.png',
            HOVER:  'selection_cancel_hover.png',
            DOWN:   'selection_cancel_pressed.png'
        },
    },
    borderStyle: { // overwriteable style defaults
        width:      '1px',
        color:      '#fff'
    },
    handleStyle: {
        top:        '50%',
        left:       '50%',
        width:      '6px',
        height:     '6px',
        margin:     '-4px 0 0 -4px',
        background: '#000',
        border:     '1px solid #ccc'
    },
    cornersStyle: {
        width:      '6px',
        height:     '6px',
        background: '#000',
        border:     '1px solid #ccc'
    }
});

To do

- fix behavior when the viewer itself is rotated
- test/fix with multiple images at once

Fixes

- Now selection can be draw over existing selections, make selection in selection.
To achieve that before you were forced to make a selection outside any other selection and move it over.

openseadragonselection's People

Contributors

mindfreeze avatar dthornley avatar pin0 avatar rparadis avatar ovanderzee avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.