News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Temperature comparison
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
Temperature comparison

Here's a simple tool to compare temperatures in celcius, fahrenheit, and kelvin, and show some temperature levels of note.

It isn't finished, or even entirely accurate. The conversions are rounded to integers, which I might change in the future, and a lot more "notable temps" need to be included. Also going to eliminate some redundancy in the code.

Posting for criticism/suggestions.

Code:
#!/usr/bin/env murgaLua

function chk()
box:label("")
for k,v in pairs(temps) do
if math.floor(sk:value())==k then box:label(v) end
end
end

temps={
[0]="absolute zero",
[159]="freezing point of pure ethanol",
[184]="coldest air temperature recorded on Earth (Vostok, Antarctica, 1983)",
[273]="freezing point of water",
[309]="average human body temperature",
[331]="Highest air temperature recorded on Earth (El Azizia, Libya, 1922)";
[351]="boiling point of ethanol",
[373]="boiling point of water",
[516]="Ignition temperature of sulfur",
[553]="Ignition temperature of gasoline",
[622]="Ignition temperature of charcoal",
[672]="Ignition temperature of isopropyl alcohol",
[673]="Ignition temperature of petroleum",
[693]="Ignition temperature of butane",
[753]="Ignition temperature of propane",
[773]="Ignition temperature of hydrogen",
[973]="Ignition temperature of carbon",
[1670]="The hottest (blue) part of a candle flame";
[5800]="estimated temperature of the sun's surface"
}

ww=600; sh=30
w=fltk:Fl_Double_Window(ww,sh*5,"Temperature Conversion")

sf=fltk:Fl_Hor_Value_Slider(20,10,ww-30,sh,"F")
sf:align(4); --sf:when(fltk.FL_WHEN_RELEASE)
sf:minimum(-459); sf:maximum(212); sf:value(32); sf:step(1)
sf:callback(function()
sc:value((sf:value() - 32) * 5/9)
sk:value(sc:value()+273)
chk()
end)

sc=fltk:Fl_Hor_Value_Slider(20,10+sh,ww-30,sh,"C")
sc:align(4); --sc:when(fltk.FL_WHEN_RELEASE)
sc:minimum(-273); sc:maximum(420); sc:step(1)
sc:callback(function()
sf:value(sc:value() * 9/5 + 32)
sk:value(sc:value() + 273)
chk()
end)

sk=fltk:Fl_Hor_Value_Slider(20,10+sh*2,ww-30,sh,"K")
sk:align(4); --sk:when(fltk.FL_WHEN_RELEASE)
sk:minimum(0); sk:maximum(5800); sk:value(273); sk:step(1)
sk:callback(function()
sf:value((sk:value() - 273) * 9/5 + 32 )
sc:value(sk:value() - 273)
chk()
end)

box=fltk:Fl_Box(20,10+sh*3,ww-30,sh)
box:box(fltk.FL_DOWN_BOX)
sc:do_callback()

w:show()
Fl:run()

04-17-2010 11:48 PM
Find all posts by this user Quote this message in a reply
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #2
RE: Temperature comparison

Nice. Inspires me to post some of my little MurgaLua projects.

04-19-2010 10:18 AM
Visit this user's website Find all posts by this user Quote this message in a reply
jpjacobs
Member
***


Posts: 113
Group: Registered
Joined: Jul 2007
Status: Offline
Reputation: 0
Post: #3
RE: Temperature comparison

Would be nice to add colors to it, to really *feel* the temperature Wink

Greetz,
JP

04-21-2010 01:08 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: