CLEO Help rezoll

CLEO related
Status
Not open for further replies.

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
RE: [HELP] Fast Rainbow Color

Stickey said:
Hello! I maked a Rainbow Hud in CLEO but the colors are change slow.Can I make it faster? (Sorry for bad english)

First if u wanna get help ... show code...
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
RE: [HELP] Fast Rainbow Color

Etc..
not u maked it , so stop lie... , u just using..

Anyway... , u can use @monday snippet...

edit to any value.:
[font=Monaco, Consolas, Courier, monospace]speed_step 1[/font]


PHP:
{$CLEO}
0000: NOP
repeat
    wait 50
until 0AFA:  is_samp_available

31@ = 0  // hue 0 - 359 (variable required to keep track of the colour)
0B34: "rbhud" @ColorLoop   

while true
wait 0

    call @ShiftColorHue 3 speed_step 1 direction 1 hue_var 31@ _returned_hue_var 31@ // it increases/decreases 31@ variable between 0-359
    call @GetCLRfromHSV 3 hue 31@ saturation 1.0 value 1.0 _returnedColor 1@ 2@ 3@  

    if 0@ == TRUE
    then       
        0B67: render a 0xFF r 1@ g 2@ b 3@ to_argb 4@
        0A8C: write_memory 0xBAB22C size 4 value 4@ virtual_protect 0 
        0A8C: write_memory 0xBAB230 size 4 value 4@ virtual_protect 0 
        0A8C: write_memory 0xBAB238 size 4 value 4@ virtual_protect 0  
        0A8C: write_memory 0xBAB240 size 4 value 4@ virtual_protect 0  
        0A8C: write_memory 0xBAB244 size 4 value 4@ virtual_protect 0  
        0A8C: write_memory 0xBAB24C size 4 value 4@ virtual_protect 0  
        0A8C: write_memory 0xBAB258 size 4 value 4@ virtual_protect 0  
        0A8C: write_memory 0x005507C0 size 4 value 4@ virtual_protect 0  

        for 5@ = 0 to 9400
        if 0C5D: samp textdraw 5@  is_exists
        then
            0C5C: samp textdraw 5@ get_letter_size 6@ 7@ color -1
            0C52: samp textdraw 5@ set_letter_size 6@ 7@ color 4@  
        end
        end
    end
    
end


:RYB_to_RGB_GetSingleClr
{
    0@ - R
    1@ - Y
    2@ - B
    
    3@ - front_up_left : [1, 1, 0],
    4@ - front_up_right: [1, 0.5, 0],
    5@ - "front_down_left": [1, 1, 1], 
    6@ - "front_down_right": [1, 0, 0],
    7@ - "back_up_left": [0, 0.66, 0.2],
    8@ - "back_up_right": [0.2, 0.094, 0], 
    9@ - "back_down_left": [0.163, 0.373, 0.6], 
    10@ - "back_down_right": [0.5, 0.0, 0.5], 
}

/*
3@ *= 255.0
4@ *= 255.0
5@ *= 255.0
6@ *= 255.0
7@ *= 255.0
8@ *= 255.0
9@ *= 255.0
10@ *= 255.0
*/
//chatmsg "%.2f %.2f %.2f" -1 0@ 1@ 2@
call @Interpolate 5 val 0@ range 0.0 255.0 front_up_left 3@ front_up_right 4@ _side_front_up 11@
call @Interpolate 5 val 0@ range 0.0 255.0 front_down_left 5@ front_down_right 6@ _side_front_down 12@
call @Interpolate 5 val 0@ range 0.0 255.0 back_up_left 7@ back_up_right 8@ _side_back_up 13@
call @Interpolate 5 val 0@ range 0.0 255.0 back_down_left 9@ back_down_right 10@ _side_back_down 14@

//chatmsg "%.2f %.2f %.2f %.2f" -1 11@ 12@ 13@ 14@

call @Interpolate 5 val 1@ range 0.0 255.0 side_front_down 12@ side_front_up 11@ _side_vert_front 15@
call @Interpolate 5 val 1@ range 0.0 255.0 side_back_down 14@ side_back_up 13@ _side_vert_back 16@

call @Interpolate 5 val 2@ range 0.0 255.0 side_vert_front 15@ side_vert_back 16@ _returnedValue 17@

/*
sideways_front_up = Interpolate(r, [0,1], [
    RYB_RGB_cube["front_up_left"][i],
    RYB_RGB_cube["front_up_right"][i]
    ])

sideways_front_down = Interpolate(r, [0,1], [
    RYB_RGB_cube["front_down_left"][i],
    RYB_RGB_cube["front_down_right"][i]
    ])

sideways_back_up = Interpolate(r, [0,1], [
    RYB_RGB_cube["back_up_left"][i],
    RYB_RGB_cube["back_up_right"][i]
    ])

sideways_back_down = Interpolate(r, [0,1], [
    RYB_RGB_cube["back_down_left"][i],
    RYB_RGB_cube["back_down_right"][i]
    ])
*/

//17@ *= 255.0
0092: 17@ = float 17@ to_integer
ret 1 17@

:RYB_to_RGB
{
    0@ 1@ 2@ - Red, Yellow, Blue (integers 0-255)
   More info and python example: https://github.com/michalmonday/RGB_rainbowLoop/blob/master/RYB_RGB_conversion_rainbowLoop.py
}
0093: 0@ = integer 0@ to_float
0093: 1@ = integer 1@ to_float
0093: 2@ = integer 2@ to_float

call @RYB_to_RGB_GetSingleClr 11 RYB 0@ 1@ 2@ interpolation_cube_corners 255.0 255.0 255.0 255.0 0.0 51.0 41.565 127.5 _returnedRed 21@
call @RYB_to_RGB_GetSingleClr 11 RYB 0@ 1@ 2@ interpolation_cube_corners 255.0 127.5 255.0 0.0 168.3 23.97 95.115 0.0 _returnedGreen 22@
call @RYB_to_RGB_GetSingleClr 11 RYB 0@ 1@ 2@ interpolation_cube_corners 0.0 0.0 255.0 0.0 51.0 0.0 153.0 127.5 _returnedBlue 23@

ret 3 21@ 22@ 23@ 

:Interpolate
{
    All floats:
    0@ - value
    1@ - Lower border of initial range
    2@ - Higher border of initial range
    3@ - Lower border of desired range
    4@ - Higher border of desired range
}
0087: 31@ = 2@ // float
0063: 31@ -= 1@  // (s[1] - s[0])
0063: 0@ -= 1@ // (val - s[0])
0087: 30@ = 4@ // float
0063: 30@ -= 3@ // (s2[1] - s2[0])
006B: 30@ *= 0@  // (s2[1] - s2[0]) * (val - s[0])
0073: 30@ /= 31@ // (s2[1] - s2[0]) * (val - s[0]) / (s[1] - s[0])
005B: 3@ += 30@  // (float)
ret 1 3@



//call @ShiftColor 2 speed_step 3 direction 1 variable_keeping_track 31@
:ShiftColorHue
{
    0@ - speed_step - how fast the color change occurs
    1@ - direction (1-rgb order, 2-reversed order)
    2@ - hue variable which needs to be dedicated for this snippet (it's actually the only variable that is required in external code for this snippet)
}
if 1@ == 1
then
005A: 2@ += 0@  // (int)
    if 2@ > 359
    then
    2@ = 0
    end
end

if 1@ == 2
then
0062: 2@ -= 0@  // (int)
    if 001B:   0 > 2@
    then
    2@ = 359
    end
end
ret 1 2@ 

//call @GetRGBfromHSV 3 hue 31@ saturation 1.0 value 1.0 _returnedRGB 1@ 2@ 3@
:GetCLRfromHSV
{
    0@ - Hue (0 - 360 int)
    1@ - Saturation  (0.0 - 1.0 float)
    2@ - Value (0.0 - 1.0 float)
}
0085: 25@ = 0@ // hue copy
0093: 0@ = integer 0@ to_float

//C = value * saturation
0087: 31@ = 1@ // C
006B: 31@ *= 2@  // C

//X = C * (1.0 - abs((hue/60.0)%2 - 1.0))
0087: 30@ = 0@ // hue
30@ /= 60.0 // (hue/60.0)

if and  // fix for the bugged 0b14 (when float is used, idk if it happens with int too)
30@ >= 2.0 
0023:   4.0 > 30@
then
30@ -= 2.0
else
    if and 
    30@ >= 4.0 
    0023:   6.0 > 30@
    then
    30@ -= 4.0 
    else
        if and 
        30@ >= 6.0 
        0023:   8.0 > 30@
        then
        30@ -= 6.0 
        end
    end   
end

0B14: 30@ = 30@ MOD 2.0 // sampfuncs modulo function is probably not working for numbers that are at least twice as big, or because it's float... idk
//printf "X= %.2f" 1000 30@
30@ -= 1.0
0097: make 30@ absolute_float
29@ = 1.0
0063: 29@ -= 30@ // (1.0 - abs((hue/60.0)%2 - 1.0))
0087: 30@ = 31@ // X = C *
006B: 30@ *= 29@ // X = C * (1.0 - abs((hue/60.0)%2 - 1.0))

//m = value - C
0087: 29@ = 2@
0063: 29@ -= 31@  // m = value - C

// C = 31@
// X = 30@
// m = 29@

//printf "C= %.2f X= %.2f m= %.2f" 1000 31@ 30@ 29@
 
//sectionList (0 - 0, C - 1, X - 2)
alloc 28@ 100
0085: 27@ = 28@ // (int)
0085: 26@ = 28@ // (int)

//[C, X, 0],
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4

//[X, C, 0],
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4

//[0, C, X],
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4

//[0, X, C],
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4

//[X, 0, C],
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4

//[C, 0, X],
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0


//section = sectionList[hue/60]
25@ /= 60 // hue/60
25@ *= 12 
005A: 27@ += 25@  // (int)
0A8D: 21@ = read_memory 27@ size 4 virtual_protect 0
27@ += 4
0A8D: 22@ = read_memory 27@ size 4 virtual_protect 0
27@ += 4
0A8D: 23@ = read_memory 27@ size 4 virtual_protect 0

// 21@ 22@ 23@ have now values from 0 to 2 (they're just indicators)
0093: 21@ = integer 21@ to_float
0093: 22@ = integer 22@ to_float
0093: 23@ = integer 23@ to_float
call @AssignHSVSectionValue 3 21@ 31@ 30@ _ret 21@
call @AssignHSVSectionValue 3 22@ 31@ 30@ _ret 22@
call @AssignHSVSectionValue 3 23@ 31@ 30@ _ret 23@

005A: 21@ += 29@  // (int)
005A: 22@ += 29@  // (int)
005A: 23@ += 29@  // (int)
21@ *= 255.0
22@ *= 255.0
23@ *= 255.0
0092: 21@ = float 21@ to_integer
0092: 22@ = float 22@ to_integer
0092: 23@ = float 23@ to_integer

free 26@

ret 3 21@ 22@ 23@

:AssignHSVSectionValue
{
    0@ - indicator_1
    1@ - val_C
    2@ - val_X
}
if 0@ == 0.0
then
ret 1 0.0
else
    if 0@ == 1.0
    then
    ret 1 1@
    else
        if 0@ == 2.0
        then
        ret 1 2@
        end
    end
end
ret 1 0.0

:ColorLoop
0B12: 0@ = 0@ XOR 1
if 0@ == TRUE
then
printf "~Y~Rainbow Hud ~G~ON" 1300
else
printf "~Y~Rainbow Hud ~R~OFF" 1300
end
cmdret
 
Status
Not open for further replies.
Top