mirror of
https://github.com/Rucknium/misc-research.git
synced 2024-12-22 11:29:22 +00:00
Create Statistical Monero Logo project
This commit is contained in:
parent
31a58824c3
commit
299789cee7
5 changed files with 266 additions and 0 deletions
11
Statistical-Monero-Logo/README.md
Normal file
11
Statistical-Monero-Logo/README.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Statistical Monero Logo
|
||||||
|
These files create an animated gif that visually builds a Monero logo from random draws of a probability density function.
|
||||||
|
|
||||||
|
The probability density function was constructed from the coordinates embedded in this SVG file:
|
||||||
|
|
||||||
|
https://raw.githubusercontent.com/fluffypony/monero-logo-artefacts/master/Logo Subsequent%20Tweaks/monero%20file.svg
|
||||||
|
|
||||||
|
To create the gif, first run data-construction.R . This may take days to complete since over 50 million observations have to be drawn from a cumulative distribution function that is created through numerical integration. Then run gif-construction.R . For best results, it is recommended to install Cairo, which is software separate from R. Read gif-construction.R for more details.
|
||||||
|
|
||||||
|
The code itself is available under the MIT open source license. However, since the resultant gif is based on an SVG that is released under the CC BY-SA 4.0 license (the [Creative Commons Attribution-ShareAlike 4.0 International license](https://creativecommons.org/licenses/by-sa/4.0/)), it is probably the case that the gif inherits the specified CC license. This means that you can copy and redistribute the material in any medium or format, and remix, transform, and build upon the material for any purpose, even commercially. However, when doing so you must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests The Monero Project endorses you or your use.
|
||||||
|
|
BIN
Statistical-Monero-Logo/Statistical-Monero-Logo.gif
Normal file
BIN
Statistical-Monero-Logo/Statistical-Monero-Logo.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 829 KiB |
94
Statistical-Monero-Logo/data-construction.R
Normal file
94
Statistical-Monero-Logo/data-construction.R
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
# MIT License
|
||||||
|
|
||||||
|
# Copyright (c) 2021 Rucknium
|
||||||
|
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
# install.packages("rsvg")
|
||||||
|
# install.packages("grImport2")
|
||||||
|
# install.packages("GoFKernel")
|
||||||
|
|
||||||
|
library(rsvg)
|
||||||
|
library(grImport2)
|
||||||
|
library(GoFKernel)
|
||||||
|
|
||||||
|
M.svg <- grImport2::readPicture(rawToChar(rsvg::rsvg_svg("monero file.svg")))
|
||||||
|
# From https://raw.githubusercontent.com/fluffypony/monero-logo-artefacts/master/Logo Subsequent%20Tweaks/monero%20file.svg
|
||||||
|
# https://github.com/fluffypony/monero-logo-artefacts/tree/master/Logo%20Subsequent%20Tweaks
|
||||||
|
|
||||||
|
M.svg.grob <- grImport2::pictureGrob(M.svg)
|
||||||
|
|
||||||
|
M.outline <- data.frame(
|
||||||
|
x = M.svg.grob$children[[1]]$children[[2]]$children[[2]]$x,
|
||||||
|
y = M.svg.grob$children[[1]]$children[[2]]$children[[2]]$y)
|
||||||
|
|
||||||
|
M.outline$y <- (-1) * M.outline$y + max(abs(M.outline$y))
|
||||||
|
|
||||||
|
y.min <- min(M.outline$y)
|
||||||
|
|
||||||
|
M.outline <- M.outline[(-1) * (which.min(M.outline$x) + 1):(which.max(M.outline$x) - 1), ]
|
||||||
|
|
||||||
|
M.outline <- M.outline[(-1) * c(1, 9), ]
|
||||||
|
|
||||||
|
M.outline <- M.outline
|
||||||
|
|
||||||
|
M.outline$x <- M.outline$x - min(M.outline$x)
|
||||||
|
M.outline$x <- M.outline$x / max(M.outline$x)
|
||||||
|
|
||||||
|
M.outline$x[2] <- M.outline$x[2] - 1e-10
|
||||||
|
M.outline$x[5] <- M.outline$x[5] + 1e-10
|
||||||
|
# Must add very small offset so that the non-unique x's are not dropped
|
||||||
|
|
||||||
|
M.outline$y <- M.outline$y / integrate(approxfun(M.outline), 0, 1)$value
|
||||||
|
|
||||||
|
M.pdf <- approxfun(M.outline)
|
||||||
|
|
||||||
|
M.cdf <- function(x) {
|
||||||
|
f.vectorized <- Vectorize(function(y) {integrate(approxfun(M.outline), 0, y)$value})
|
||||||
|
f.vectorized(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
M.inverse.cdf <- Vectorize(GoFKernel::inverse(M.cdf, lower = 0, upper = 1))
|
||||||
|
|
||||||
|
xmr.orange <- M.svg.grob$children[[1]]$children[[1]]$gp$fill
|
||||||
|
# "#FF6600FF"
|
||||||
|
xmr.grey <- M.svg.grob$children[[1]]$children[[2]]$gp$fill
|
||||||
|
# "#4C4C4CFF"
|
||||||
|
|
||||||
|
save(M.outline, xmr.orange, xmr.grey, file = "logo-data.Rdata")
|
||||||
|
|
||||||
|
|
||||||
|
set.seed(314)
|
||||||
|
|
||||||
|
generated.logo.observations <- M.inverse.cdf(runif(10))
|
||||||
|
|
||||||
|
# Running this loop may take days since numerical integration is slow.
|
||||||
|
for ( i in 3:48) {
|
||||||
|
|
||||||
|
generated.logo.observations <-
|
||||||
|
c(generated.logo.observations, M.inverse.cdf(runif(floor(2^(i/2)))) )
|
||||||
|
|
||||||
|
save(generated.logo.observations, file = "generated-logo-observations.Rdata")
|
||||||
|
# When i = 48, y will be length 57280991
|
||||||
|
|
||||||
|
print(paste(i, length(generated.logo.observations) )
|
||||||
|
}
|
||||||
|
|
||||||
|
|
139
Statistical-Monero-Logo/gif-construction.R
Normal file
139
Statistical-Monero-Logo/gif-construction.R
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
# MIT License
|
||||||
|
|
||||||
|
# Copyright (c) 2021 Rucknium
|
||||||
|
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
# install.packages("animation")
|
||||||
|
# install.packages("plotrix")
|
||||||
|
# install.packages("Cairo")
|
||||||
|
# NOTE: Cairo is a general software package that cannot be installed by R alone.
|
||||||
|
# Search for installation instructions according to your operating system.
|
||||||
|
|
||||||
|
library(animation)
|
||||||
|
library(plotrix)
|
||||||
|
library(Cairo)
|
||||||
|
|
||||||
|
load("logo-data.Rdata", verbose = TRUE)
|
||||||
|
# max(M.outline$y) == 1.58044863212111
|
||||||
|
# xmr.orange == "#FF6600FF"
|
||||||
|
# xmr.grey == "#4C4C4CFF"
|
||||||
|
|
||||||
|
load("generated-logo-observations.Rdata", verbose = TRUE)
|
||||||
|
# generated.logo.observations
|
||||||
|
|
||||||
|
# If Cairo in installed, use:
|
||||||
|
# ani.options(interval = 0.2, ani.dev = "CairoPNG")
|
||||||
|
# Otherwise, use:
|
||||||
|
ani.options(interval = 0.2)
|
||||||
|
|
||||||
|
saveGIF({
|
||||||
|
|
||||||
|
y <- generated.logo.observations[1:10]
|
||||||
|
|
||||||
|
for ( i in 3:73) {
|
||||||
|
|
||||||
|
y <- c(y, generated.logo.observations[length(y) + (1:floor(2^(i/3-1))) ] )
|
||||||
|
|
||||||
|
par(mar = c(5, 0, 0, 0))
|
||||||
|
|
||||||
|
plot(0, 0, xlim = c(0 - 0.1, 1 + 0.1), ylim = c(0 , max(M.outline$y) * 2 ),
|
||||||
|
axes = FALSE,
|
||||||
|
ylab = "", xlab = "", main = "", col = "transparent",
|
||||||
|
asp = (1.2)/(max(M.outline$y) * 2))
|
||||||
|
|
||||||
|
mtext("Secure. Private. Untraceable.", side = 1, line = 0.5, cex = 2)
|
||||||
|
mtext("Resistant to statistical attack.", side = 1, line = 2.5, cex = 2)
|
||||||
|
mtext(paste0("N = ", prettyNum(length(y), big.mark = ",")), side = 1, line = 3.9, cex = 1)
|
||||||
|
|
||||||
|
center_x = mean(c(0, 1))
|
||||||
|
center_y = max(M.outline$y)
|
||||||
|
|
||||||
|
plotrix::draw.ellipse(center_x, center_y,
|
||||||
|
0.6, max(M.outline$y),
|
||||||
|
col = xmr.orange, border = NA)
|
||||||
|
|
||||||
|
M.density <- density(y, bw = "SJ-dpi")
|
||||||
|
|
||||||
|
polygon((c(M.density$x, M.density$x) * 1.5 - .5/2),
|
||||||
|
c(M.density$y, M.density$y * 1.5), border = NA, col = "white")
|
||||||
|
|
||||||
|
hist(y, breaks = 50, col = xmr.grey,
|
||||||
|
axes = FALSE, border = NA,
|
||||||
|
xlim = c(0, 1), ylim = c(0, max(M.outline$y) * 2),
|
||||||
|
freq = FALSE,
|
||||||
|
ylab = "", xlab = "", main = "", add = TRUE)
|
||||||
|
|
||||||
|
|
||||||
|
# Pieced together from source of plotrix::draw.ellipse
|
||||||
|
draw1ellipse <- function(x, y, a = 1, b = 1, angle = 0, segment = NULL,
|
||||||
|
arc.only = TRUE, nv = 100, deg = TRUE, border = NULL,
|
||||||
|
col = NA, lty = 1, lwd = 1, ...) {
|
||||||
|
if (is.null(segment)) {
|
||||||
|
if (deg)
|
||||||
|
segment <- c(0, 360)
|
||||||
|
else segment <- c(0, 2 * pi)
|
||||||
|
}
|
||||||
|
if (deg) {
|
||||||
|
angle <- angle * pi/180
|
||||||
|
segment <- segment * pi/180
|
||||||
|
}
|
||||||
|
xyangle <- function(x, y, directed = FALSE, deg = TRUE) {
|
||||||
|
if (missing(y)) {
|
||||||
|
y <- x[, 2]
|
||||||
|
x <- x[, 1]
|
||||||
|
}
|
||||||
|
out <- atan2(y, x)
|
||||||
|
if (!directed)
|
||||||
|
out <- out%%pi
|
||||||
|
if (deg)
|
||||||
|
out <- out * 180/pi
|
||||||
|
out
|
||||||
|
}
|
||||||
|
z <- seq(segment[1], segment[2], length = nv + 1)
|
||||||
|
xx <- a * cos(z)
|
||||||
|
yy <- b * sin(z)
|
||||||
|
alpha <- xyangle(xx, yy, directed = TRUE, deg = FALSE)
|
||||||
|
rad <- sqrt(xx^2 + yy^2)
|
||||||
|
xp <- rad * cos(alpha + angle) + x
|
||||||
|
yp <- rad * sin(alpha + angle) + y
|
||||||
|
if (!arc.only) {
|
||||||
|
xp <- c(x, xp, x)
|
||||||
|
yp <- c(y, yp, y)
|
||||||
|
}
|
||||||
|
data.frame(x = xp, y = yp)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
eclipse <- draw1ellipse(center_x, center_y,
|
||||||
|
0.6, max(M.outline$y),
|
||||||
|
segment = c(0, 180), angle = 180)
|
||||||
|
|
||||||
|
eclipse <- rbind(data.frame(x = min(eclipse$x), y = -0.05),
|
||||||
|
eclipse,
|
||||||
|
data.frame(x = max(eclipse$x), y = 0))
|
||||||
|
|
||||||
|
polygon(eclipse, col = "white", border = NA)
|
||||||
|
|
||||||
|
print(paste(i, length(y)))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, movie.name = "Statistical-Monero-Logo.gif")
|
22
Statistical-Monero-Logo/monero file.svg
Normal file
22
Statistical-Monero-Logo/monero file.svg
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Creator: CorelDRAW -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="8.26772in" height="11.6929in" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" viewBox="0 0 8.26772 11.6929" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<defs>
|
||||||
|
<style type="text/css">
|
||||||
|
<![CDATA[
|
||||||
|
.fil1 {fill:#4C4C4C}
|
||||||
|
.fil0 {fill:#FF6600}
|
||||||
|
.fil2 {fill:#4C4C4C;fill-rule:nonzero}
|
||||||
|
]]>
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<g id="Layer_x0020_1">
|
||||||
|
<metadata id="CorelCorpID_0Corel-Layer"/>
|
||||||
|
<g id="_150062856">
|
||||||
|
<path id="_149931032" class="fil0" d="M2.70749 5.33391c-0.28302,0 -0.512535,0.229516 -0.512535,0.512535 0,0.0565709 0.00916929,0.111 0.0261024,0.161894l0.153283 0 0 -0.431232 0.333154 0.333157 0.33315 -0.333157 0 0.431232 0.153291 0c0.0169331,-0.0508937 0.0261024,-0.105323 0.0261024,-0.161894 0,-0.28302 -0.229516,-0.512535 -0.512547,-0.512535z"/>
|
||||||
|
<path id="_149931160" class="fil1" d="M2.63089 5.98686l-0.145398 -0.145398 0 0.271343 -0.0555787 0 -0.0555787 0 -0.104807 0c0.0899724,0.147614 0.252472,0.246193 0.437957,0.246193 0.185488,0 0.347996,-0.0985787 0.437969,-0.246193l-0.104815 0 -0.0994252 0 -0.0117323 0 0 -0.271343 -0.145398 0.145398 -0.0765945 0.0765945 -0.0765984 -0.0765945z"/>
|
||||||
|
<path id="_74749088" class="fil2" d="M3.43336 5.68653l0.083685 0 0.103799 0.31328 0.105366 -0.31328 0.0824331 0 0.0756654 0.449177 -0.082437 0 -0.048252 -0.283681 -0.0955669 0.283681 -0.0753504 0 -0.094315 -0.283681 -0.0491929 0.283681 -0.083374 0 0.0775394 -0.449177zm0.7315 -0.0112559c0.0635748,0 0.118181,0.0230354 0.163831,0.0689921 0.045752,0.0460669 0.0685748,0.102134 0.0685748,0.168209 0,0.0655512 -0.0225118,0.121098 -0.0676378,0.166433 -0.045126,0.0454409 -0.0998386,0.0680551 -0.164142,0.0680551 -0.0673228,0 -0.123287,-0.0232402 -0.167894,-0.0699291 -0.0446063,-0.0465866 -0.0669094,-0.101925 -0.0669094,-0.16602 0,-0.042937 0.0104252,-0.082437 0.0311614,-0.118496 0.0207402,-0.0360591 0.0492953,-0.0646142 0.0856693,-0.0856654 0.0362677,-0.0210512 0.0754528,-0.0315787 0.117346,-0.0315787zm-0.000834646 0.083689c-0.0415827,0 -0.0764921,0.0143819 -0.104736,0.0433543 -0.0283465,0.0288661 -0.0425197,0.0656575 -0.0425197,0.110157 0,0.0497126 0.0178189,0.089 0.0534606,0.11787 0.0277244,0.0226142 0.0594055,0.0338701 0.0952559,0.0338701 0.0405394,0 0.0750354,-0.0145906 0.103488,-0.043878 0.0285551,-0.0293858 0.0428307,-0.0654449 0.0428307,-0.108386 0,-0.0428307 -0.0143819,-0.0789961 -0.0431457,-0.108594 -0.0286575,-0.0295945 -0.0635709,-0.0443937 -0.104634,-0.0443937zm0.31411 -0.0724331l0.081811 0 0.192697 0.295559 0 -0.295559 0.0854606 0 0 0.449177 -0.082126 0 -0.192382 -0.294622 0 0.294622 -0.0854606 0 0 -0.449177zm0.462516 0l0.245224 0 0 0.083689 -0.160287 0 0 0.081185 0.160287 0 0 0.0822244 -0.160287 0 0 0.118079 0.160287 0 0 0.084 -0.245224 0 0 -0.449177zm0.330681 0l0.0906693 0c0.0497126,0 0.0850433,0.00448425 0.106094,0.0133425 0.0210512,0.00885827 0.0380394,0.0235512 0.0508583,0.0440827 0.0128189,0.0205315 0.0191732,0.0449173 0.0191732,0.0729528 0,0.0295984 -0.00698031,0.0541929 -0.0211535,0.0740984 -0.0141732,0.0197992 -0.0355394,0.0348071 -0.0639921,0.0450197l0.106303 0.199681 -0.0934843 0 -0.101091 -0.190197 -0.00791732 0 0 0.190197 -0.0854606 0 0 -0.449177zm0.0854606 0.175606l0.0268858 0c0.0273071,0 0.046063,-0.00354331 0.0563819,-0.0107323 0.0102126,-0.00708661 0.0153189,-0.0188661 0.0153189,-0.0353307 0,-0.00979528 -0.0025,-0.0183425 -0.0076063,-0.0255354 -0.0051063,-0.00718898 -0.0118819,-0.0124016 -0.0204252,-0.0155276 -0.00854724,-0.00322835 -0.0241811,-0.00479134 -0.0470039,-0.00479134l-0.0235512 0 0 0.0919173zm0.483567 -0.186862c0.0635748,0 0.118181,0.0230354 0.163831,0.0689921 0.045752,0.0460669 0.0685748,0.102134 0.0685748,0.168209 0,0.0655512 -0.0225118,0.121098 -0.0676378,0.166433 -0.045126,0.0454409 -0.0998386,0.0680551 -0.164142,0.0680551 -0.0673228,0 -0.123287,-0.0232402 -0.167894,-0.0699291 -0.0446063,-0.0465866 -0.0669094,-0.101925 -0.0669094,-0.16602 0,-0.042937 0.0104252,-0.082437 0.0311614,-0.118496 0.0207402,-0.0360591 0.0492953,-0.0646142 0.0856693,-0.0856654 0.0362677,-0.0210512 0.0754528,-0.0315787 0.117346,-0.0315787zm-0.000834646 0.083689c-0.0415827,0 -0.0764921,0.0143819 -0.104736,0.0433543 -0.0283465,0.0288661 -0.0425197,0.0656575 -0.0425197,0.110157 0,0.0497126 0.0178189,0.089 0.0534606,0.11787 0.0277244,0.0226142 0.0594055,0.0338701 0.0952559,0.0338701 0.0405394,0 0.0750354,-0.0145906 0.103488,-0.043878 0.0285551,-0.0293858 0.0428307,-0.0654449 0.0428307,-0.108386 0,-0.0428307 -0.0143819,-0.0789961 -0.0431457,-0.108594 -0.0286575,-0.0295945 -0.0635709,-0.0443937 -0.104634,-0.0443937z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.7 KiB |
Loading…
Reference in a new issue