Package 'pikchr'

Title: R Wrapper for 'pikchr' (PIC) Diagram Language
Description: An 'R' interface to 'pikchr' (<https://pikchr.org>, pronounced “picture”), a 'PIC'-like markup language for creating diagrams within technical documentation. Originally developed by Brian Kernighan, 'PIC' has been adapted into 'pikchr' by D. Richard Hipp, the creator of 'SQLite'. 'pikchr' is designed to be embedded in fenced code blocks of Markdown or other documentation markup languages, making it ideal for generating diagrams in text-based formats. This package allows R users to seamlessly integrate the descriptive syntax of 'pikchr' for diagram creation directly within the 'R' environment.
Authors: Andre Leite [aut, cre], Hugo Vaconcelos [aut], Richard Hipp [ctb], Brian Kernighan [ctb]
Maintainer: Andre Leite <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2025-02-14 05:58:50 UTC
Source: https://github.com/strategicprojects/pikchr

Help Index


Google Font List

Description

List of fonts and its stytles on google fonts site. Report ...

Usage

google_fonts

Format

## 'google_fonts' A data frame with 1,718 rows and 2 columns:

family

Font family names

styles

Font styles

Source

<https://fonts.google.com>


Convert Pikchr Code to SVG

Description

This function converts a diagram description written in the Pikchr language into an SVG (Scalable Vector Graphics) format. Pikchr is a diagram language inspired by PIC, and this function allows you to easily embed Pikchr diagrams as SVG images in your HTML or Markdown documents.

Usage

pikchr(
  code,
  width = NULL,
  height = NULL,
  fontSize = "100%",
  fontFamily = "Jost",
  class = "pikchr",
  align = "none",
  css = NULL,
  margin = NULL,
  svgOnly = FALSE
)

Arguments

code

A character string containing the diagram code written in the Pikchr language.

width

A character string representing the width of the rendered SVG. It accepts standard HTML values such as percentages ("75%"), pixels ("300px"), or "auto". Defaults to "75%".

height

A character string representing the height of the rendered SVG. It accepts standard HTML values such as pixels ("300px") or "auto". Defaults to "auto".

fontSize

A character string specifying the font size of the text within the SVG. It accepts standard HTML values such as percentages ("80%"), pixels, or keywords ("large"). Defaults to "80%".

fontFamily

A character string specifying the font family for the text in the diagram. Common values include "inherit" (to use the page's default font), "Arial", "Times New Roman", etc. Defaults to "inherit".

class

A character string specifying a CSS class to apply to the SVG. This can be used to style the SVG with external CSS rules. Defaults to "pikchr".

align

A character string specifying the alignment of the SVG within its container. Options are "center" (default), "left", or "right". If set to "none", no alignment is applied.

css

A character string containing extra CSS styles to apply directly to the SVG element. This allows additional customization beyond width, height, and font settings. If NULL, no extra styles are applied.

margin

A character string specifying the margin around the SVG element, formatted like a CSS margin rule (e.g., "10px 0 10px 0"). Defaults to "10px 0 10px 0".

svgOnly

Logical, whether to return only the raw SVG code (TRUE) or open the diagram in the Viewer window (FALSE, default).

Value

A character string containing the SVG diagram code if svgOnly = TRUE. Otherwise, the function opens the diagram in the Viewer window.

Examples

if(interactive()) {
pikchr('
  arrow right 200% "Rmarkdown" "Source"
  box rad 10px "Rmarkdown" "(knitr)" fit
  arrow right 200% "HTML+SVG" "Output"
  arrow <-> down from last box.s
  box same "Pikchr" "(pikchr.c)" fit
  ')
  }