The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
While things compile...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Premshree Pillai

Posts: 478
Nickname: premshree
Registered: Mar, 2004

Premshree Pillai is a Ruby evangelist, working with Yahoo!.
While things compile... Posted: Mar 19, 2005 4:10 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Premshree Pillai.
Original Post: While things compile...
Feed Title: Premshree's Personal Weblog
Feed URL: http://premshree.livejournal.com/data/rss
Feed Description: Premshree's Weblog
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Premshree Pillai
Latest Posts From Premshree's Personal Weblog

Advertisement
You do this:
FIREFOXFIREFOXFIREFOXFIREFOXFIREF
OXFIREFOXFIREFOXFIREFOXFIREFOXFI
REFOXFIREFOXFIREFOXFIREFOXFIREFO
XFIREFOXFIREFOXFIREFOXFIREFOXFIR
EFOXFIREFOXFIREFOXFIREFOXFIREFOX
FIREFOXFIREFOXFIREFOXFIREFOXFIRE
FOXFIREFOXFIREFOXFIREFOXFIREFOXF
IREFOXFIREFOXFIREFOXFIREFOXFIREF
OXFIREFOXFIREFOXFIREFOXFIREFOXFI
REFOXFIREFOXFIREFOXFIREFOXFIREFO
XFIREFOXFIREFOXFIREFOXFIREFOXFIR
EFOXFIREFOXFIREFOXFIREFOXFIREFOX
FIREFOXFIREFOXFIREFOXFIREFOXFIRE
FOXFIREFOXFIREFOXFIREFOXFIREFOXF
IREFOXFIREFOXFIREFOXFIREFOXFIREF
OXFIREFOXFIREFOXFIREFOXFIREFOXF

You do know what this is, no?

#!/ur/local/bin/ruby
# $premshree$ $2005-03-18 03:13$

require 'GD'
include GD

img = Image.newFromPng(File.new('firefox.png', 'rb'))
text = 'FIREFOX'

width = img.width
height = img.height
temps = [0]*3
skip_pixels = 1
skip_lines = 2
char_next = 0
print '<pre style="background: #FFFFFF">'
height.times { |i|
	if temps[2] == 0
		width.times { |j|
			if temps[1] == 0
				idx = img.getPixel(j, i)
				color = img.rgb(idx)
				print "<span style=\"color: rgb(#{color[0]}, #{color[1]},
				 #{color[2]}); font-size:10px;\">#{text.split('')[char_next]}</span>"
				char_next = char_next + 1
				if char_next == text.split('').length then char_next = 0 end
			end
			temps[1] = temps[1] + 1
			if temps[1] == skip_pixels then temps[1] = 0 end
			if temps[0] == width
				print '<br />'
				temps[0] = 0
			end
			temps[0] = temps[0] + 1			
		}
	end
	temps[2] = temps[2] + 1
	if temps[2] == skip_lines then temps[2] = 0 end
}
print '</pre>'
Original image here.

Read: While things compile...

Topic: Ruby class variable scope Previous Topic   Next Topic Topic: I don't care about the desktop

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use