@@ -56,6 +56,7 @@ function PDFGenerator.new(options)
5656 resources = {},
5757 font_metrics = {},
5858 fonts = {},
59+ rgb_colors = {},
5960 last_font = { fontFamily = " Helvetica" , fontWeight = " normal" },
6061 current_table = {
6162 current_row = {
@@ -782,6 +783,7 @@ function PDFGenerator:drawLine(x1, y1, x2, y2, width, options)
782783
783784 return self
784785end
786+
785787-- Draw circle on current page
786788-- borderColor and fillColor should be hex color codes (e.g., "000000" for black)
787789function PDFGenerator :drawCircle (radius , borderWidth , borderStyle , borderColor , fillColor )
879881
880882-- Convert hex color to RGB values (0-1)
881883function PDFGenerator :hexToRGB (hex )
884+ self .rgb_colors = self .rgb_colors or {}
885+ if self .rgb_colors [hex ] then
886+ return self .rgb_colors [hex ]
887+ end
888+
882889 -- Remove '#' if present
883890 hex = hex :gsub (" #" , " " )
884891 -- If hex is 3 characters (shorthand), expand it to 6 characters
@@ -890,7 +897,8 @@ function PDFGenerator:hexToRGB(hex)
890897 local g = tonumber (hex :sub (3 , 4 ), 16 ) / 255
891898 local b = tonumber (hex :sub (5 , 6 ), 16 ) / 255
892899
893- return { r , g , b }
900+ self .rgb_colors [hex ] = { r , g , b }
901+ return self .rgb_colors [hex ]
894902end
895903
896904-- Draw rectangle on current page
0 commit comments