Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

type.ex 421 Bytes
Newer Older
1
2
defmodule Grains.Type do

3
  @nr_types 2
4
5
  @nr_colors 255
  @nr_saturations 50
6
7

  def select_type(uuid) do
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    Integer.mod(parse(uuid), @nr_types)
  end

  # returns a tuple for hue / saturation
  def select_color(uuid) do
    i = parse(uuid)
    h = Integer.mod(i, @nr_colors);
    s = 50 + Integer.mod(i, @nr_saturations);
    {h, s}
  end



  def parse(uuid) do
22
    {i, _} = Integer.parse(uuid, 16)
23
    i
24
25
  end

26
27


28
end