Skip to content

Commit

Permalink
Pulled flat history from subversion.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/png/dev/": change = 2769]
  • Loading branch information
zenspider committed Dec 15, 2006
0 parents commit c855542
Show file tree
Hide file tree
Showing 9 changed files with 720 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CHANGES
@@ -0,0 +1,12 @@
== 1.1.0

* Fixed bug in PNG::Canvas#each
* Patch from Tom Werner
* Added PNG::Canvas#inpsect
* Added PNG::Canvas#to_s
* Added PNG::Color#to_ascii
* Sped up PNG#to_blob with RubyInline

== 1.0.0

BIRTHDAY!
8 changes: 8 additions & 0 deletions Manifest.txt
@@ -0,0 +1,8 @@
CHANGES
Manifest.txt
README
Rakefile
example/lines.rb
example/profile.rb
lib/png.rb
test/test_png.rb
29 changes: 29 additions & 0 deletions README
@@ -0,0 +1,29 @@
= png

== About

png is an almost-pure-ruby PNG library. It lets you write a PNG without any C
libraries. It might be a bit "slow", especially if you don't have a C
compiler.

== Installing png

Just install the gem:

$ sudo gem install png

== Using png

require 'png'

canvas = PNG::Canvas.new 200, 200

# Set a point to a color
canvas[100, 100] = PNG::Color::Black

# draw an anti-aliased line
canvas.line 50, 50, 100, 50, PNG::Color::Blue

png = PNG.new canvas
png.save 'blah.png'

23 changes: 23 additions & 0 deletions Rakefile
@@ -0,0 +1,23 @@
require 'rubygems'
require 'rake'

$VERBOSE = nil

$spec = Gem::Specification.new do |s|
s.name = 'png'
s.version = '1.1.0'
s.summary = 'An almost-pure-ruby PNG library'
s.description = 'png allows you to write a PNG file without installing any C libraries.'
s.author = 'Ryan Davis'
s.email = 'ryand-ruby@zenspider.com'

s.has_rdoc = true
s.files = File.read('Manifest.txt').split($/)
s.require_path = 'lib'

s.add_dependency 'RubyInline', '>= 3.5.0'
end

require '../../tasks/project_defaults'

# vim: syntax=Ruby
27 changes: 27 additions & 0 deletions example/lines.rb
@@ -0,0 +1,27 @@
#!/usr/local/bin/ruby -w

require 'png'

canvas = PNG::Canvas.new 1024, 1024, PNG::Color::Black

#canvas.each do |x, y|
# case x
# when y then
# canvas.point(x, y, Color::Black)
# when 50 then
# canvas.point(x, y, Color::Background)
# end
# canvas.point(x, y, Color::Green) if y = 200
#end

canvas.line 50, 50, 100, 50, PNG::Color::Blue
canvas.line 50, 50, 50, 100, PNG::Color::Blue
canvas.line 100, 50, 150, 100, PNG::Color::Blue
canvas.line 100, 50, 125, 100, PNG::Color::Green # currently wrong
canvas.line 100, 50, 200, 75, PNG::Color::Green # currently wrong
canvas.line 0, 200, 200, 0, PNG::Color::Black

png = PNG.new canvas
png.save 'blah.png'
`open blah.png`

16 changes: 16 additions & 0 deletions example/profile.rb
@@ -0,0 +1,16 @@
require 'png'

class PNGProfile

def draw
canvas = PNG::Canvas.new 400, 400
png = PNG.new canvas
png.to_blob
end

end

pp = PNGProfile.new

10.times do pp.draw end

37 changes: 37 additions & 0 deletions example/profile_lines.rb
@@ -0,0 +1,37 @@
require 'png'

class PNGProfileLine

COLORS = [
PNG::Color::Red,
PNG::Color::Orange,
PNG::Color::Yellow,
PNG::Color::Green,
PNG::Color::Blue,
PNG::Color::Purple,
]

def draw
line = 0
canvas = PNG::Canvas.new 100, 100

0.step 99, 10 do |x|
canvas.line x, 0, 99 - x, 99, COLORS[line % 6]
line += 1
end

0.step 99, 10 do |y|
canvas.line 0, y, 99, y, COLORS[line % 6]
line += 1
end

canvas
end

end

ppl = PNGProfileLine.new

5.times do ppl.draw end
#PNG.new(ppl.draw).save 'x.png'

0 comments on commit c855542

Please sign in to comment.