Public
Edited
Dec 30, 2024
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hello_md = function () {
let texto = "**Hello World**";
return texto;
}
Insert cell
hello_html = function () {
let texto = "<b>Hello World</b>";
return texto;
}
Insert cell
dobra = function (valor) {
let calculo = valor * 2;
let sointeiro = parseInt(calculo);
return sointeiro;
}
Insert cell
apresenta = function (total) {
let texto = `O valor da variável resultados é igual a: <b>${total}</b>.`;
return html`${texto}`;
}
Insert cell
viewof numero = Inputs.range([0, 100], { label: "numero", step: 0.25 })
Insert cell
resultados = dobra(numero)
Insert cell
fComplexa = function (arr, bin) {
let valorA = arr[2];
let valorB = bin;
let texto = `O terceiro valor da Array é ${valorA}, e o valor de bin é ${valorB}`;

return md`${texto}`;
}
Insert cell
fSuperComplexa = function (arr, bin, f) {
let valorA = f(arr[2]);
let valorB = bin;
let texto = `O terceiro valor da Array, após processado por o que for definido como "f", é ${valorA}, e o valor de bin é ${valorB}`;

return md`${texto}`;
}
Insert cell
verifica = function (x) {
let resultado = "o valor é menor";

if (x > 5) {
resultado = "o valor é maior que 5";
}

return resultado;
}
Insert cell
criamatriz = function (limite, fator) {
let array = [];
for (let a = 0; a < limite; a = a + 1) {
array[a] = a * fator;
}

return array;
}
Insert cell
criaquadmatriz = function (w, h) {
let meusvg = `
<svg
width="100%"
height="300"
viewBox="0 0 ${w} ${h}"
xmlns="http://www.w3.org/2000/svg"
>`;

// Cria quadrados através de loops em x e y
for (let ix = 0; ix < w; ix = ix + 20) {
for (let iy = 0; iy < h; iy = iy + 20) {
meusvg =
meusvg +
`
<rect x="${ix}" y="${iy}" width="10" height="10" fill="#888888"></rect>
`;
}
}

meusvg = meusvg + `</svg>`;

return html`${meusvg}`;
}
Insert cell
criaquadrado = function () {
let meusvg = `
<svg
width="100%"
height="300"
viewBox="0 0 500 300"
xmlns="http://www.w3.org/2000/svg"
style="border: 1px solid #cccccc"
>

<rect id='meuquad' x='0' y='100' width='50' height='100' />

</svg>
`;

return html`${meusvg}`;
}
Insert cell
setaquadrado = function (val) {
if (
typeof document.getElementById("meuquad") != "undefined" &&
document.getElementById("meuquad") != null
) {
document.getElementById("meuquad").setAttribute("x", val);
}

return md`<pre>setaquadrado(posicao)</pre>`;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more