Script en ruby como gui para el comando 3Dtext.
Lun ,01/03/2010El comando 3Dtext permite crear un texto extruido simulando un efecto tridimensional. El script está ubicado en esta página y ha sido creado por Fred Weinhaus usando la interfaz de cónsola ImageMagick. Pueden bajar el script y ver los ejemplos de la página web indicada. El comando usa 13 parámetros para crear un texto, para ello hemos creado esta interfaz gráfica que nos facilita un poco el uso del comando.
Quedaría pendiente grabar los parámetros usados en un archivo tipo ini, para ser leído en la siguiente ejecución del programa, lo cual facilitaría aún más la múltiple creación de textos. El archivo de salida ha sido fijado con el nombre de 3Dtextoruby.png
#!/usr/bin/ruby require 'tk' require 'RMagick' include Magick #----------------------------------------------------- # mac3d.rb # Interfaz GUI para uso de 3Dtext # autor: Marcelo Anelli C. # # v1.00 23/02/2010 programa base. #----------------------------------------------------- # Selección de las opciones del borde def opciones(padre) # definir ventana de diálogo de las opciones wopciones = TkToplevel.new { title 'Seleccione sus opciones:' #relief 'sunken' borderwidth 3 height 430 width 600 } # etiquetas etiq0l = TkLabel.new(wopciones) { text 'Texto:' place('x'=>10.0,'y'=>10.0) } etiq02 = TkLabel.new(wopciones) { text 'Fuente:' place('x'=>10.0,'y'=>40.0) } etiq03 = TkLabel.new(wopciones) { text 'Tamaño Fuente:' place('x'=>10.0,'y'=>70.0) } etiq04 = TkLabel.new(wopciones) { text 'Tamaño itálico:' place('x'=>10.0,'y'=>100.0) } etiq05 = TkLabel.new(wopciones) { text 'Color texto:' place('x'=>10.0,'y'=>130.0) } etiq06 = TkLabel.new(wopciones) { text 'Color fondo:' place('x'=>10.0,'y'=>160.0) } etiq07 = TkLabel.new(wopciones) { text 'Color borde:' place('x'=>10.0,'y'=>190.0) } etiq08 = TkLabel.new(wopciones) { text 'Tamaño borde:' place('x'=>10.0,'y'=>220.0) } etiq09 = TkLabel.new(wopciones) { text 'Color outline:' place('x'=>10.0,'y'=>250.0) } etiq10 = TkLabel.new(wopciones) { text 'Tamaño outline:' place('x'=>10.0,'y'=>280.0) } etiq11 = TkLabel.new(wopciones) { text 'Color extrusión:' place('x'=>10.0,'y'=>310.0) } etiq12 = TkLabel.new(wopciones) { text 'Tamaño extrusión:' place('x'=>10.0,'y'=>340.0) } etiq13 = TkLabel.new(wopciones) { text 'Dirección:' place('x'=>10.0,'y'=>370.0) } # variables entry1 = TkEntry.new(wopciones) { background "white" } entry2 = TkEntry.new(wopciones) { background "white" } entry3 = TkEntry.new(wopciones) { background "white" } entry4 = TkEntry.new(wopciones) { background "white" } entry5 = TkEntry.new(wopciones) { background "white" } entry6 = TkEntry.new(wopciones) { background "white" } entry7 = TkEntry.new(wopciones) { background "white" } entry8 = TkEntry.new(wopciones) { background "white" } entry9 = TkEntry.new(wopciones) { background "white" } entry10 = TkEntry.new(wopciones) { background "white" } entry11 = TkEntry.new(wopciones) { background "white" } entry12 = TkEntry.new(wopciones) { background "white" } entry13 = TkEntry.new(wopciones) { background "white" } varia1 = TkVariable.new varia2 = TkVariable.new varia3 = TkVariable.new varia4 = TkVariable.new varia5 = TkVariable.new varia6 = TkVariable.new varia7 = TkVariable.new varia8 = TkVariable.new varia9 = TkVariable.new varia10 = TkVariable.new varia11 = TkVariable.new varia12 = TkVariable.new varia13 = TkVariable.new entry1.textvariable = varia1 entry2.textvariable = varia2 entry3.textvariable = varia3 entry4.textvariable = varia4 entry5.textvariable = varia5 entry6.textvariable = varia6 entry7.textvariable = varia7 entry8.textvariable = varia8 entry9.textvariable = varia9 entry10.textvariable = varia10 entry11.textvariable = varia11 entry12.textvariable = varia12 entry13.textvariable = varia13 varia1.value = $texto varia2.value = $fuente varia3.value = $punto varia4.value = $italic varia5.value = $tcolor varia6.value = $ucolor varia7.value = $bcolor varia8.value = $bsize varia9.value = $ocolor varia10.value = $lsize varia11.value = $ecolor varia12.value = $amount varia13.value = $direct entry1.place('height' => 25, 'width' => 450, 'x' => 140, 'y' => 10) entry2.place('height' => 25, 'width' => 450, 'x' => 140, 'y' => 40) entry3.place('height' => 25, 'width' => 50, 'x' => 140, 'y' => 70) entry4.place('height' => 25, 'width' => 50, 'x' => 140, 'y' => 100) entry5.place('height' => 25, 'width' => 450, 'x' => 140, 'y' => 130) entry6.place('height' => 25, 'width' => 450, 'x' => 140, 'y' => 160) entry7.place('height' => 25, 'width' => 450, 'x' => 140, 'y' => 190) entry8.place('height' => 25, 'width' => 50, 'x' => 140, 'y' => 220) entry9.place('height' => 25, 'width' => 450, 'x' => 140, 'y' => 250) entry10.place('height' => 25, 'width' => 50, 'x' => 140, 'y' => 280) entry11.place('height' => 25, 'width' => 450, 'x' => 140, 'y' => 310) entry12.place('height' => 25, 'width' => 50, 'x' => 140, 'y' => 340) entry13.place('height' => 25, 'width' => 250, 'x' => 140, 'y' => 370) # Botón de ok butfin = TkButton.new(wopciones) butfin.configure('text' => 'Ok') butfin.command { $texto = varia1.value $fuente = varia2.value $punto = varia3.value $italic = varia4.value $tcolor = varia5.value $ucolor = varia6.value $bcolor = varia7.value $bsize = varia8.value $ocolor = varia9.value $lsize = varia10.value $ecolor = varia11.value $amount = varia12.value $direct = varia13.value wopciones.destroy } butfin.place('x'=>460.0,'y'=>400.0) # Botón de cancelar butcanc = TkButton.new(wopciones) butcanc.configure('text'=> 'Cancelar') butcanc.command { wopciones.destroy } butcanc.place('x'=>510.0,'y'=>400) end def procesatexto # procesar texto exec( "3Dtext", "-t", $texto, "-f", $fuente, "-p", $punto, "-i", $italic, "-c", $tcolor, "-u", $ucolor, "-b", $bcolor, "-s", $bsize, "-o", $ocolor, "-l", $lsize, "-x", $ecolor, "-a", $amount, "-d", $direct, "3Dtextoruby.png") end # Variables $texto = "Marcelo Anelli" $fuente = "Arial" $punto = "48" $italic = "0" $tcolor = "navy" $ucolor = "white" $bcolor = "white" $bsize = "5" $ocolor = "black" $lsize = "0" $ecolor = "gray" $amount = "8" $direct = "northwest" # Abrir ventana root = TkRoot.new { title "macborde.rb"; minsize(400,100) } root['resizable'] = false, false root['geometry'] = '400x150+200+200' # Botón de control buttonexec = TkButton.new(root) buttonexec.configure('text' => 'Ejecutar') buttonexec.command { procesatexto() } buttonexec.place('x'=>260.0,'y'=>110.0) # Botón de opciones butopciones = TkButton.new(root) butopciones.configure('text' => 'Opciones') butopciones.command { opciones(root) } butopciones.place('x'=>175.0,'y'=>110.0) # Botón de salida butcancela = TkButton.new(root) butcancela.configure('text' => 'Salir') butcancela.command { exit } butcancela.place('x'=>335.0,'y'=>110.0) # Mostrar ventana principal Tk.mainloop # salir exit
