Skip to content

Instantly share code, notes, and snippets.

@allatambov
Last active May 29, 2020 00:24
Show Gist options
  • Save allatambov/0ca763a60a77e99e4a1a416dfc7f0ab4 to your computer and use it in GitHub Desktop.
Save allatambov/0ca763a60a77e99e4a1a416dfc7f0ab4 to your computer and use it in GitHub Desktop.
revelio <- function(object){NA}
setGeneric("revelio")
setMethod("revelio", signature(object = "Cauldron"),
function(object) {
y <- -10:10
x <- y ** 2
z <- seq(20, 80, length.out = 100)
plot(x, y, type = 'l', ylim=c(-4, 4),
xlab = "", ylab = "", axes=FALSE)
lines(-x + 100, y)
lines(z, rep(-4.2, 100))
lines(z, rep(4.2, 100))
lines(z, 0.0012*(z - 50)**2 + 3)
lines(z, 0.0012*(z - 50)**2 + 2.5)
text(x = 50, y = 0,
labels = "I am a cauldron.")
})
revelio(caul)
setMethod("revelio", signature(object = "Cabbage"),
function(object) {
x <- seq(-2, 2, length.out = 1000)
y <- sqrt(4 - x**2)
plot(x, y, type = 'l',
xlim = c(-5, 5), ylim = c(-2,2),
xlab = "", ylab = "", axes=FALSE)
lines(x, -y)
text(x = 0, y = 0,
labels = "I am a cabbage.")
})
revelio(cabb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment