Assign a random colour to each particle?

  • ChemGuy
    4th Aug 2014 Member 0 Permalink

    Hello.

     

    I was wondering how to make a script (graphics function, perhaps?) that would assign a random colour to each particle of some element, out of a specified set.

    I've searched the forum, but I wasn't able to find something like this exactly.

    I also looked at the source for QRTZ/PQRT, and found out it's somehow dependent on the TMP2 value. This would be the effect I'm looking for, making the colour brighter or darker for each particle in a random way.

     

    Could this be achieved through Lua scripting?

  • PTuniverse
    4th Aug 2014 Member 0 Permalink

    Check out TRON. Maybe that will help you. It's also dependent on TMP but well, you know.

  • jenn4
    4th Aug 2014 Member 0 Permalink
    You take the first pixel; x0,y0, generate three random numbers between 1 and 255, assign the numbers as the RBG decoration color for the particle (if it's not NONE), and move to the next particle; x1, y0 and repeat for all the pixels.
  • QuentinADay
    4th Aug 2014 Member 0 Permalink

    I'm not sure if this helps in any way but I was just messing around and did this: 

     

    local function glow(i, colr, colg, colb)
    a = math.random(1,255)
    b = math.random(1,255)
    c = math.random(1,255)
    d = math.random(1,255)
    e = math.random(1,255)
    f = math.random(1,255)
    g = math.random(1,255)
    h = math.random(1,255)
    return 1,0x00000001,a,b,c,d,e,f,g,h
    end
    tpt.graphics_func(glow,elements.DEFAULT_PT_IRON)

     

  • ChemGuy
    5th Aug 2014 Member 0 Permalink

    @QuentinADay (View Post)

     While the effect is nice, would it be possible to make the set colour constant to the particle? Like it is with QRTZ, there is a random colour assigned, which persists and doesn't change for the given particle.

  • QuentinADay
    6th Aug 2014 Member 0 Permalink

    I really have no clue... I'll mess around with it and see if i figure it out

  • h4zardz1
    6th Aug 2014 Member 0 Permalink
    @ChemGuy (View Post)
    turn sand particle on.
  • iamdumb
    6th Aug 2014 Member 0 Permalink

    @ChemGuy (View Post)

     

    You'd have to change it in the constructor for the particle... I think. 

    http://pastebin.com/tn6S8ciB

    I don't know if it works. 

    Edited once by iamdumb. Last: 6th Aug 2014
  • ChemGuy
    7th Aug 2014 Member 0 Permalink

    Well, I guess I'm gonna have to leave it for now and get back to it if I would ever be making a source-based mod.

    @QuentinADay (View Post)

     No need to trouble yourself, I was just wondering if there was an easy way of achieving this through Lua, but it appears there isn't.

    @h4zardz1 (View Post)

    Yes, this is exactly the effect I want, but I'd like it to be native to the element itself, and not be a decor layer or option switched on by the user.

     

    Thanks for the help, anyways.

    Edited once by ChemGuy. Last: 6th Aug 2014
  • PTuniverse
    7th Aug 2014 Member 0 Permalink

    Does anyone here have a sample of the code used in TRON? Because every time you make a particle of it, it would randomly generate its own color (TMP-based). Is that what you want?

     

    Maybe if you want it to look less weird in debug mode, it should be using TMP2 instead so that people who always like to have it turned on don't get bothered by that huge random number sitting in the TMP variable.

     

    And modifications so that it also covers the colors you usually don't find in TRON?

     

    TRON is so neglected.

    Edited 4 times by PTuniverse. Last: 7th Aug 2014