Image selection techniques to be tasted

Source: Internet
Author: User

Our image selection technology has finally achieved a phased breakthrough today!

Is the result of common efforts, this technology can be achieved, in the work area, the picture frame selection, finished can be the starting point, the end point coordinates display, and, the coordinates of the point can be easily manually modified, after the change, press OK, the box will also change corresponding changes. Some of the code is as follows:

1 getting the mouse position

function Movetomouseloc (e) {if (Ns4 | | ns6) {Curpositionx = E.pagexcurpositiony = E.pagey;} else {Curpositionx = Event.x + Document.body.scrollleft;curpositiony = Event.y + document.documentElement.scrollTop;} return true;}

2 Mouse down Events

function OnMouseDown (e) {if(Resizing = =true)            return true; Resizing=true; if(divsx<=curpositionx&&curpositionx<=Divex) {            if(divsy<=curpositiony&&curpositiony<=Divey) {Startpointx=Curpositionx; Startpointy=Curpositiony; }        }            if(curpositionx<divsx) {Startpointx=DIVSX; }            if(curpositionx>Divex) {Startpointx=Divex; }            if(divsy>curpositiony) {Startpointy=Divsy; }            if(curpositiony>Divey) {Startpointy=Divey;                        } drawborder (); }

3 Mouse Bounce Events

function OnMouseUp (e) {if(resizing) {drawborder (); Resizing=false; }            if(curpositionx<divsx) {Endpointx=DIVSX; }            if(curpositionx>Divex) {Endpointx=Divex; }            if(divsy>curpositiony) {Endpointy=Divsy; }            if(curpositiony>Divey) {Endpointy=Divey; }                                            if(Startpointx > && Startpointx < 400)                $("#startPointX"). Val (Startpointx); if(Startpointy > && startpointy < 600)                $("#startPointY"). Val (Startpointy); if(Endpointx > && Endpointx < 400)                $("#endPointX"). Val (Endpointx); if(Endpointy > && endpointy < 600)                $("#endPointY"). Val (Endpointy); }

4 Draw Wireframe

function Drawborder () {if(divsx<=curpositionx&&curpositionx<=Divex) {            if(divsy<=curpositiony&&curpositiony<=Divey) {Endpointx=Curpositionx; Endpointy=Curpositiony; With (Border.style) {width= Math.Abs (Startpointx-endpointx) + "px"; Height= Math.Abs (Startpointy-endpointy) + "px"; Left= Math.min (Startpointx, Endpointx) + "px"; Top= Math.min (Startpointy, Endpointy) + "px"; }            }        }                                    }

These are some of the technical implementations of the code.

Is the scene that the image chooses realizes.

Image selection techniques to be tasted

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.