2014-03-14 49 views
2

我希望使一些邊界框變圓。有沒有辦法輕鬆做到這一點?蝦柵欄:如何使bounding_box四捨五入?

據我所知,人們可以分別繪製一個圓角框,並使其與文本框重疊,但這太麻煩了。這是因爲我正在使用網格來生成所有boudning框,而圓角框函數需要相對於整個文檔的參數。

回答

2

您可以創建一個bounding_box,然後在其周圍繪製一個rounded_rectangle,使用初始和當前光標位置來確定矩形的邊界。以下是我的代碼中的一個硬編碼示例:

PADDING = 10 
    @current_cursor = cursor 

    bounding_box([0, @current_cursor], width: WIDTH) do 
    image1 = "#{Rails.root}/app/assets/images/app-icon.png" 
    image2 = "#{Rails.root}/app/assets/images/gui-logo.png" 

    clinic_data = [[' '], 
        ['<font size="13"><b>Los Angeles Test Medical Center</b></font>'], 
        ['<font size="9">56 Berent Ave. New York, NY 07002</font>'], 
        ['<font size="9">Tel: 212-541-1900 Fax: 212-541-1199</font>'] 
    ] 
    clinic_table = make_table clinic_data, column_widths: [275], cell_style: {borders: {}, inline_format: true, padding: 1, align: :center} 

    data = [[{image: image1, image_width: 50, image_height: 50, position: :center, vposition: :center}, 
      '<font size="11">Structured Ultrasound Reporting<font>', 
      clinic_table, 
      {image: image2, image_width: 75, vposition: :center, position: :right}]] 

    table(data, column_widths: [75, 80, 275], cell_style: {borders: {}, inline_format: true, valign: :center}) 
    end 

    stroke do 
    rounded_rectangle [0, @current_cursor + 5], WIDTH + 5, @current_cursor - cursor + PADDING, 10 
    end