module Thinreports::Generator::PDF::DrawShape
Public Instance Methods
draw_shape_ellipse(shape)
click to toggle source
@param [Thinreports::Core::Shape::Basic::Internal] shape
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 84 def draw_shape_ellipse(shape) cx, cy, rx, ry = shape.format.attributes.values_at('cx', 'cy', 'rx', 'ry') ellipse(cx, cy, rx, ry, build_graphic_attributes(shape.style.finalized_styles)) end
draw_shape_iblock(shape)
click to toggle source
@param [Thinreports::Core::Shape::ImageBlock::Internal] shape
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 46 def draw_shape_iblock(shape) return if blank_value?(shape.src) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') style = shape.style.finalized_styles image_box( shape.src, x, y, w, h, position_x: image_position_x(style['position-x']), position_y: image_position_y(style['position-y']), offset_x: style['offset-x'], offset_y: style['offset-y'] ) end
draw_shape_image(shape)
click to toggle source
@param [Thinreports::Core::Shape::Basic::Internal] shape
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 38 def draw_shape_image(shape) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') image_data = shape.format.attributes['data'] base64image(image_data['base64'], x, y, w, h) end
draw_shape_line(shape, dy1 = 0, dy2 = 0)
click to toggle source
@param [Thinreports::Core::Shape::Basic::Internal] shape
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 90 def draw_shape_line(shape, dy1 = 0, dy2 = 0) x1, y1, x2, y2 = shape.format.attributes.values_at('x1', 'y1', 'x2', 'y2') line(x1, y1 + dy1, x2, y2 + dy2, build_graphic_attributes(shape.style.finalized_styles)) end
draw_shape_pageno(shape, page_no, page_count)
click to toggle source
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 30 def draw_shape_pageno(shape, page_no, page_count) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') attrs = build_text_attributes(shape.style.finalized_styles) text_box(shape.build_format(page_no, page_count), x, y, w, h, attrs) end
draw_shape_rect(shape, dheight = 0)
click to toggle source
@param [Thinreports::Core::Shape::Basic::Internal] shape
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 96 def draw_shape_rect(shape, dheight = 0) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') rect_attributes = build_graphic_attributes(shape.style.finalized_styles) do |attrs| attrs[:radius] = shape.format.attributes['border-radius'] end rect(x, y, w, h + dheight, rect_attributes) end
draw_shape_tblock(shape, height: nil, overflow: nil, &block)
click to toggle source
@param [Thinreports::Core::Shape::TextBlock::Internal] shape @param [Numeric] height (nil) It will be used as rendering height if present.
Otherwise, the rendering height is the height of schema.
@param [:truncate, :shrink_to_fit, :expand] overflow (nil) It will be set the overflow attribute if present.
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 11 def draw_shape_tblock(shape, height: nil, overflow: nil, &block) x, y, w = shape.format.attributes.values_at('x', 'y', 'width') h = height || shape.format.attributes['height'] content = shape.real_value.to_s return if content.empty? attrs = build_text_attributes(shape.style.finalized_styles) attrs[:overflow] = overflow if overflow unless shape.multiple? content = content.tr("\n", ' ') attrs[:single] = true end text_box(content, x, y, w, h, attrs, &block) end
draw_shape_text(shape, dheight = 0)
click to toggle source
@param [Thinreports::Core::Shape::Text::Internal] shape
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 75 def draw_shape_text(shape, dheight = 0) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') text( shape.texts.join("\n"), x, y, w, h + dheight, build_text_attributes(shape.style.finalized_styles) ) end
shape_iblock_dimenions(shape)
click to toggle source
# File lib/thinreports/generator/pdf/document/draw_shape.rb, line 61 def shape_iblock_dimenions(shape) return nil if blank_value?(shape.src) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') style = shape.style.finalized_styles image_dimensions( shape.src, x, y, w, h, position_x: image_position_x(style['position-x']), position_y: image_position_y(style['position-y']) ) end