{"id":18733595,"url":"https://github.com/insightsengineering/hex-stickers","last_synced_at":"2025-04-12T18:31:56.417Z","repository":{"id":38340347,"uuid":"419979978","full_name":"insightsengineering/hex-stickers","owner":"insightsengineering","description":"hex sticker archive","archived":false,"fork":false,"pushed_at":"2025-01-07T11:29:29.000Z","size":47941,"stargazers_count":8,"open_issues_count":5,"forks_count":1,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-26T13:03:40.138Z","etag":null,"topics":["hex-stickers","r"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/insightsengineering.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://pharmaverse.org"]}},"created_at":"2021-10-22T05:44:40.000Z","updated_at":"2025-01-07T11:29:31.000Z","dependencies_parsed_at":"2024-12-20T10:41:07.052Z","dependency_job_id":null,"html_url":"https://github.com/insightsengineering/hex-stickers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insightsengineering%2Fhex-stickers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insightsengineering%2Fhex-stickers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insightsengineering%2Fhex-stickers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insightsengineering%2Fhex-stickers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insightsengineering","download_url":"https://codeload.github.com/insightsengineering/hex-stickers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248613554,"owners_count":21133532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hex-stickers","r"],"created_at":"2024-11-07T15:10:36.133Z","updated_at":"2025-04-12T18:31:51.401Z","avatar_url":"https://github.com/insightsengineering.png","language":"R","funding_links":["https://pharmaverse.org"],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n```{r getopenpharma, echo=FALSE,message=FALSE}\n# reference PNGs\nlogos \u003c- tools::file_path_sans_ext(dir(\"PNG\", pattern = \"\\\\.png$\"))\n\n# get it\nlibrary(magrittr)\n\nopenpharma_repos \u003c- readRDS(url(\n  \"https://github.com/openpharma/openpharma_log/blob/main/all-repos/data.rds?raw=true\"\n))\n\nrepositories \u003c- tibble::tibble(\n  repo = logos\n) %\u003e%\n  dplyr::left_join(\n    openpharma_repos,\n    by = \"repo\"\n  ) %\u003e%\n  dplyr::mutate(\n    description = dplyr::case_when(\n      is.na(description) ~ \"No description in github\",\n      TRUE ~ description\n    ),\n    Project = dplyr::case_when(\n      is.na(org) ~ as.character(glue::glue(\n        \"{repo} \u003cbr /\u003e\",\n        '\u003cp style=\"color:grey\"\u003eThis project is not tracked by openpharma.github.io\u003c/p\u003e'\n      )),\n      TRUE ~ as.character(glue::glue(\n        '\u003ca href=\"https://github.com/{org}/{repo}\"\u003e{org}/{repo}\u003c/a\u003e \u003cbr /\u003e',\n        \"\u003cp\u003e {description} \u003c/p\u003e\"\n      ))\n    )\n  )\n```\n\n# Hex Stickers\n\nProjects where we are involved.\n\n## Adding stickers\n\nTo add one, make sure to add your hex sticker under the format `EXACT_PACKAGE_NAME.FORMAT`\n\n- where `EXACT_PACKAGE_NAME` is the exact name of your R package,\n- and `FORMAT` is the file format of the hex sticker.\n\nFor example, if your package is called `BananaPudding`, and your hex sticker is an SVG, then add `BananaPudding.svg` to the [SVG](SVG) directory.\n\nThen, simply run `rmarkdown::render(\"README.Rmd\")` in R to render the `README.md` file, as it will also automatically generate the hexwall and the thumbnail(s) for your logo(s).\n\n## Hex sticker wall\n\n```{r, echo=FALSE,message=FALSE}\n# from https://github.com/mitchelloharawild/hexwall/blob/master/hexwall.R\n\n# Dependencies\nlibrary(magick)\nlibrary(purrr)\n\n# path:             The path to a folder of hexagon stickers\n# sticker_row_size: The number of stickers in the longest row\n# sticker_width:    The width of each sticker in pixels\n# remove_small:     Should hexagons smaller than the sticker_width be removed?\n# coords:           A data.frame of coordinates defining the placement of hexagons\n# scale_coords:     Should the coordinates be scaled to the hexagon size?\n# remove_size:      Should hexagons of an abnormal size be removed?\n# sort_mode:        How should the files be sorted?\n# background_color: The colour of the background canvas\n# n_stickers:       The number of hexagons to produce. Recycled in file order.\nhexwall \u003c- function(path,\n                    sticker_row_size = 16,\n                    sticker_width = 500,\n                    remove_small = TRUE,\n                    total_stickers = NULL,\n                    remove_size = TRUE,\n                    scale_coords = TRUE,\n                    sort_mode = c(\"filename\", \"random\", \"color\", \"colour\"),\n                    background_color = \"white\",\n                    n_stickers = NULL) {\n  sort_mode \u003c- match.arg(sort_mode)\n\n  # Load stickers\n  sticker_files \u003c- list.files(path)\n  if (is.null(n_stickers)) n_stickers \u003c- length(sticker_files)\n  sticker_files \u003c- rep_len(sticker_files, n_stickers)\n  stickers \u003c- file.path(path, sticker_files) %\u003e%\n    map(function(path) {\n      intermediate \u003c- switch(tools::file_ext(path),\n        svg = image_read_svg(path),\n        pdf = image_read_pdf(path),\n        image_read(path)\n      )\n      # Scale down to avoid cache exhausted errors\n      result \u003c- image_resize(intermediate, \"400x400\")\n      image_destroy(intermediate)\n      result\n    }) %\u003e%\n    map(image_transparent, \"white\") %\u003e%\n    map(image_trim) %\u003e%\n    set_names(sticker_files)\n\n  # Low resolution stickers\n  low_res \u003c- stickers %\u003e%\n    map_lgl(~ remove_small \u0026\u0026 image_info(.x)$width \u003c (sticker_width - 1) / 2 \u0026\u0026 image_info(.x)$format != \"svg\")\n  which(low_res)\n\n  stickers \u003c- stickers %\u003e%\n    map(image_scale, sticker_width)\n\n  # Incorrectly sized stickers\n  bad_size \u003c- stickers %\u003e%\n    map_lgl(\n      ~ remove_size \u0026\u0026 with(\n        image_info(.x),\n        height \u003c (median(height) - 2) | height \u003e (median(height) + 2)\n      )\n    )\n  which(bad_size)\n\n  # Remove bad stickers\n  sticker_rm \u003c- low_res | bad_size\n  stickers \u003c- stickers[!sticker_rm]\n\n  if (any(sticker_rm)) {\n    message(sprintf(\n      \"Automatically removed %i incompatible stickers: %s\",\n      sum(sticker_rm), paste0(names(sticker_rm[sticker_rm]), collapse = \", \")\n    ))\n  }\n\n  if (is.null(total_stickers)) {\n    total_stickers \u003c- length(stickers)\n  }\n\n  # Coerce sticker sizes\n  sticker_height \u003c- stickers %\u003e%\n    map(image_info) %\u003e%\n    map_dbl(\"height\") %\u003e%\n    median()\n  stickers \u003c- stickers %\u003e%\n    map(image_resize, paste0(sticker_width, \"x\", sticker_height, \"!\"))\n\n  # Repeat stickers sorted by file name\n  stickers \u003c- rep_len(stickers, total_stickers)\n\n  if (sort_mode == \"random\") {\n    # Randomly arrange stickers\n    stickers \u003c- sample(c(\n      stickers,\n      sample(\n        stickers,\n        total_stickers - length(stickers),\n        replace = TRUE\n      )\n    ))\n  } else if (sort_mode %in% c(\"color\", \"colour\")) {\n    # Sort stickers by colour\n    sticker_col \u003c- stickers %\u003e%\n      map(image_resize, \"1x1!\") %\u003e%\n      map(image_data) %\u003e%\n      map(~ paste0(\"#\", paste0(.[, , 1], collapse = \"\"))) %\u003e%\n      map(colorspace::hex2RGB) %\u003e%\n      map(as, \"HSV\") %\u003e%\n      map_dbl(~ .@coords[, 1]) %\u003e%\n      sort(index.return = TRUE) %\u003e%\n      .$ix\n\n    stickers \u003c- stickers[sticker_col]\n  }\n\n  # Arrange rows of stickers into images\n  sticker_col_size \u003c- ceiling(length(stickers) / (sticker_row_size - 0.5))\n  row_lens \u003c- rep(c(\n    sticker_row_size,\n    sticker_row_size - 1\n  ), length.out = sticker_col_size)\n  row_lens[\n    length(row_lens)\n  ] \u003c- row_lens[length(row_lens)] - (length(stickers) - sum(row_lens))\n  sticker_rows \u003c- map2(\n    row_lens, cumsum(row_lens),\n    ~ seq(.y - .x + 1, by = 1, length.out = .x)\n  ) %\u003e%\n    map(~ stickers[.x] %\u003e%\n      exec(c, !!!.) %\u003e%\n      image_append())\n\n  # Add stickers to canvas\n  canvas \u003c- image_blank(\n    sticker_row_size * sticker_width,\n    sticker_height + (sticker_col_size - 1) * sticker_height / 1.33526, \"white\"\n  )\n  reduce2(sticker_rows, seq_along(sticker_rows),\n    ~ image_composite(\n      ..1, ..2,\n      offset = paste0(\n        \"+\",\n        (\n          (..3 - 1) %% 2) * sticker_width / 2, \"+\",\n        round((..3 - 1) * sticker_height / 1.33526)\n      )\n    ),\n    .init = canvas\n  )\n}\n\nimage \u003c- hexwall(\"PNG\",\n  sticker_row_size = 6, sticker_width = 120,\n  sort_mode = \"colour\",\n)\n\nimage_write(image, path = \"hexwall.png\", format = \"png\")\n```\n\n![](hexwall.png)\n\nHex details.\n\n```{r, echo = FALSE, message = FALSE}\nlibrary(magick)\npng \u003c- paste0(\"PNG/\", logos, \".png\")\nsvg \u003c- paste0(\"SVG/\", logos, \".svg\")\nthumb \u003c- paste0(\"thumbs/\", logos, \".png\")\nresize \u003c- function(path_in, path_out) {\n  image \u003c- image_read(path_in)\n  image \u003c- image_resize(image, \"278x\")\n  image_write(image, path_out)\n}\noutdated \u003c- !file.exists(thumb) | file.mtime(thumb) \u003c file.mtime(png)\ninvisible(Map(resize, png[outdated], thumb[outdated]))\n```\n\n```{r, results = \"asis\", echo = FALSE}\nimg \u003c- glue::glue(\n  '\u003cimg alt=\"Logo for {logos}\" src=\"{thumb}\" height=\"139\"\u003e'\n)\npng_link \u003c- glue::glue('\u003ca href=\"{png}\"\u003e{logos}.png\u003c/a\u003e')\ncell \u003c- paste0(\n  \"\u003ctd\u003e\", img, \"\u003cbr /\u003e\",\n  repositories$Project,\n  png_link,\n  \"\u003c/td\u003e\"\n)\ncols \u003c- 3\nrows \u003c- ceiling(length(cell) / cols)\nrow_id \u003c- rep(seq_len(rows), each = cols, length.out = length(cell))\nrow_cells \u003c- split(cell, row_id)\ncat(\"\u003ctable\u003e\\n\")\ncat(paste0(\"\u003ctr\u003e\", sapply(row_cells, paste, collapse = \"\"), \"\u003c/tr\u003e\"), sep = \"\")\ncat(\"\u003c/table\u003e\\n\")\n```\n\n## HTML\n\nGenerated HTML wall of hexes at https://insightsengineering.github.io/hex-stickers\n\n```{r, include = FALSE}\ninput_data \u003c- tibble::tibble(\n  package = logos,\n  png_link = png\n  ) %\u003e%\n  dplyr::left_join(\n    repositories,\n    by = c(\"package\" = \"repo\")\n  ) %\u003e%\n  dplyr::select(package, png_link, full_name) %\u003e%\n  dplyr::mutate(\n    repo_link = glue::glue(\n      '\u003ca href=\"https://github.com/{full_name}\"\u003e{full_name}\u003c/a\u003e'\n    ),\n    png_link = glue::glue(\"https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/{png_link}\")\n  )\n\nhexes \u003c- NULL\nfor (i in 1:nrow(input_data)){\n\n  i_row \u003c- input_data[i,]\n\n  hexes \u003c- paste0(\n    hexes,\n    \"\n\n    \",\n    glue::glue(\n     '\u003cli class=\"hex\"\u003e\n        \u003cdiv class=\"hexIn\"\u003e\n          \u003ca class=\"hexLink\" href=\"https://github.com/{i_row$full_name}\"\u003e\n            \u003cimg src=\"{i_row$png_link}\" alt=\"\" \u003e\n          \u003c/a\u003e\n        \u003c/div\u003e\n      \u003c/li\u003e\n\n     '\n    )\n  )\n}\n\npaste0(\n  '\n  \u003c!doctype html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003e\u003c/title\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"hex.css\"\u003e\n    \u003clink href=\"https://fonts.googleapis.com/css?family=Raleway:300\" rel=\"stylesheet\" type=\"text/css\"\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cul id=\"hexGrid\"\u003e\n  ',\n  hexes,\n  \"\n      \u003c/ul\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n  \"\n) %\u003e% write(\n  file = \"docs/index.html\"\n)\n```\n\n# Acknowledgements\n\nCode for this repo has been forked from `rstudio/hex-stickers` and `mitchelloharawild/hexwall`.\nCopyright of the images is defined by the sourced project (see source repo for hex-sticker)\n\n## Stargazers\n\n[![Stargazers repo roster for @insightsengineering/hex-stickers](https://reporoster.com/stars/dark/insightsengineering/hex-stickers)](https://github.com/insightsengineering/hex-stickers/stargazers)\n\n[![Stargazers over time](https://starchart.cc/insightsengineering/hex-stickers.svg)](https://starchart.cc/insightsengineering/hex-stickers)\n\n## Forkers\n\n[![Forkers repo roster for @insightsengineering/hex-stickers](https://reporoster.com/forks/dark/insightsengineering/hex-stickers)](https://github.com/insightsengineering/hex-stickers/network/members)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsightsengineering%2Fhex-stickers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsightsengineering%2Fhex-stickers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsightsengineering%2Fhex-stickers/lists"}