module HexaPDF::Utils::GraphicsHelpers

This module provides some helper functions for graphics.

Public Instance Methods

calculate_dimensions(width, height, rwidth: nil, rheight: nil)

Calculates and returns the requested dimensions for the rectangular object with the given width and height based on the following: options:

rwidth

The requested width. If rheight is not specified, it is chosen so that the aspect ratio is maintained. In case of width begin zero, height is used for the height.

rheight

The requested height. If rwidth is not specified, it is chosen so that the aspect ratio is maintained. In case of height begin zero, width is used for the width.

point_on_line(x0, y0, x1, y1, distance:)

Given two points p0 = (x0, y0) and p1 = (x1, y1), returns the point on the line through these points that is distance units away from p0.

v = p1 - p0
result = p0 + distance * v/norm(v)