Skip to content

Commit dccd842

Browse files
authored
Merge pull request #31 from matt-dray/30-cairo-antialias
Fix issue with png output on Windows
2 parents 3f6eca8 + 149e4ec commit dccd842

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

R/hexagon.R

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,27 @@ open_device <- function(file_path, resolution = 300) {
5151
stop("Argument 'resolution' must be a numeric value.", call. = FALSE)
5252
}
5353

54-
grDevices::png(
55-
filename = file_path,
56-
width = 4.39,
57-
height = 5.08,
58-
units = "cm",
59-
res = resolution,
60-
bg = "transparent"
61-
)
54+
if (.Platform[["OS.type"]] == "windows") {
55+
grDevices::png(
56+
filename = file_path,
57+
width = 4.39,
58+
height = 5.08,
59+
units = "cm",
60+
res = resolution,
61+
bg = "transparent",
62+
type = "cairo",
63+
antialias = "none"
64+
)
65+
} else {
66+
grDevices::png(
67+
filename = file_path,
68+
width = 4.39,
69+
height = 5.08,
70+
units = "cm",
71+
res = resolution,
72+
bg = "transparent"
73+
)
74+
}
6275

6376
}
6477

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<!-- badges: start -->
44
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
55
[![R-CMD-check](https://github.com/matt-dray/gex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/matt-dray/gex/actions/workflows/R-CMD-check.yaml)
6+
[![Blog posts](https://img.shields.io/badge/rostrum.blog-posts-008900?labelColor=000000&logo=data%3Aimage%2Fgif%3Bbase64%2CR0lGODlhEAAQAPEAAAAAABWCBAAAAAAAACH5BAlkAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAAC55QkISIiEoQQQgghRBBCiCAIgiAIgiAIQiAIgSAIgiAIQiAIgRAEQiAQBAQCgUAQEAQEgYAgIAgIBAKBQBAQCAKBQEAgCAgEAoFAIAgEBAKBIBAQCAQCgUAgEAgCgUBAICAgICAgIBAgEBAgEBAgEBAgECAgICAgECAQIBAQIBAgECAgICAgICAgECAQECAQICAgICAgICAgEBAgEBAgEBAgICAgICAgECAQIBAQIBAgECAgICAgIBAgECAQECAQIBAgICAgIBAgIBAgEBAgECAgECAgICAgICAgECAgECAgQIAAAQIKAAAh%2BQQJZAACACwAAAAAEAAQAAAC55QkIiESIoQQQgghhAhCBCEIgiAIgiAIQiAIgSAIgiAIQiAIgRAEQiAQBAQCgUAQEAQEgYAgIAgIBAKBQBAQCAKBQEAgCAgEAoFAIAgEBAKBIBAQCAQCgUAgEAgCgUBAICAgICAgIBAgEBAgEBAgEBAgECAgICAgECAQIBAQIBAgECAgICAgICAgECAQECAQICAgICAgICAgEBAgEBAgEBAgICAgICAgECAQIBAQIBAgECAgICAgIBAgECAQECAQIBAgICAgIBAgIBAgEBAgECAgECAgICAgICAgECAgECAgQIAAAQIKAAA7)](https://www.rostrum.blog/index.html#category=gex)
67
<!-- badges: end -->
78

89
## What
@@ -95,13 +96,15 @@ That creates this absolutely stunning demo sticker, written to the specified `fi
9596

9697
Note that you can't rely on plot-window previews when you're developing your sticker (they lie).
9798
You must inspect the generated PNG file instead.
98-
From R, you could do this with a `system()` call:
99+
You could do this with a `system()` call from R:
99100

100101
``` r
101102
# Open the PNG hex image for inspection
102103
system(paste("open", temp_path))
103104
```
104105

106+
Try `start` rather than `open` on Windows.
107+
105108
## Related
106109

107110
For more established hex-making tools with R, try:

0 commit comments

Comments
 (0)