spf_drawing 0.0.8 → 0.0.9

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjcyNmNjOTQzOGM0MzAxN2VjNjk0MjcwYzdmNmM3YmRmMTIzNmE3NA==
4
+ NTQwNTg2Y2FiZDNjMzRjODUzOTk2ZGE5MTY0YWMxZTVhNWViZmRkZA==
5
5
  data.tar.gz: !binary |-
6
- NzIyMjQ4MTNkZTI4OGUyZDMyOTIwNWY4NTlmMDc3NjkyOTVlNDIyOA==
6
+ ZWY5ZDFmMWVkMDg1YzZjMTMzNWQyZjA1YzVkMzgxMDRjOWJjMzJhMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGQ0YzkzMjQyYTQ0MjZjMzk2NWE1Mjg3OGM0ODcyYjIyODVmNGQ0YTlhZGM3
10
- MDNiNTc3NWM2NzIzN2I5NjI4NGViMjMxZWFjMjdmMmRiNTJjMGZmMzQ5Yjkw
11
- MjFkNDdmZjM5NzkzZWM5NDU3MTNiNzgwM2JhZmY3MDhlNzM4YmQ=
9
+ ZTZiYjBmYjY0YTk3NjI3NTg3MDk5YzhlZWI5MGE5OGVkZTJkMTliNDE2OTgz
10
+ YmM4NWIwMTJmZDJjNjllMWZmZmM1ZTFjZjQyZDYxZTBhNDcxZjVlMTY1NTY3
11
+ NTNlYjNiZmE4ZTI0YmY4YWJhZTU3ZWY2YjAwZDUxYTk4ZmZhOWU=
12
12
  data.tar.gz: !binary |-
13
- MzdiYzYzODhlZWRhYzI3YzNlMjI4MGU0ODEwYzFmYzUwNzUxZDg4NWYyZDI1
14
- NzJkYzM3ZmVhYzE1NjM2ZDQzMjhjZmYyOTQ0NGRhMzk3ZDU5NjY5OWJkOGFl
15
- ZDllZmE5ZGUwYjZlYTNiM2RjOTI5Y2E3NzMyODFkYzQ5YThjMjc=
13
+ YjUxMTljNjk5MWJjYTZkMWRmZmQwMzI1MzA5MDY1Y2MyMjE1ZDE0ZjA0MTE3
14
+ NDgxODdjOWE3N2E1MzFjMGRkNjk2NzhmNWU1M2EwYzE1ZTBiMTNjZGQ5ZjMz
15
+ YTViM2NlNGU4YmJmMmRmNTZiYTI4NmM0MDMzNDgwMDlkNTNmNGU=
@@ -0,0 +1,9 @@
1
+ module ComponenteMagickUtil
2
+
3
+ require 'rmagick'
4
+
5
+ def representacion_height
6
+ img = Magick::Image.ping(Path.representacion_componente(self)).first
7
+ img.rows
8
+ end
9
+ end
@@ -22,6 +22,21 @@ class ComposicionMagick
22
22
  imagen_composicion.destroy!
23
23
  end
24
24
 
25
+ def crear_dibujo_componente(componente)
26
+ path = "#{Path::ImagesMagick}componente_#{componente.id}.png"
27
+
28
+
29
+ imagen_composicion = dibujar_solo_componente(componente)
30
+
31
+
32
+ imagen_composicion.write(path)
33
+
34
+ # agarra la misma imagen y la hace transparente
35
+ system("convert #{path} -transparent white #{path}")
36
+
37
+ imagen_composicion.destroy!
38
+ end
39
+
25
40
  def dibujar_composicion(composicion)
26
41
  imagenes = ImageList.new
27
42
 
@@ -53,6 +68,25 @@ class ComposicionMagick
53
68
  imagenes.append(true)
54
69
  end
55
70
 
71
+ def dibujar_solo_componente(componente)
72
+ imagenes = ImageList.new
73
+
74
+ imagenes.push Image.read(Path::IconoSunPng)[0].resize(40, 40)
75
+
76
+ componente.elementos.order(:orden).each do |elemento|
77
+ imagen_elemento = dibujar_elemento(elemento)
78
+ imagenes.push imagen_elemento
79
+ end
80
+
81
+ imagen2 = ImageList.new
82
+
83
+ imagen2.push Image.read(Path::IconoHomePng)[0].resize(40, 40)
84
+ # imagen2.push Image.read("/home/fontela/SPF/app/assets/images/vacio.png")[0]
85
+ imagenes.push imagen2.append(false)
86
+
87
+ imagenes.append(true)
88
+ end
89
+
56
90
  def dibujar_elemento(elemento)
57
91
 
58
92
  # devuelve un objeto Figura::Monolitico/Espaciador/etc
@@ -125,4 +159,13 @@ class ComposicionMagick
125
159
  end
126
160
  end
127
161
 
162
+ def get_imagen_componente(componente)
163
+ if File.exist?("#{Path::ImagesMagick}componente_#{componente.id}.png")
164
+ return "componente_#{componente.id}.png"
165
+ else
166
+ crear_dibujo_componente(compoonente)
167
+ return "componente_#{componente.id}.png"
168
+ end
169
+ end
170
+
128
171
  end
@@ -1,3 +1,3 @@
1
1
  module SpfDrawing
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/spf_drawing.rb CHANGED
@@ -7,6 +7,7 @@ require 'spf_drawing/composicion_magick_util'
7
7
 
8
8
  require 'composicion_magick'
9
9
  require 'composicion_magick_util'
10
+ require 'componente_magick_util'
10
11
 
11
12
  module SpfDrawing
12
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spf_drawing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Ramseyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-11 00:00:00.000000000 Z
11
+ date: 2016-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -48,6 +48,7 @@ files:
48
48
  - MIT-LICENSE
49
49
  - README.rdoc
50
50
  - Rakefile
51
+ - lib/componente_magick_util.rb
51
52
  - lib/composicion_magick.rb
52
53
  - lib/composicion_magick_util.rb
53
54
  - lib/figura.rb