HISE Logo Forum
    • Categories
    • Register
    • Login

    Setting colors in paint routines. Colours.fromVec4() troubles.

    Scheduled Pinned Locked Moved Newbie League
    2 Posts 1 Posters 67 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • hujackusH
      hujackus
      last edited by

      I'm having trouble debugging my paint routine code. I have some panels that share colors and I was planning using a few arrays and/or color constants. I had an implementation that worked sometimes, but if I changed the method of storage, the panels wouldn't draw correctly.

      So I set up a test to see what methods work and which one don't. In the following snippet there are 9 panels and only 5 render correctly.

      I think I have a misunderstanding about Colours.fromVec4() causing the missing panels. What I'm doing wrong?

      HiseSnippet 1144.3ocsX1uahaDD.ecRb6EZQpmz8.Xc+E4DJx1w.FE01PHIsndgPgzndJ5Tzl0qgUwrKxd4xgNcR2yPeh5iTeCZ20qAaR.eAJwhO79wryuY1AuyPmPFBGEwBAZEtbxHLP6606MgxGzb.jPAsNAn8c5MnjgPNgQAGOYDLJB6Azz19WjSPa2c.wW+yOeLL.RQ3zt.fqXDD9sjgDdZucN52HAAmA8vWRFlY1NG0BwnMYArwBX1V2DLBhtC1G2FJm1V5feEFM.n8FcOKGKeWDrpqkiMBY6VytdMDF56iqZUoliquiODYZCz9lS8HbVXONjii.Z6bLyaRuAr6oJEbEIhba.V1vBzSnYU2mwB7jlnrWPyAj.uNS8RQ.wpzI0mssxm8J8yIdjY8m569g3ALRkHqCTaq4wa64vyJKdlYvaAHokAocTH8R8dnPxHd5Hp8xVTNNT3dvyghZtfs9quUuISLCJe+gv6vmEJZLShR1llkMrpXVXuCKTrfX2JhazARwAVF+nwT45i4MYCGwnhFkdsZ3Wu2gEKntc+HLuiv8v6xFyITbI+wTjL1pT+8JV3SEKXHt5KmkJTnj5qn8ue.gikqiZB9hfntXDuz0lkMKaKe8d4neVvVVzryGMaAZISu4Es6c4MMu3sWzUHi4G88MMkuOTQtcdjW3SOl6zkSnh7f9QLeP9Lefj49AragAFpujpLbFzRrSf9fUD5LK2pBsS9P6Hg9CvPCw6r3p.NAWmUD2oq0pxZk7YsxBCJtoQ2tMdmPxqq5TV8RZ.uOg8JeE12UZ7nXEqBn8CYCuBibJ8HcLybRsTzpZhUy2Dqt3XnFggvIRSTZYkUeLmUVcssxGpEIu+usxZ4ak0jVo5tmB2vkX4K2nfahsJ27MB2znQjz6EMkR0CnhgzM9Z5lj6J9yH0xdcLbqD40ym75KNHycQdRgE4H+AU5GBW+zcu5q+iwbeB1TQwoYSWPCFsMiiufVJNrnvmKX7vg78W3XRGQHKH.GtvgkY6DlmfkniGdKNrr3IjAiwyln3D84SSPe4oIjMKFjZeIyDYzVTB+hQX5xxsAjrYJt6OZcBjCk4VjzmXdivgbhDAsSvePjYmJSic0OAGcGmMRb6rH.QtW73QKNMOD49HfHx13E5pLA.eLM4ue5nIYyD7dhGWjpmt1qDMGfI8Gvm1BrBpvNiJ9xu+rnhCxphqeVTgSFU7229rnhJKcun8lREUW5dwFSE0V5dwFSEtKcuXioh5Kcu3c4phGWBfn3Cl23.He9JRj0skLvCKoSlpOMhvmjsttMVYJOUDeodGBGMXwLt0BXT7TpmCFSJtqn9ohJKQ7T.2Q+r+74oRNf57s9mC4gDQbfd6wC6INQCgEZmJhNjO+WaKYDkpsorszCzCS8ha7uhqjAsjs0RFzZ5ffgPTH6Fj5TGY4iuHtGASz3Rs2U+bYaCKP7IQY8yCEUydCBM+R8HAsWWAOXcEzYcErx5JX00UvZqqftecAk+YCMFyYI+aM.v4cNM9XbMsSoPQDXbzJ3+.mnq8h.
      

      Check out the music of Conway's Game of Life - https://www.youtube.com/@hujackus
      ConwayMatrix - http://hujackus.altervista.org/conwaymatrix/

      1 Reply Last reply Reply Quote 0
      • hujackusH
        hujackus
        last edited by

        I added another test panel and I think I figured it out.

        const Panel10 = Content.getComponent("Panel10");
        const colorConst10 = 0xffddbbaa;
        Panel10.setPaintRoutine(function(g)
        {
        	var vec4 = Colours.toVec4(colorConst10);
        	var c = Colours.fromVec4(vec4);
        
        Console.print(colorConst10); //4292721578
        Console.print(vec4);         //[Array]
        Console.print(trace(vec4));  //[0.8666666746139526,0.7333333492279053,0.6666666865348816,1.0]
        Console.print(c);            //-2245718
        
            g.setColour(c);
            g.fillRect([0,0,20,20]);
        });
        

        The thing that I was getting wrong this whole time was that the vec4 array contains normalized RGB components. I thought the problem was that the colors were out of scope or something.

        Check out the music of Conway's Game of Life - https://www.youtube.com/@hujackus
        ConwayMatrix - http://hujackus.altervista.org/conwaymatrix/

        1 Reply Last reply Reply Quote 1
        • First post
          Last post

        19

        Online

        1.7k

        Users

        11.8k

        Topics

        102.6k

        Posts