Welcome to TalkGraphics.com
Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Drag and Drop

  1. #11
    Join Date
    Mar 2009
    Posts
    4,504

    Default Re: Drag and Drop

    Nice approach with the color wheel, Acorn.

  2. #12
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,966

    Default Re: Drag and Drop

    The main problem with doing it the way suggested so far is that it can very quickly become a highly multi-layered file.

    For example 23 colours x 5 shapes would need 115 layers

    The link below leads to an all Xara created animation with 20 colours (fills) x 10 shapes. This would require 200 layers in the suggested method but it only has 30 layers in this example.

    LINK
    Egg

    Minis Forum UM780XTX AMD Ryzen7 7840HS with AMD Radeon 780M Graphics + 32 GB Ram + MSI Optix Mag321 Curv monitor
    + 1Tb SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  3. #13
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    927

    Default Re: Drag and Drop

    Is javascript really not an option even if simple? Otherwise check out this.
    Attached Files Attached Files

  4. #14
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,966

    Default Re: Drag and Drop

    Nice solution siran. Very simple to add more shape and colours.
    Egg

    Minis Forum UM780XTX AMD Ryzen7 7840HS with AMD Radeon 780M Graphics + 32 GB Ram + MSI Optix Mag321 Curv monitor
    + 1Tb SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  5. #15
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,950

    Default Re: Drag and Drop

    siran, I like it but the grouping of a shape and its cut-out and the use of Names needs to be explained.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  6. #16
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,966

    Default Re: Drag and Drop

    One of the tings I find strange is that you can drag one 'colourtarget' onto another 'colourtarget' and it changes colour.
    Egg

    Minis Forum UM780XTX AMD Ryzen7 7840HS with AMD Radeon 780M Graphics + 32 GB Ram + MSI Optix Mag321 Curv monitor
    + 1Tb SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  7. #17
    Join Date
    Mar 2009
    Posts
    4,504

    Default Re: Drag and Drop

    Quote Originally Posted by Acorn View Post
    siran, I like it but the grouping of a shape and its cut-out and the use of Names needs to be explained.
    Yes, tell us how you did this!

  8. #18
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    927

    Default Re: Drag and Drop

    Egg, that is because images are draggable by default. Would you like to prevent that? If so do a little code change
    Code:
    function dragStartEvt(e) {if(e.target.className.indexOf("coloursource")>=0){e.dataTransfer.setData("text", e.target.style.backgroundColor);}}
    function dropEvt(e) {e.preventDefault();if(e.target.className.indexOf("colourtarget")>=0){var c=e.dataTransfer.getData("text");if(c)e.target.style.backgroundColor=c;}}
    Boy, this example is based on the htmlclass name I learned from Acorn. And it uses a little trick on the shapes. The shapes themselves are the transparent part of exported image. So when setting the background colour of the image it has the effect of displaying a coloured shape. So in this case the images are groups of white rectangle from which the shape was subtracted with a transparent copy of the shape with a black outline added, so that you can see the outlines.
    These groups have been given the name htmlclass=colourtarget so that the code can identify them.
    The source colour squares have been given the name htmlclass=coloursource so that the code can identify them. They are made draggable during startup. Additionally three event handlers are registered which do the copying of the coulour. Have a look at the page body code. There are a lot of examples on the web how that can be done. Search for: html drag and drop
    Did I miss something? Please ask if so.

  9. #19
    Join Date
    Mar 2009
    Posts
    4,504

    Default Re: Drag and Drop

    Thanks Siran. At first I didn't get that it was about a drag & drop routine. Clever use of the shapes.

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •