rmagick4j 0.3.1-java → 0.3.2-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,133 @@
1
+ #--
2
+ # $Id: transformable.rb,v 1.3 2007/01/20 17:39:50 rmagick Exp $
3
+ # Copyright (C) 2007 Timothy P. Hunter
4
+ #++
5
+
6
+ module Magick
7
+ class RVG
8
+
9
+ # Transforms is an Array with a deep_copy method.
10
+ # During unit-testing it also has a deep_equal method.
11
+ class Transforms < Array #:nodoc:
12
+
13
+ def deep_copy(h=nil)
14
+ copy = self.class.new
15
+ each { |transform| copy << [transform[0], transform[1].dup] }
16
+ return copy
17
+ end
18
+
19
+ end # class Transform
20
+
21
+ # Transformations are operations on the coordinate system.
22
+ # All the transformations defined within a container (an RVG object
23
+ # or a group) are applied before drawing any shapes or text.
24
+ # All transformations are applied in the order they were
25
+ # defined. <em>Note:</em> This means that
26
+ # g.translate(10,20).scale(2)
27
+ # is not the same as
28
+ # g.scale(2).translate(10,20)
29
+ module Transformable
30
+
31
+ private
32
+
33
+ # Apply transforms in the same order they were specified!
34
+ def add_transform_primitives(gc)
35
+ @transforms.each { |transform| gc.__send__(transform[0], *transform[1]) }
36
+ end
37
+
38
+ def initialize(*args, &block)
39
+ super()
40
+ @transforms = Transforms.new
41
+ end
42
+
43
+ public
44
+
45
+ # Applies the transformation matrix [sx, rx, ry, sy, tx, ty]
46
+ def matrix(sx, rx, ry, sy, tx, ty)
47
+ begin
48
+ @transforms << [:affine, [Float(sx), Float(rx), Float(ry), Float(sy), Float(tx), Float(ty)]]
49
+ rescue ArgumentError
50
+ raise ArgumentError, "arguments must be convertable to float (got #{sx.class}, #{rx.class}, #{ry.class}, #{sy.class}, #{sx.class}, #{sx.class}, #{tx.class}, #{ty.class})"
51
+ end
52
+ yield(self) if block_given?
53
+ self
54
+ end
55
+
56
+ # Add <tt>tx</tt> to all x-coordinates and <tt>ty</tt>
57
+ # to all y-coordinates. If <tt>ty</tt> is omitted it defaults
58
+ # to <tt>tx</tt>.
59
+ def translate(tx, ty=nil)
60
+ ty ||= tx
61
+ begin
62
+ @transforms << [:translate, [Float(tx), Float(ty)]]
63
+ rescue ArgumentError
64
+ raise ArgumentError, "arguments must be convertable to float (got #{tx.class}, #{ty.class})"
65
+ end
66
+ yield(self) if block_given?
67
+ self
68
+ end
69
+
70
+ # Multiply the x-coordinates by <tt>sx</tt> and the y-coordinates
71
+ # by <tt>sy</tt>. If <tt>sy</tt> is omitted it defaults to <tt>sx</tt>.
72
+ def scale(sx, sy=nil)
73
+ sy ||= sx
74
+ begin
75
+ @transforms << [:scale, [Float(sx), Float(sy)]]
76
+ rescue ArgumentError
77
+ raise ArgumentError, "arguments must be convertable to float (got #{sx.class}, #{sy.class})"
78
+ end
79
+ yield(self) if block_given?
80
+ self
81
+ end
82
+
83
+ # This method can take either of two argument lists:
84
+ # [rotate(angle)] rotate by <tt>angle</tt> degrees
85
+ # [rotate(angle, cx, cy)] rotate by <tt>angle</tt> degrees about
86
+ # the point [<tt>cx</tt>, <tt>cy</tt>].
87
+ def rotate(angle, *args)
88
+ begin
89
+ case args.length
90
+ when 0
91
+ @transforms << [:rotate, [Float(angle)]]
92
+ when 2
93
+ cx, cy = Float(args[0]), Float(args[1])
94
+ @transforms << [:translate, [cx, cy]]
95
+ @transforms << [:rotate, [angle]]
96
+ @transforms << [:translate, [-cx, -cy]]
97
+ else
98
+ raise ArgumentError, "wrong number of arguments (#{args.length} for 1 or 3)"
99
+ end
100
+ rescue ArgumentError
101
+ raise ArgumentError, "arguments must be convertable to float (got #{[angle, *args].collect {|a| a.class}.join(', ')})"
102
+ end
103
+ yield(self) if block_given?
104
+ self
105
+ end
106
+
107
+ # Skew the X-axis by <tt>angle</tt> degrees.
108
+ def skewX(angle)
109
+ begin
110
+ @transforms << [:skewx, [Float(angle)]]
111
+ rescue ArgumentError
112
+ raise ArgumentError, "argument must be convertable to float (got #{angle.class})"
113
+ end
114
+ yield(self) if block_given?
115
+ self
116
+ end
117
+
118
+ # Skew the Y-axis by <tt>angle</tt> degrees.
119
+ def skewY(angle)
120
+ begin
121
+ @transforms << [:skewy, [Float(angle)]]
122
+ rescue ArgumentError
123
+ raise ArgumentError, "argument must be convertable to float (got #{angle.class})"
124
+ end
125
+ yield(self) if block_given?
126
+ self
127
+ end
128
+
129
+ end # module Transformable
130
+
131
+ end # class RVG
132
+ end # module Magick
133
+
data/lib/rvg/units.rb ADDED
@@ -0,0 +1,66 @@
1
+ # $Id: units.rb,v 1.3 2007/01/20 17:39:50 rmagick Exp $
2
+ # Copyright (C) 2007 Timothy P. Hunter
3
+ module Magick
4
+ class RVG
5
+
6
+ # Define RVG.dpi and RVG.dpi=. Add conversions to Fixnum and Float classes
7
+ class << self
8
+ attr_reader :dpi
9
+ def dpi=(n)
10
+ if !defined?(@dpi)
11
+ [Float, Fixnum].each do |c|
12
+ c.class_eval <<-END_DEFS
13
+ # the default measurement - 1px is 1 pixel
14
+ def px
15
+ self
16
+ end
17
+ # inches
18
+ def in
19
+ self * ::Magick::RVG.dpi
20
+ end
21
+ # millimeters
22
+ def mm
23
+ self * ::Magick::RVG.dpi / 25.4
24
+ end
25
+ # centimeters
26
+ def cm
27
+ self * ::Magick::RVG.dpi / 2.54
28
+ end
29
+ # points
30
+ def pt
31
+ self * ::Magick::RVG.dpi / 72.0
32
+ end
33
+ # picas
34
+ def pc
35
+ self * ::Magick::RVG.dpi / 6.0
36
+ end
37
+ # percentage of the argument
38
+ def pct(of)
39
+ self * Float(of) / 100.0
40
+ end
41
+ # the default is deg
42
+ def deg
43
+ self
44
+ end
45
+ # radians -> degrees
46
+ def rad
47
+ self * 180.0 / Math::PI
48
+ end
49
+ # grads -> degrees
50
+ def grad
51
+ self * 9.0 / 10.0
52
+ end
53
+ END_DEFS
54
+ end
55
+ end
56
+
57
+ @dpi = Float(n)
58
+ return @dpi
59
+ rescue ArgumentError
60
+ raise TypeError, "Can't convert `#{n}' to Float"
61
+ end
62
+ end # class << self
63
+
64
+ end # class RVG
65
+ end # module Magick
66
+
Binary file
metadata CHANGED
@@ -5,7 +5,7 @@ description: RMagick4J is a JRuby back end to support the RMagick library. It bu
5
5
  a Java library called Magick4J that implements ImageMagick and some RMagick native
6
6
  functionality.
7
7
  version: !ruby/object:Gem::Version
8
- version: 0.3.1
8
+ version: 0.3.2
9
9
  requirements: []
10
10
  test_files: []
11
11
  bindir: bin
@@ -14,7 +14,7 @@ autorequire:
14
14
  extensions: []
15
15
  summary: RMagick4J is a JRuby back end for RMagick.
16
16
  post_install_message:
17
- homepage: http://rubyforge.org/projects/jruby-extras/
17
+ homepage: http://code.google.com/p/rmagick4j/
18
18
  dependencies: []
19
19
  has_rdoc: false
20
20
  required_ruby_version: !ruby/object:Gem::Version::Requirement
@@ -30,13 +30,32 @@ name: rmagick4j
30
30
  executables: []
31
31
  rdoc_options: []
32
32
  files:
33
+ - lib
33
34
  - lib/RMagick.jar
35
+ - lib/RMagick.rb
36
+ - lib/jhlabs-filters.jar
34
37
  - lib/magick4j.jar
35
38
  - lib/rmagick4j
36
39
  - lib/rmagick4j/rmagick4j.rb
40
+ - lib/rvg
41
+ - lib/rvg/clippath.rb
42
+ - lib/rvg/container.rb
43
+ - lib/rvg/deep_equal.rb
44
+ - lib/rvg/describable.rb
45
+ - lib/rvg/embellishable.rb
46
+ - lib/rvg/misc.rb
47
+ - lib/rvg/paint.rb
48
+ - lib/rvg/pathdata.rb
49
+ - lib/rvg/rvg.rb
50
+ - lib/rvg/stretchable.rb
51
+ - lib/rvg/stylable.rb
52
+ - lib/rvg/text.rb
53
+ - lib/rvg/transformable.rb
54
+ - lib/rvg/units.rb
55
+ - lib/svgsalamander.jar
37
56
  platform: java
38
57
  rubyforge_project: jruby-extras
39
- date: 2007-04-02 07:00:00 +00:00
58
+ date: 2007-05-25 07:00:00 +00:00
40
59
  authors:
41
60
  - Tom Palmer
42
61
  extra_rdoc_files: []