google-research / dex-lang

Research language for array processing in the Haskell/ML family
BSD 3-Clause "New" or "Revised" License
1.58k stars 107 forks source link

PNG rendering doesn't work on Mac #538

Closed duvenaud closed 3 years ago

duvenaud commented 3 years ago

Edit: Adam fixed it for me with this advice:

"can you please try adding -DDEX_LIVE to this line? https://github.com/google-research/dex-lang/blob/main/makefile#L95"

It doesn't work in the raytrace demo or anywhere, as far as I can tell. I tried on Chrome and Safari. It just shows the "missing image" icon.

Here's a simple example that fails:

import plot

def hue2rgb (p:Float) (q:Float) (t:Float) : Float = 
  t = t - floor t
  if t < (1.0/6.0)
    then p + (q - p) * 6.0 * t
    else if t < (1.0/2.0)
      then q
      else if t < (2.0/3.0)
        then p + (q - p) * (2.0/3.0 - t) * 6.0
        else p

def hslToRgb (h:Float) (s:Float) (l:Float) : (Fin 3)=>Float =
  if s == 0.0
    then [l, l, l] -- achromatic
    else
      q = select (l < 0.5) (l * (1.0 + s)) (l + s - l * s)
      p = 2.0 * l - q
      r = hue2rgb p q (h + 1.0/3.0)
      g = hue2rgb p q h
      b = hue2rgb p q (h - 1.0/3.0)
      [r, g, b]

im:(Fin 100)=>(Fin 100)=>(Fin 3)=>Float = for x. for y.
  l = ((IToF (ordinal y)) / 100.0)
  s = 1.0
  v = ((IToF (ordinal x)) / 100.0)
  hslToRgb l s v 

:html imshow im
duvenaud commented 3 years ago

Fixed by #545