Archive

Posts Tagged ‘rmagick’

RMagick4J 0.3.6

August 16th, 2008 Serabe No comments

I am glad to announce a new version of rmagick4j.

RMagick4J aims to implement the ImageMagick funcionality and the C
portions of RMagick for make it works in JRuby.

Current stable version: 0.3.6
Project URL: http://code.google.com/p/rmagick4j/
Installation: gem install rmagick4j

Google Summer of Code project should be thanked for making this new
release possible.

In release 0.3.6 you can find the next improvements:

  • More Draw primitives (clip-path [creatin a clip-path and using a
    clip-path], fill-rule, rotate, scale [reimplemented], skewX, slewY,
    stroke-linecap, stroke-linejoin, stroke-miterlimit, translate).
  • Solve a bug with transparent stroke and line primitive.
  • Added the following Draw instance methods:
    • annotate
    • get_multiline_type_metrics
  • Solved a bug that caused the background become black while resizing
    images with alpha channel.

Please try out your applications with rmagick4j and help us provide
feedback. It is our goal to make a fully-compatible implementation of
RMagick4j in JRuby.

RMagick: Dibujar con patrones

July 22nd, 2008 Serabe No comments

Una interesante cualidad de la clase Draw de RMagick es la posibilidad de definir patrones a través del método pattern.

En primer lugar, lo básico:

RUBY:
  1. require 'rubygems'
  2. require 'RMagick'
  3.  
  4. include Magick

Ahora definamos el patrón. Para ello, necesitamos cinco parámetros, el nombre, dos números que recomiendo ponerlos a cero (después de unas cuantas pruebas, no he notado diferencias notables) y después las dimensiones del patrón.

RUBY:
  1. draw = Draw.new
  2.  
  3. draw.pattern('circles', 0, 0, 10, 10) do
  4.   draw.stroke 'none'
  5.   draw.fill 'red'
  6.   draw.rectangle 0, 0, 10, 10
  7.   draw.stroke 'LightGreen'
  8.   draw.fill 'blue'
  9.   draw.circle 5, 5, 5, 0
  10. end

Ya, por último, dibujamos un cuadrado y lo plasmamos en una imagen de 300x300.

RUBY:
  1. draw.stroke 'circles'
  2. draw.stroke_width 25
  3.  
  4. draw.fill 'none'
  5.  
  6. draw.polygon 150,0, 300,150, 150,300, 0,150
  7.  
  8. img = Image.new 300, 300
  9.  
  10. draw.draw img
  11.  
  12. img.write 'pattern.jpg'

Obteniéndose el siguiente resultado:

Dibujo con patrón como brocha

Dibujo con patrón como brocha

Improve the web with Nofollow Reciprocity.