Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pulled flat history from subversion.
[git-p4: depot-paths = "//src/png/dev/": change = 2769]
- Loading branch information
0 parents
commit c855542
Showing
9 changed files
with
720 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CHANGES | ||
Manifest.txt | ||
README | ||
Rakefile | ||
example/lines.rb | ||
example/profile.rb | ||
lib/png.rb | ||
test/test_png.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
|
Oops, something went wrong.