Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Advise please

  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Advise please

    Hello I am currently learning new things web wise one of them being java , I have been working with fabric.js and I have a free draw mode and want to enable color change when click button I have attached my html and script please can you help me and explain what I am doing wrong if possible.

    html:

    <button id="freedraw" class="btn btn-info">Enter drawing mode</button>
    <br>

    <p>Stroke Color:</p> <input id="freedraw" class="color{pickerClosable:true,hash:true}"
    onchange="freedrawcolor('#'+this.color)" value="000000" style="width:60px;">




    js:

    $(function(){

    canvas.freeDrawingLineWidth = 15;



    document.getElementById('freedraw').addEventListener('click', function () {
    canvas.isDrawingMode = !canvas.isDrawingMode;

    function freedrawcolor(a)
    {var b=canvas.getActiveObject();b&&"freedraw"===b.type&&(this.color=a,canvas.renderAll())}

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    You said you are learning Java and then have posted some JavaScript code. Which of the two is it you are learning - Java or JavaScript?

    Java and JavaScript are as different as Ham and Hamsters
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    bigmacca80 (05-18-2013)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,857
    Thanks
    78
    Thanked 4,417 Times in 4,382 Posts
    You are missing a right brace and right parenthesis.

    I find it easier to see the braces if I move the arguments to addEventListener to separate lines, thus:
    Code:
    document.getElementById('freedraw').addEventListener(
        'click', 
        function () {
            canvas.isDrawingMode = !canvas.isDrawingMode;
        } 
    );
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    bigmacca80 (05-18-2013)

  • #4
    New to the CF scene
    Join Date
    May 2013
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    my mistake

    See I told you I was new its Javascript. Again sorry to cause confusion. OK so I already got the free draw mode to work but its the color change it just does nothing other than bring up my swatch board lets me pick a color but no change to the stroke fill . Please help

  • #5
    New to the CF scene
    Join Date
    May 2013
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    doh

    Quote Originally Posted by felgall View Post
    You said you are learning Java and then have posted some JavaScript code. Which of the two is it you are learning - Java or JavaScript?

    Java and JavaScript are as different as Ham and Hamsters
    See I told you I was new its Javascript. Again sorry to cause confusion. OK so I already got the free draw mode to work but its the color change it just does nothing other than bring up my swatch board lets me pick a color but no change to the stroke fill . Please help

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,857
    Thanks
    78
    Thanked 4,417 Times in 4,382 Posts
    Can you show this live? Give us a URL?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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