POV-Ray : Newsgroups : povray.off-topic : Interactive Huffman compression Server Time
3 Sep 2024 19:15:44 EDT (-0400)
  Interactive Huffman compression (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Invisible
Subject: Interactive Huffman compression
Date: 22 Oct 2010 09:41:06
Message: <4cc19472@news.povray.org>
OK, so it's taken me an entire week to code this up. See what you think 
of it. It definitely works in Firefox 3.5.13, but realistically it ought 
to work with anything that supports XHTML, SVG, JavaScript and DOM 
manipulations.

To use it, just unzip everything into the same folder, and open the 
XHTML page. Hopefully the controls and the display are self-explanatory. 
(Assuming you know what Huffman codes *are*, of course!)

PS. Yes, I know decoding doesn't work.

PPS. Yes, I know it's slower than continental drift.


Post a reply to this message


Attachments:
Download 'huffman-06.zip' (11 KB)

From: scott
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 10:20:36
Message: <4cc19db4$1@news.povray.org>
> OK, so it's taken me an entire week to code this up. See what you think 
> of it. It definitely works in Firefox 3.5.13, but realistically it ought 
> to work with anything that supports XHTML, SVG, JavaScript and DOM 
> manipulations.
> 
> To use it, just unzip everything into the same folder, and open the 
> XHTML page. Hopefully the controls and the display are self-explanatory. 
> (Assuming you know what Huffman codes *are*, of course!)

The pretty graphics just flicker onto the screen then disappear!


Post a reply to this message

From: Invisible
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 10:53:15
Message: <4cc1a55b$1@news.povray.org>
On 22/10/2010 03:20 PM, scott wrote:

> The pretty graphics just flicker onto the screen then disappear!

The design intention is this: If you click "compress", the browser locks 
up and has a heart attack, and then eventually spits out the compressed 
bitstream. However, if you click on "step compress", you should get a 
bunch of buttons further down the page which you can use to step through 
the process one stage at a time. The "abort" button quits the simulation 
and unlocks all the controls. The button furthest to the left does small 
steps, the button furthest to the right does big steps.

Now, that's what is *supposed* to happen. Whether it actually works in 
all browsers is another matter...


Post a reply to this message

From: Invisible
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 10:54:41
Message: <4cc1a5b1$1@news.povray.org>
On 22/10/2010 03:53 PM, Invisible wrote:
> The button furthest to the left does small
> steps, the button furthest to the right does big steps.

...aaaaaaand I still haven't learned to tell left from right, 
apparently. o_O


Post a reply to this message

From: scott
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 11:32:15
Message: <4cc1ae7f@news.povray.org>
>> The pretty graphics just flicker onto the screen then disappear!
> 
> The design intention is this: If you click "compress", the browser locks 
> up and has a heart attack, and then eventually spits out the compressed 
> bitstream. However, if you click on "step compress", 

Cool - I missed that bit!


Post a reply to this message

From: Invisible
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 11:33:15
Message: <4cc1aebb@news.povray.org>
>> However, if you click on "step compress",
>
> Cool - I missed that bit!

I guess this illustrates Darren's point the other day - *everything* is 
obvious to the person who designed it...


Post a reply to this message

From: Invisible
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 11:50:13
Message: <4cc1b2b5@news.povray.org>
On 22/10/2010 02:41 PM, Invisible wrote:

> To use it, just unzip everything...

Speaking of compression: This is about 35KB of source code, yet 7zip has 
squished it into an 11KB file. That's about 68% compression. So half of 
what I wrote was "necessary". ;-)

It's ironic really. Writing a program that *does* Huffman compression is 
fairly trivial. Writing a program that *demonstrates* Huffman 
compression is quite non-trivial. _Especially_ in an untyped, rather 
promiscuous language like JavaScript. Man, so many global variables! >_< 
Not to mention that function names are global too. Yuck!

So yeah, the program is just a tad buggy in places. I think I could 
probably improve my abstractions though. I've already done that several 
times

For example, originally the code for each step handled twiddling all the 
buttons on and off, etc. Things became drastically easier when I 
refactored the whole thing. Now I have a data structure representing 
steps, and utility functions that handle moving to the next step, etc. 
And a utility function that automatically reads this structure and does 
the necessary things to the UI. Suddenly everything becomes much easier.

But hey, we all know that having the right abstractions is critical to 
computer programming, right?

I remember when programming a computer required serious tools. Like, we 

Windows installed, and nothing else, and write stuff like... well, this. 
(IE doesn't support SVG yet though, does it?) You'd have to use Notepad 
of course [*shiver*], but you can now program a computer with almost 
nothing other than what comes with the OS.

(Of course, if you install Linux you probably get GCC by default anyway. 
:-P Along with software for every imaginable task, most of which you 
don't want and can't remove...)

Anyway, I'm going to go away and ruminate on this for a while now. No 
doubt I'll end up rewriting the whole thing yet again, and it'll be even 
bigger and better. It's how I work. I call it "iterative prototyping". ;-)


Post a reply to this message

From: nemesis
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 12:54:53
Message: <4cc1c1dd$1@news.povray.org>
Invisible escreveu:
> OK, so it's taken me an entire week to code this up. See what you think 
> of it. It definitely works in Firefox 3.5.13, but realistically it ought 
> to work with anything that supports XHTML, SVG, JavaScript and DOM 
> manipulations.
> 
> To use it, just unzip everything into the same folder, and open the 
> XHTML page. Hopefully the controls and the display are self-explanatory. 
> (Assuming you know what Huffman codes *are*, of course!)

doesn't work on IE8: it never seems to open xhtml files and "downloads" 
the file and opens in Firefox instead.

doesn't work in Firefox 3.0.14:

Error: row.children is undefined
Source File: file:///D:/Temp/Huffman-06/UI-SymbolTable.js
Line: 62

it's the same browser used for your previous version.

-- 
a game sig: http://tinyurl.com/d3rxz9


Post a reply to this message

From: Florian Pesth
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 14:49:15
Message: <4cc1dcab$1@news.povray.org>
Nice!

P.S.: It hangs with one character compression (not that it makes any 
sense :))


Post a reply to this message

From: Orchid XP v8
Subject: Re: Interactive Huffman compression
Date: 22 Oct 2010 15:18:53
Message: <4cc1e39d$1@news.povray.org>
On 22/10/2010 05:54 PM, nemesis wrote:
> Invisible escreveu:
>> OK, so it's taken me an entire week to code this up. See what you
>> think of it. It definitely works in Firefox 3.5.13, but realistically
>> it ought to work with anything that supports XHTML, SVG, JavaScript
>> and DOM manipulations.
>
> doesn't work on IE8: it never seems to open xhtml files and "downloads"
> the file and opens in Firefox instead.

Yeah, I noticed that IE just plain doesn't like XHTML, for whatever reason.

> doesn't work in Firefox 3.0.14:
>
> Error: row.children is undefined
> Source File: file:///D:/Temp/Huffman-06/UI-SymbolTable.js
> Line: 62

Hmm, that's an interesting place for it to fail... It's just vanilla DOM 
stuff. (Unless something is going screwy earlier than that, resulting in 
the variable not pointing to what it should be.)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.