<commit_before>require 'ws_light/set/color_set'

module WSLight
  module Set
    # Creates a watermelon set, some green, some white, lots of red with a few red dots
    class WatermelonSet < ColorSet
      def frame
        set = []

        length_red = (0.72 * @length).to_i
        length_red_to_white = (0.1 * @length).to_i
        length_white = (0.1 * @length).to_i

        white = Color.new(255, 255, 255)
        red = Color.new(255, 0, 0)

        @length.times do |i|
          if i < length_red
            set << Color.new((rand(25) < 1 ? 0 : 255), 0, 0)
          elsif i < length_red + length_red_to_white
            ratio = (i - length_red) / (length_red + length_red_to_white)
            set << red.mix(white, ratio)
          elsif i < length_red + length_red_to_white + length_white
            set << white
          else
            set << Color.new(0, 127, 0)
          end
        end

        set
      end

      def pixel(number, _frame = 0)
        frame[number]
      end
    end
  end
end<commit_msg>[BUGFIX] Extend melon to second led strip<commit_after>require 'ws_light/set/color_set'

module WSLight
  module Set
    # Creates a watermelon set, some green, some white, lots of red with a few red dots
    class WatermelonSet < ColorSet
      def create_frame
        set = []

        length_red = (0.72 * @length).to_i
        length_red_to_white = (0.1 * @length).to_i
        length_white = (0.1 * @length).to_i

        white = Color.new(255, 255, 255)
        red = Color.new(255, 0, 0)

        @length.times do |i|
          if i < length_red
            set << Color.new((rand(25) < 1 ? 0 : 255), 0, 0)
          elsif i < length_red + length_red_to_white
            ratio = (i - length_red) / (length_red + length_red_to_white)
            set << red.mix(white, ratio)
          elsif i < length_red + length_red_to_white + length_white
            set << white
          else
            set << Color.new(0, 127, 0)
          end
        end

        type == :double ? set + set.reverse : set
      end

      def frame
        @set ||= create_frame
      end

      def pixel(number)
        frame[number]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09770642201834863, 'fraction_numerical': 0.03256880733944954, 'mean_word_length': 1.753787878787879, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2344749', 'n_tokens_mistral': 770, 'n_tokens_neox': 703, 'n_words': 202}