<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: bar code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 09:01:41 GMT</pubDate>
    <description>DZone Snippets: bar code</description>
    <item>
      <title>Simple % bar in a pdf using Ruby</title>
      <link>http://snippets.dzone.com/posts/show/3648</link>
      <description>Will create a bar, filled to the percentage provided, and draw it in a PDF.&lt;br /&gt;&lt;br /&gt;Requires PDF Writer, call method after setting up PDF to @pdf&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def generate_pdf_bar(p = 50, x = 10, y = 'center', w = 200, h = 10)&lt;br /&gt;     # adjustments&lt;br /&gt;    if y == 'center'&lt;br /&gt;      y = @pdf.page_height / 2 - h&lt;br /&gt;    else&lt;br /&gt;      y = @pdf.page_height - y - h&lt;br /&gt;    end&lt;br /&gt;    p = w / 100 * p&lt;br /&gt;&lt;br /&gt;      # Empty&lt;br /&gt;    @pdf.stroke_color  Color::RGB::Black&lt;br /&gt;    @pdf.rectangle(x, y, w, h).close_stroke&lt;br /&gt;&lt;br /&gt;     # Fill&lt;br /&gt;    @pdf.fill_color    Color::RGB::Black&lt;br /&gt;    @pdf.stroke_color  Color::RGB::Black&lt;br /&gt;    @pdf.rectangle(x, y, p, h).close_fill_stroke&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 08 Mar 2007 12:01:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3648</guid>
      <author>abscond (James Darling)</author>
    </item>
    <item>
      <title>Showing message on status bar</title>
      <link>http://snippets.dzone.com/posts/show/1642</link>
      <description>There's an empty space below app.title that we can&lt;br /&gt;use as a status bar. So, I modify this &lt;a href=http://bigbold.com/snippets/posts/show/839&gt;recipe&lt;/a&gt; and &lt;br /&gt;make it into a module. (need fgimage.pyd from &lt;a href=http://pymbian.sourceforge.net/misc/fgimage-v0.20051022.zip&gt;here&lt;/a&gt;)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# status.py&lt;br /&gt;from graphics import *&lt;br /&gt;import fgimage&lt;br /&gt;__all__ = ["status_on", "status_off"]&lt;br /&gt;&lt;br /&gt;bar = Image.new((119,13))&lt;br /&gt;bgcolor = screenshot().getpixel((0,0))[0]&lt;br /&gt;fg = fgimage.FGImage()&lt;br /&gt;&lt;br /&gt;def status_on(message=None):&lt;br /&gt;    if message is not None:&lt;br /&gt;        bar.clear(bgcolor)&lt;br /&gt;        bar.text((0,11), unicode(message), 0xffffff)&lt;br /&gt;    fg.set(57,30, bar._bitmapapi())&lt;br /&gt;&lt;br /&gt;def status_off():&lt;br /&gt;    fg.unset()&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;You can use it easily this way&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; from status import *&lt;br /&gt;&gt;&gt;&gt; status_on('Hello world')  # show it&lt;br /&gt;&gt;&gt;&gt; status_off()              # hide it&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;See a &lt;a href=http://www.frappr.com/pys60/photo/1501182&gt;screenshot&lt;/a&gt;.</description>
      <pubDate>Mon, 06 Mar 2006 20:58:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1642</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
