Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Change and read individual pixel colours?

    Coding
    7
    15
    491
    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.
    • D
      DaddyJDM last edited by

      What about making an array of pixel data (rgb values), and then using uploadImage to turn that array into an image?

      D 1 Reply Last reply Reply Quote 1
      • D
        daddy-devito166 @DaddyJDM last edited by

        @DaddyJDM
        I’ll give that a go. Currently made an array containing all pixel positions and colours. will try to update the colours on the fly with that. Gonna make Langton ant to give it a test

        1 Reply Last reply Reply Quote 0
        • Martin
          Martin Fuze Team last edited by

          uploadImage() wouldn't really be suitable for cases where you want stuff plotted by algorithms that are dynnamically changing which is what I assume we are talking about here so yes, plot is the way to go (or box, or circle perhaps?)

          Sadly, no you cannot read pixels. So you cannot get the colour at screen position X / Y.

          Also just something to be aware of: uploadImage() has a memory leak in the current retail version but it is fixed in the next version.

          D 1 Reply Last reply Reply Quote 4
          • D
            daddy-devito166 @Martin last edited by

            @Martin
            Cheers, I’ve noticed an error that keeps getting thrown back. When trying to use a screen resolution larger than 160x100 while storing every pixels x, y and colour in a struct array I get a stack overflow. I know storing 3 bits of information on 900000+ array elements is pushing it and wasn’t expecting full 1280x720 but is a stack overflow expected for a resolution as low as 200x200?

            1 Reply Last reply Reply Quote 0
            • Martin
              Martin Fuze Team last edited by

              Can you show / type the code please? The simple answer is no, I would not expect problems with 200x200 but I'd like to see whats going on really.

              D 1 Reply Last reply Reply Quote 0
              • D
                daddy-devito166 @Martin last edited by

                @Martin
                setmode(160,100)
                Struct pix
                Int x
                Int y
                String color
                Endstruct

                pix pixels[gheight()*gwidth()]

                This throws up a stack overflow on any values larger or just freezes meaning I have to restart FUZE

                R 1 Reply Last reply Reply Quote 0
                • Martin
                  Martin Fuze Team last edited by

                  Thank you - I'll investigate when I get a moment

                  1 Reply Last reply Reply Quote 1
                  • R
                    Richard F @daddy-devito166 last edited by

                    @daddy-devito166
                    Probably not the cause of your problem, but shouldn't colour be stored as a vector rather than a string. When you use the colour names, they just refer to the corresponding rbga vector.

                    D 1 Reply Last reply Reply Quote 0
                    • D
                      daddy-devito166 @Richard last edited by

                      @Richard
                      I’ll take a look, the stack overflow always points to that array though

                      1 Reply Last reply Reply Quote 0
                      • Martin
                        Martin Fuze Team last edited by

                        It would also be useful to print(len(pixels)) and print(len(pixels[0])) just to be absolutely sure that gHeight() and gWidth() are returning the values of the new mode - of course they should!

                        The comment about string is valid.

                        Another thing I would try, just to see what happens is if you have 3 separate arrays instead of an array of structs.

                        Please note, these are all debug steps to try and narrow the problem. I won't get to actually try anything on my Switch until later this evening.

                        1 Reply Last reply Reply Quote 0
                        • PickleCatStars
                          PickleCatStars F last edited by

                          Try setting gwidth() and gheight() to variables first and then put those in your array declaration. It’s worth a try!

                          D 1 Reply Last reply Reply Quote 1
                          • D
                            daddy-devito166 @PickleCatStars last edited by

                            @toxibunny
                            Will do! Tbh might drop the full code as the puzzle is getting stranger and stranger and with lowering the res to avoid stack overflows I can’t read error messages anymore!

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