[web-devel] Issues with aeson encoding performance

Chris Smith cdsmith at gmail.com
Mon Aug 29 20:35:19 CEST 2011


On Mon, 2011-08-29 at 11:15 -0700, Bryan O'Sullivan wrote:

> It's impossible to tell what's going on from the data at hand, alas.
> Do you have an example of the kind of image you're trying to encode,
> so that I could try to reproduce your situation locally?

The easiest way I can give you to reproduce it is to try
http://dac4.designacourse.com:8000/anim and copy and paste the second
example from the blog link above, which I've included below.  I'll send
an example of the generated JSON off the mailing list if you like, since
it's 182K in size and bandwidth isn't free everywhere in the world yet.


import Graphics.Gloss

animation :: Float -> Picture
animation time
	= Scale 0.8 0.8 $ Translate 0 (-300)
	$ tree 4 time (dim $ dim brown)

-- Basic stump shape
stump :: Color -> Picture
stump color
	= Color color
	$ Polygon [(30,0), (15,300), (-15,300), (-30,0)]

-- Make a tree fractal.
tree 	:: Int 		-- Fractal degree
	-> Float	-- time
	-> Color 	-- Color for the stump
	-> Picture

tree 0 time color = stump color
tree n time color
 = let	smallTree
		= Rotate (sin time)
		$ Scale 0.5 0.5
		$ tree (n-1) (- time) (greener color)
   in	Pictures
		[ stump color
		, Translate 0 300 $ smallTree
		, Translate 0 240 $ Rotate 20	 smallTree
		, Translate 0 180 $ Rotate (-20) smallTree
		, Translate 0 120 $ Rotate 40 	 smallTree
		, Translate 0  60 $ Rotate (-40) smallTree ]

-- A starting colour for the stump
brown :: Color
brown =  makeColor8 139 100 35  255

-- Make this color a little greener
greener :: Color -> Color
greener c = mixColors 1 10 green c

-- 
Chris





More information about the web-devel mailing list