diff options
Diffstat (limited to 'axis.hs')
-rw-r--r-- | axis.hs | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -46,6 +46,7 @@ drawFilledHexircle = _drawHexircle True | |||
46 | 46 | ||
47 | _AXIS_ROWS = 7 + 4 | 47 | _AXIS_ROWS = 7 + 4 |
48 | _AXIS_UNIQUE_COLS = 7 | 48 | _AXIS_UNIQUE_COLS = 7 |
49 | _AXIS_COLS_REPEAT = 1 | ||
49 | _AXIS_TOP_PITCH = 81 + (7 * (_AXIS_ROWS - 7) `div` 2) | 50 | _AXIS_TOP_PITCH = 81 + (7 * (_AXIS_ROWS - 7) `div` 2) |
50 | _AXIS_BOTTOM_PITCH = 81 - (7 * _AXIS_ROWS) - 3 | 51 | _AXIS_BOTTOM_PITCH = 81 - (7 * _AXIS_ROWS) - 3 |
51 | 52 | ||
@@ -71,6 +72,7 @@ eraseKeys pitches videoSurface font axis_key_locations axis_key_size = do | |||
71 | let (x, y) = axis_key_locations !! idx | 72 | let (x, y) = axis_key_locations !! idx |
72 | drawFilledHexircle videoSurface (fromIntegral x) (fromIntegral y) (fromIntegral axis_key_size) _KEY_BG_COLOR_PIXEL | 73 | drawFilledHexircle videoSurface (fromIntegral x) (fromIntegral y) (fromIntegral axis_key_size) _KEY_BG_COLOR_PIXEL |
73 | drawHexircle videoSurface (fromIntegral x) (fromIntegral y) (fromIntegral axis_key_size) _KEY_COLOR_PIXEL | 74 | drawHexircle videoSurface (fromIntegral x) (fromIntegral y) (fromIntegral axis_key_size) _KEY_COLOR_PIXEL |
75 | centerText videoSurface x y font _KEY_TEXT_COLOR _KEY_BG_COLOR (smartShowPitch pitch) | ||
74 | 76 | ||
75 | fi = fromIntegral | 77 | fi = fromIntegral |
76 | rgbColor r g b = SDL.Pixel (shiftL (fi r) 24 .|. shiftL (fi g) 16 .|. shiftL (fi b) 8 .|. (fi 255)) | 78 | rgbColor r g b = SDL.Pixel (shiftL (fi r) 24 .|. shiftL (fi g) 16 .|. shiftL (fi b) 8 .|. (fi 255)) |
@@ -181,10 +183,11 @@ centerText videoSurface x y font fgColor bgColor text = do | |||
181 | _ <- SDL.blitSurface fontSurface (Just fontClipRect) videoSurface (Just (SDL.Rect (fromIntegral(x) - w `div` 2) (fromIntegral(y) - h `div` 2) w h)) | 183 | _ <- SDL.blitSurface fontSurface (Just fontClipRect) videoSurface (Just (SDL.Rect (fromIntegral(x) - w `div` 2) (fromIntegral(y) - h `div` 2) w h)) |
182 | return () | 184 | return () |
183 | 185 | ||
184 | pitchIndex = (\x -> x ++ x) $ concat $ map colfrom toprow | 186 | pitchIndex = concat $ map (\x -> unique) [0 .. _AXIS_COLS_REPEAT - 1] |
185 | where | 187 | where |
186 | toprow = map (\i -> if (i `mod` 2) == 0 then (_AXIS_TOP_PITCH + i `div` 2) else (_AXIS_TOP_PITCH - 3 + i `div` 2)) [0 .. _AXIS_UNIQUE_COLS - 1] | 188 | toprow = map (\i -> if (i `mod` 2) == 0 then (_AXIS_TOP_PITCH + i `div` 2) else (_AXIS_TOP_PITCH - 3 + i `div` 2)) [0 .. _AXIS_UNIQUE_COLS - 1] |
187 | colfrom top = map (+ top) $ map (* (-7)) [0 .. _AXIS_ROWS - 1] | 189 | colfrom top = map (+ top) $ map (* (-7)) [0 .. _AXIS_ROWS - 1] |
190 | unique = concat $ map colfrom toprow | ||
188 | 191 | ||
189 | getKeyLocations (SDL.Rect offx offy totalw totalh) = | 192 | getKeyLocations (SDL.Rect offx offy totalw totalh) = |
190 | let (key_height, key_width, xys) = getKeyLocationsAbs | 193 | let (key_height, key_width, xys) = getKeyLocationsAbs |
@@ -215,7 +218,7 @@ getKeyLocations (SDL.Rect offx offy totalw totalh) = | |||
215 | 218 | ||
216 | getKeyLocationsAbs = | 219 | getKeyLocationsAbs = |
217 | let kb_rows = (fromIntegral _AXIS_ROWS) :: Double | 220 | let kb_rows = (fromIntegral _AXIS_ROWS) :: Double |
218 | kb_cols = 2 * (fromIntegral _AXIS_UNIQUE_COLS) :: Double | 221 | kb_cols = _AXIS_COLS_REPEAT * (fromIntegral _AXIS_UNIQUE_COLS) :: Double |
219 | -- the edges of the hexagon are equal in length to its "radius" | 222 | -- the edges of the hexagon are equal in length to its "radius" |
220 | -- if the radius is 1, then horizontal movement is 1.5 and vertical movement is sqrt(3) from one center to the next | 223 | -- if the radius is 1, then horizontal movement is 1.5 and vertical movement is sqrt(3) from one center to the next |
221 | -- or else it is 2*sqrt(3) to move down | 224 | -- or else it is 2*sqrt(3) to move down |
@@ -230,7 +233,7 @@ getKeyLocationsAbs = | |||
230 | 233 | ||
231 | y + kh / 2 * fromInteger(i `mod` 2) + | 234 | y + kh / 2 * fromInteger(i `mod` 2) + |
232 | 235 | ||
233 | (if (fromInteger(i) >= kb_cols / 2) then kh * fromInteger((i+1) `mod` 2) else 0) | 236 | (if (fromInteger(i) >= _AXIS_UNIQUE_COLS) then kh * fromInteger((i+1) `mod` 2) else 0) |
234 | 237 | ||
235 | )) [0 .. round(kb_cols) - 1]) $ | 238 | )) [0 .. round(kb_cols) - 1]) $ |
236 | map (\i -> kh * fromIntegral(i)) | 239 | map (\i -> kh * fromIntegral(i)) |