Advertisement
jdelano

Untitled

Mar 21st, 2025
442
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.54 KB | None | 0 0
  1. Private Sub btnConvert_Click()
  2.  
  3.     ' convert the RGB values to HSL using the formula from
  4.     ' from https://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/
  5.    
  6.     Dim redColor As Double
  7.     Dim greenColor As Double
  8.     Dim blueColor As Double
  9.     Dim min As Double
  10.     Dim max As Double
  11.     Dim luminanceValue As Double
  12.     Dim saturationValue As Double
  13.     Dim hueValue As Double
  14.    
  15.     ' convert to 0-1
  16.     redColor = Format(Val(txtR.Text) / 255, "#.#0")
  17.     greenColor = Format(Val(txtG.Text) / 255, "#.#0")
  18.     blueColor = Format(Val(txtB.Text) / 255, "#.#0")
  19.            
  20.     ' find min and max of the three
  21.     min = 2
  22.     If redColor < min Then min = redColor
  23.     If greenColor < min Then min = greenColor
  24.     If blueColor < min Then min = blueColor
  25.    
  26.     max = 0
  27.     If redColor > max Then max = redColor
  28.     If greenColor > max Then max = greenColor
  29.     If blueColor > max Then max = blueColor
  30.    
  31.     ' calculate lumanince value
  32.     luminanceValue = Format((min + max) / 2, "#.#0")
  33.    
  34.     ' calculate saturation value
  35.     If min = max Then
  36.         saturationValue = 0
  37.     Else
  38.         If luminanceValue <= 0.5 Then
  39.             saturationValue = (max - min) / (max + min)
  40.         Else
  41.             saturationValue = (max - min) / (2 - max - min)
  42.         End If
  43.         saturationValue = Format(saturationValue, "#.#0")
  44.     End If
  45.    
  46.     ' calculate hue
  47.     If redColor = max Then hueValue = (greenColor - blueColor) / (max - min)
  48.     If greenColor = max Then hueValue = 2 + (blueColor - redColor) / (max - min)
  49.     If blueColor = max Then hueValue = 4 + (redColor - greenColor) / (max - min)
  50.    
  51.     hueValue = Format(hueValue, "#.#0")
  52.     txtH.Text = Format((hueValue * 60) / 100, "###%")
  53.     txtS.Text = Format(saturationValue, "###%")
  54.     txtL.Text = Format(luminanceValue, "###%")
  55.        
  56. End Sub
  57.  
  58. Private Sub txtB_Change()
  59.     ChangeRGBColor
  60. End Sub
  61.  
  62. Private Sub txtG_Change()
  63.     ChangeRGBColor
  64. End Sub
  65.  
  66. Private Sub txtR_Change()
  67.     ChangeRGBColor
  68. End Sub
  69.  
  70. Private Sub ChangeRGBColor()
  71.  
  72.     Dim redColor As Integer
  73.     Dim greenColor As Integer
  74.     Dim blueColor As Integer
  75.    
  76.     redColor = Val(txtR.Text)
  77.     greenColor = Val(txtG.Text)
  78.     blueColor = Val(txtB.Text)
  79.    
  80.     If redColor > 255 Then redColor = 255
  81.     If greenColor > 255 Then greenColor = 255
  82.     If blueColor > 255 Then blueColor = 255
  83.    
  84.     txtR.Text = redColor
  85.     txtG.Text = greenColor
  86.     txtB.Text = blueColor
  87.  
  88.     lblColor.BackColor = RGB(redColor, greenColor, blueColor)
  89.    
  90. End Sub
  91.  
Tags: rgb HSL
Advertisement
Comments
  • responsive02
    6 days
    # text 2.09 KB | 0 0
    1. https://katfile.com/47dnpxn71ghh/defloration_of_rebecca.mp4.html
    2.  
    3. https://katfile.com/smcxklrxq2bu/t33n_hottie_hippie.mp4.html
    4. https://katfile.com/2m534lsws01y/1yo-_renee_roulette.mp4.html
    5.  
    6. https://katfile.com/1cufobt46nkl/teen_fucked_and_spanked.mp4.html
    7. https://katfile.com/9h0ejv5fyw6d/skinny_teen_squirted_on_a_huge_cock.mp4.html
    8.  
    9. https://katfile.com/2c17vu10m7f0/Xvideos_loving_sex_with_teen.mp4.html
    10. https://katfile.com/21h5dbudizpq/little_puusy.mp4.html
    11.  
    12. https://katfile.com/311arifdnur0/stepdaughter_is_fucked.mp4.html
    13. https://katfile.com/io0wfnl7mdk6/eos__arcel.mp4.html
    14.  
    15. https://katfile.com/khn7888qjnn3/exxxtra_t.mp4.html
    16. https://katfile.com/vzfutxpkkmgk/you_doing_i_am_t.mp4.html
    17.  
    18. https://katfile.com/23eazz88040p/girl_masturbation_pussy.mp4.html
    19. https://katfile.com/m7tkkbbgfy9e/exciting_teenie.mp4.html
    20.  
    21. https://katfile.com/9qs94as6iix4/774442[pt.mp4.html
    22. https://katfile.com/bw4nby0d4hfl/analj.mp4.html
    23. https://katfile.com/7us4r0bsconi/cam_5801.mp4.html
    24. https://katfile.com/36s00ol8nv1q/hot_play_webcam_teen_masturbation_in_front.mp4.html
    25. https://katfile.com/110ld42x6d7w/morning_teen_masturb.mp4.html
    26. https://katfile.com/mjk1qxqefaii/orrga01.MP4.html
    27. https://katfile.com/gon211e3ldm9/orrga02.MOV.html
    28. https://katfile.com/41fuahxsgv9j/orrga3.mp4.html
    29. https://katfile.com/si951brc7wai/teen_cocksucker.mp4.html
    30. https://katfile.com/i6ejhnfmzkmy/VID_201_018.mp4.html
    31. https://katfile.com/fi4x6r4tgkqm/darling_tomoyo_isumi_fucks_a_gu.mp4.html
    32. https://katfile.com/ti4wk9bbnwlr/defloration_t.mp4.html
    33. https://katfile.com/io0wfnl7mdk6/eos__arcel.mp4.html
    34. https://katfile.com/m7tkkbbgfy9e/exciting_teenie.mp4.html
    35. https://katfile.com/khn7888qjnn3/exxxtra_t.mp4.html
    36. https://katfile.com/23eazz88040p/girl_masturbation_pussy.mp4.html
    37. https://katfile.com/110ld42x6d7w/morning_teen_masturb.mp4.html
    38. https://katfile.com/dy8t4x1qh63k/my_best_friend_was_a_virgin.mp4.html
    39. https://katfile.com/311arifdnur0/stepdaughter_is_fucked.mp4.html
    40. https://katfile.com/si951brc7wai/teen_cocksucker.mp4.html
    41. https://katfile.com/air1cunyil6q/Xxxx_.t.mp4.html
    42. https://katfile.com/vzfutxpkkmgk/you_doing_i_am_t.mp4.html
Add Comment
Please, Sign In to add comment
Advertisement