---
title: horizontal
description: > 
  Design and printing of horizontal labels using huito.
vignette: >
  %\VignetteIndexEntry{horizontal}
  %\VignetteEngine{quarto::html}
  %\VignetteEncoding{UTF-8}
knitr:
  opts_chunk: 
    collapse: true
    comment: '#>'
    echo: true
    warning: false
    message: false
editor_options: 
  chunk_output_type: console
---

```{r setup}
#| include: false
source("https://raw.githubusercontent.com/Flavjack/inti/master/pkgdown/favicon/docs.r")
```

# Create the experimental field book

The field book experimental design was deployed with `inti` package <https://inkaverse.com/articles/apps.html>

```{r}
library(inti)

treats <- data.frame(condition = c("irrigated", "drought")
                     , genotypes = c("choclito", "salcedo", "pandela", "puno"))

fb <- tarpuy_design(data = treats
                    , nfactors = 2
                    , type = "rcbd"
                    , rep = 3
                    , project = "inkaverse"
                    ) 

fb %>% web_table()
```

# Customize the label layout

The label layout can be customized by combining text, images and QR codes. Each layer can use values from the experimental field book, allowing automatic generation of labels for every experimental plot.

Load package and import fonts.

```{r}
library(huito)

font <- c("Permanent Marker", "Tillana", "Courgette")

huito_fonts(font)
```

> You can find more fonts in <https://fonts.google.com/>

# Label design

```{r}
label <- fb %>%  
  label_layout(size = c(10, 2.5)
               , border_color = "blue"
               ) %>%
  include_image(
    value = "https://flavjack.github.io/inti/img/inkaverse.png"
    , size = c(2.1, 2.4)
    , position = c(1.2, 1.25)
    # , opts = list("image_scale(200)", "image_noise()")
    ) %>%
  include_barcode(
     value = "barcode"
     , size = c(2.5, 2.5)
     , position = c(8.2, 1.25)
     ) %>%
  include_text(value = "INKAVERSE"
               , position = c(4.6, 2)
               , size = 20
               , font = font[1]
               , fontface = "bold"
               ) %>%
  include_text(value = "condition"
               , position = c(2.4, 1.2)
               , size = 12
               , font = font[2]
               , opts = list(hjust = 0.0, vjust = 0.0) 
               , prefix = "Irrigation: "
               , fontface = "bold"
               ) %>%
  include_text(value = "genotypes"
               , position = c(2.4, 0.5)
               , size = 12
               , color = "#009966"
               , font = font[2]
               , opts = list(hjust = 0.0, vjust = 0.0)
               , prefix = "Genotipo: "
               , fontface = "bold"
               ) %>% 
  include_text(value = "plots"
               , position = c(9.7, 1.25)
               , angle = 90
               , size = 12
               , color = "red"
               , font = font[3]
               , prefix = "Plot: "
               ) 
```

## Preview mode

The preview mode `label_print(mode = "preview")` generate a example of the label design from a random row of the data set.

```{r}
label %>% 
  label_print(mode = "preview")
```

## Complete mode

If you want generate the complete labels list, change: `label_print(mode = "complete")`.

```{r}
label %>% 
  label_print(mode = "complete", filename = "horizontal"
              , nlabels = 10)
```

<embed src="horizontal.pdf" height="600" width="100%" alt="pdf" pluginspage="http://www.adobe.com/products/acrobat/readstep2.html">

