How can i create a float array on LL?

How can i create a float array on LL?

I know, it’s the stupidest question i ever made here… But I can’t find out a way!

I tried different classic java syntaxes, but it always shows up “Syntax Error”

]]>

23 Commentsto How can i create a float array on LL?

  1. Anonymous says:

    < ![CDATA[

    You can do something like that :



    var tab = [0.5, 1.5, 2.5, 3.75];



    alert(“tab length = ” + tab.length); // show 4


    alert(tab[2]); //show 2.5

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Benoît de Chezelles I’ll try

    ]]>

  3. Anonymous says:

    < ![CDATA[

    ok it seems to work, but i need a blank array for my purposes (HSV)

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Lukas Morawietz , TrianguloY ?

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Simone Boccuzzi its JavaScript not Java. var arr = new Array(); or var arr = []; should work fine. You can then add values with arr.push(value);.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    James Coyle oh, it’s right xD


    I tried and your method works well, but i have another little problem:


    I must use a blank float array with lenght 3


    so i used this: new Array(3);


    but it is not defined as float so it doesn’t work with the method colorToHSV(color, float array).


    How can i do? 

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Maybe just : var arr = [ 0.0, 0.0, 0.0 ];


    (didn’t tried)

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Benoît de Chezelles i already tried, but it must be a blank float array

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Simone Boccuzzi That isn’t possible AFAIK. Do you have a link to the documentation of that method?

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Simone Boccuzzi I tried any research possible, & I didn’t found any possible way to do this with our javascript’s java wrapper…

    ]]>

  11. Anonymous says:

    < ![CDATA[

    James Coyle link: http://developer.android.com/reference/android/graphics/Color.html the methods are “colorToHSV()” or “RGBToHSV()”



    Benoît de Chezelles​ 😭

    ]]>

  12. Anonymous says:

    < ![CDATA[

    There is a way. Lukas Morawietz​​​ asked it and Pierre Hébert​​​ provided the solution.



    Unfortunately it was long time ago and don’t have the time to search for it, sorry.



    You need to create a java array binding its class and using ‘new’

    ]]>

  13. Anonymous says:

    < ![CDATA[

    TrianguloY I tried to search for a way via a new array, etc, like you say, but I didn’t found anything..

    ]]>

  14. Anonymous says:

    < ![CDATA[

    (16-october-2014 Lukas post)



    Didn’t tested, but try this:



    LL.bindClass(“java.lang.reflect.Array”);


    LL.bindClass(“java.lang.Float”);


    var a = Array.newInstance(Float.TYPE, 5);//5 is the length of the array

    ]]>

  15. Anonymous says:

    < ![CDATA[

    Guys, I have a wonderful news 🙌


    Yesterday I was so afflicted that I tried to do something crazy…


    I completely revamped the “colorToHSV()” android method to make it works perfectly with LL java wrapper (finally my math skills have been useful).


    I think I will share it later here by the way. (maybe)



    TrianguloY​​ I tried your way and it works the same, I guess that someone have to put this on script.api to avoid future problem like this one.



    I thank you all for your patience!! 😁

    ]]>

  16. Anonymous says:

    < ![CDATA[

    Rhino is pretty intelligent with choosing the correct method. But an empty javascript Array has no type, so it is impossible to detect the correct method. You have to tell it which method to use:



    Color[“HSVToColor(float[])”](new Array(3));

    ]]>

  17. Anonymous says:

    < ![CDATA[

    Lukas Morawietz​ does this works???

    ]]>

  18. Anonymous says:

    < ![CDATA[

    Yes.

    ]]>

  19. Anonymous says:

    < ![CDATA[

    How? Why?

    ]]>

  20. Anonymous says:

    < ![CDATA[

    What’s the difference with Color.HSVToColor(new Array(3));

    ]]>

  21. Anonymous says:

    < ![CDATA[

    the difference is the “float[]”. It tells Rhino which specific method is targeted and as a result which conversion from javascript to Java should be used.



    Color.HSVToColor(new Array(3)) ends up as the following java call : Color.HSVToColor(java.lang.Object[3]);


    which is obviously not a legal call.

    ]]>

  22. Anonymous says:

    < ![CDATA[

    Oooh thanks that’s great!



    What’s Rhino? The java to javascript engine?

    ]]>

  23. Anonymous says:

    < ![CDATA[

    Benoît de Chezelles


    exactly.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *