From chris at postal-code.com Mon Jan 7 19:45:37 2008 From: chris at postal-code.com (Chris Cummer) Date: Mon, 7 Jan 2008 16:45:37 -0800 Subject: [Rubyosa-discuss] Defining a Color for OmniGraffle? Message-ID: <02214992-7118-4D42-B384-83CBE3E28EF3@postal-code.com> Hello I'm attempting to use RubyOSA to script OmniGraffle and its coming along pretty nicely but I'm stuck on how to define a color in the following code: og = OSA.app( "OmniGraffle 4" ) title_color = og.make( OSA::OmniGraffle4::Color, :with_properties => { :r => 45535, g => 5, :b =>65535 } ) #[45535,45535,65535] obviously that, and numerous permutations of that (ie: :red, :R, :Red) don't work. Alas the help docs generated by RDoc refer to the Color class as: Class OSA::OmniGraffle4::Color Parent: OSA::OmniGraffle4::Item A color. which leaves a bit to be desired. Anyone with any ideas or experience attempting this? Regards Chris From chris at postal-code.com Mon Jan 7 23:01:03 2008 From: chris at postal-code.com (Chris Cummer) Date: Mon, 7 Jan 2008 20:01:03 -0800 Subject: [Rubyosa-discuss] Defining a Color for OmniGraffle? In-Reply-To: <7F1AE6DE-7AF3-486C-A212-24EE372BDD45@gmail.com> References: <02214992-7118-4D42-B384-83CBE3E28EF3@postal-code.com> <7F1AE6DE-7AF3-486C-A212-24EE372BDD45@gmail.com> Message-ID: <63251C58-D509-4448-B900-1EE0C77289F6@postal-code.com> On 7-Jan-08, at 5:23 PM, dmw_rubyosa at spamex.com wrote: > This _may_ be of help. It took me a while to figure out that OG > seems to be expecting its RGB values in floating point rather than > hex format. Below is a function I hacked together that takes an RGB > value as a string (ie. 'ffffff' is white), and returns a color value > that OG expects. However, I was using rb-appscript at the time, so > YMMV. Also, I'm no Ruby pro, so there is probably a better way to > do this. > > def rgb_to_og(color) > r = color[0..1].to_i(16).to_f > g = color[2..3].to_i(16).to_f > b = color[4..5].to_i(16).to_f > return [r/0xff,g/0xff,b/0xff] > end Interesting, that's not a format I would have thought of. Any chance you have a code example implementing that? I've plugged it into my code as-is but alas it doesn't work, and silently. Thanks for the idea! Chris From chris at postal-code.com Mon Jan 7 23:22:02 2008 From: chris at postal-code.com (Chris Cummer) Date: Mon, 7 Jan 2008 20:22:02 -0800 Subject: [Rubyosa-discuss] Defining a Color for OmniGraffle? In-Reply-To: <63251C58-D509-4448-B900-1EE0C77289F6@postal-code.com> References: <02214992-7118-4D42-B384-83CBE3E28EF3@postal-code.com> <7F1AE6DE-7AF3-486C-A212-24EE372BDD45@gmail.com> <63251C58-D509-4448-B900-1EE0C77289F6@postal-code.com> Message-ID: <899C0718-10CC-4DB7-BA94-84459E7C0FC3@postal-code.com> On 7-Jan-08, at 8:01 PM, Chris Cummer wrote: > On 7-Jan-08, at 5:23 PM, dmw_rubyosa at spamex.com wrote: > >> This _may_ be of help. It took me a while to figure out that OG >> seems to be expecting its RGB values in floating point rather than >> hex format. Below is a function I hacked together that takes an RGB >> value as a string (ie. 'ffffff' is white), and returns a color value >> that OG expects. However, I was using rb-appscript at the time, so >> YMMV. Also, I'm no Ruby pro, so there is probably a better way to >> do this. >> >> def rgb_to_og(color) >> r = color[0..1].to_i(16).to_f >> g = color[2..3].to_i(16).to_f >> b = color[4..5].to_i(16).to_f >> return [r/0xff,g/0xff,b/0xff] >> end > > Interesting, that's not a format I would have thought of. Any chance > you have a code example implementing that? I've plugged it into my > code as-is but alas it doesn't work, and silently. More interesting, your advice to make it a float worked perfectly for changing the canvas background color to purple: irb(main):002:0> require 'rubygems' irb(main):004:0> require 'rbosa' irb(main):008:0> og = OSA.app( "OmniGraffle\ 4" ) irb(main):010:0> og.make( OSA::OmniGraffle4::Document, :with_properties => {:name => "test"} ) irb(main):013:0> og.windows[0].canvas.canvascolor = [45535.0,45535.0,65535.0] But using that same format doesn't affect the background color of a Shape object: og.make( OSA::OmniGraffle4::Shape, :at => og .windows [0 ].canvas .graphics[ og.windows[0].canvas.graphics.length ], :with_properties => { :origin => [ 10, 10 ], :size => [ 200, 20 ], :name => "test_shape", :fill_color => [65535.0,45535.0,65535.0], :text => { :size => 12, :text => "test_shape", :alignment => 'OTa1' } } ) Hmm.... From keenan at thebrocks.net Tue Jan 8 12:03:25 2008 From: keenan at thebrocks.net (Keenan Brock) Date: Tue, 8 Jan 2008 12:03:25 -0500 Subject: [Rubyosa-discuss] Defining a Color for OmniGraffle? In-Reply-To: <899C0718-10CC-4DB7-BA94-84459E7C0FC3@postal-code.com> References: <02214992-7118-4D42-B384-83CBE3E28EF3@postal-code.com> <7F1AE6DE-7AF3-486C-A212-24EE372BDD45@gmail.com> <63251C58-D509-4448-B900-1EE0C77289F6@postal-code.com> <899C0718-10CC-4DB7-BA94-84459E7C0FC3@postal-code.com> Message-ID: <91506680801080903k6ba860a2w7cba6c4b1c83c5a8@mail.gmail.com> Chris, This is a great thread. Thanks, An alternative solution would be using DOT as input to OmniGraffle. Though OmniGraffle's DOT support is lacking IMHO. Please forward any blog articles you write on this and if possible, get the code into the rubyosa samples. --Keenan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20080108/7cab7f3d/attachment.html From chris at postal-code.com Thu Jan 10 00:05:14 2008 From: chris at postal-code.com (Chris Cummer) Date: Wed, 9 Jan 2008 21:05:14 -0800 Subject: [Rubyosa-discuss] Defining a Color for OmniGraffle? In-Reply-To: <91506680801080903k6ba860a2w7cba6c4b1c83c5a8@mail.gmail.com> References: <02214992-7118-4D42-B384-83CBE3E28EF3@postal-code.com> <7F1AE6DE-7AF3-486C-A212-24EE372BDD45@gmail.com> <63251C58-D509-4448-B900-1EE0C77289F6@postal-code.com> <899C0718-10CC-4DB7-BA94-84459E7C0FC3@postal-code.com> <91506680801080903k6ba860a2w7cba6c4b1c83c5a8@mail.gmail.com> Message-ID: On 8-Jan-08, at 9:03 AM, Keenan Brock wrote: > This is a great thread. The closest I've come to an explanation so far is that when dumping the properties of a Canvas, canvasColor is listed like so: :canvasColor => [45535, 45535, 25535] which succeeds. The fill color of a Shape gets listed like so: :"fillColor" => [65535.0,65535.0,65535.0] which fails. The quotes around the property name in the symbol are evidently significant but I don't know what they signify. > An alternative solution would be using DOT as input to OmniGraffle. > Though OmniGraffle's DOT support is lacking IMHO. I looked into that but the DOT syntax seems so brutally convoluted for doing complex diagrams that I decided to abandon it entirely. To be honest I've also stopped using rbosa for the time being and have instead switched to rb-appscript (though my code contains a switch to flip between implementations). Thus far I've been able to make further progress with rb-appscript than I could before. Regards Chris