Coder Social home page Coder Social logo

Comments (6)

hadley avatar hadley commented on May 29, 2024

Hmmmmm:

1.73/2 # hex.bin spec
#> [1] 0.865
2206/2557 # current recommendation
#> [1] 0.8627298
2214/2557
#> [1] 0.8658584
2206/2547
#> [1] 0.866117

Created on 2020-08-19 by the reprex package (v0.3.0)

I suspect this hasn't been a problem since the munging of the aspect ratio is so minor.

It's probably worth changing the recommendation, but if we do that I'd rather pick nicer numbers than 2206/2557 etc. Any thoughts?

from hex-stickers.

schloerke avatar schloerke commented on May 29, 2024

These dimensions are close to integer values when scaled.

library(magrittr)
close_integers <- function(digits) {
  (1:5000 * sqrt(3) / 2) %>% 
    round(digits = digits) %>% 
    as.character() %>% 
    grepl(".", ., fixed = TRUE) %>% 
    magrittr::not() %>% 
    which() %>% 
    setNames(., (. * sqrt(3) / 2) %>% round()) %>% 
    as.list() %>% 
    {tibble::tibble(d = as.numeric(names(.)), D = unlist(unname(.)))} %>% 
    print(n = Inf)
}
close_integers(2)
#> # A tibble: 50 x 2
#>        d     D
#>    <dbl> <int>
#>  1    84    97
#>  2   181   209
#>  3   265   306
#>  4   362   418
#>  5   446   515
#>  6   543   627
#>  7   627   724
#>  8   724   836
#>  9   808   933
#> 10   905  1045
#> 11   989  1142
#> 12  1086  1254
#> 13  1170  1351
#> 14  1254  1448
#> 15  1267  1463
#> 16  1351  1560
#> 17  1435  1657
#> 18  1532  1769
#> 19  1616  1866
#> 20  1713  1978
#> 21  1797  2075
#> 22  1894  2187
#> 23  1978  2284
#> 24  2075  2396
#> 25  2159  2493
#> 26  2256  2605
#> 27  2340  2702
#> 28  2437  2814
#> 29  2521  2911
#> 30  2605  3008
#> 31  2702  3120
#> 32  2786  3217
#> 33  2883  3329
#> 34  2967  3426
#> 35  3064  3538
#> 36  3148  3635
#> 37  3245  3747
#> 38  3329  3844
#> 39  3426  3956
#> 40  3510  4053
#> 41  3607  4165
#> 42  3691  4262
#> 43  3775  4359
#> 44  3788  4374
#> 45  3872  4471
#> 46  3956  4568
#> 47  4053  4680
#> 48  4137  4777
#> 49  4234  4889
#> 50  4318  4986
close_integers(3)
#> # A tibble: 5 x 2
#>       d     D
#>   <dbl> <int>
#> 1  1170  1351
#> 2  1351  1560
#> 3  2521  2911
#> 4  3691  4262
#> 5  3872  4471
close_integers(4)
#> # A tibble: 1 x 2
#>       d     D
#>   <dbl> <int>
#> 1  2521  2911

Created on 2020-08-19 by the reprex package (v0.3.0)

@hadley While they are not "pretty" numbers, 2521 x 2911 is a perfect match for a hexagon.

2911 * sqrt(3) / 2
#> [1] 2521

Created on 2020-08-19 by the reprex package (v0.3.0)

from hex-stickers.

schloerke avatar schloerke commented on May 29, 2024

There are also these pretty numbers:

close_integers(1) %>% dplyr::filter(as.character(d) %>% grepl("00$", .) | as.character(D) %>% grepl("00$", .))
#> # A tibble: 7 x 2
#>       d     D
#>   <dbl> <int>
#> 1   433   500
#> 2   866  1000
#> 3  1299  1500
#> 4  1500  1732
#> 5  1700  1963
#> 6  3200  3695
#> 7  3400  3926

close_integers(1) %>% dplyr::filter(as.character(d) %>% grepl("0$", .) & as.character(D) %>% grepl("0$", .))
#> # A tibble: 4 x 2
#>       d     D
#>   <dbl> <int>
#> 1   840   970
#> 2  1810  2090
#> 3  2650  3060
#> 4  3620  4180

2650 x 3060 isn't bad. I still put my vote in for 2521 x 2911 as it's an arbitrary number in the end, but requires no visual adjustments from the svg.

from hex-stickers.

hadley avatar hadley commented on May 29, 2024

2521 x 2911 sounds good. Want to do a PR to contributing.md?

from hex-stickers.

hadley avatar hadley commented on May 29, 2024

And the pull request template?

from hex-stickers.

schloerke avatar schloerke commented on May 29, 2024

@hadley Will do!

from hex-stickers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.