Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Trigonometría Bella
Search
Lupo Montero
September 25, 2020
Programming
47
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Trigonometría Bella
LimaJS 25 Sep 2020
Lupo Montero
September 25, 2020
More Decks by Lupo Montero
See All by Lupo Montero
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
110
Manejo de memoria en Rust: Ownership
lupomontero
0
49
Hola Rust! Aprendiendo con rustlings
lupomontero
1
340
WebThing: construyamos una lámpara 💡
lupomontero
1
99
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
40
Reduzco, reuso y reciclo
lupomontero
0
45
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
64
Primeros pasos con Rust y WebAssembly
lupomontero
0
560
Paralelizando promesas
lupomontero
0
370
Other Decks in Programming
See All in Programming
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
220
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
170
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
250
リアルな遅延を測る仕様
kota_yata
1
120
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
360
ソフトウェアラスタライザ
fadis
1
210
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
180
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
170
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
340
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Mobile First: as difficult as doing things right
swwweet
225
10k
Side Projects
sachag
455
43k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
240
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
It's Worth the Effort
3n
188
29k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
260
Writing Fast Ruby
sferik
630
63k
Transcript
Trigonometría Bella @lupomontero - LimaJS 25 Sep 2020 😷
@Laboratoriala @LimaJSorg @node_lima @lupomontero @mozillaperu
None
Comencemos por la demo...
Ahora sí, veamos un poco de JavaScript
Preparando el escenario
const createCanvas = (width = 500) => { const canvas
= Object.assign( document.createElement('canvas'), { width, height: width }, ); // ... return canvas; };
const createCanvas = (width = 500) => { const canvas
= document.createElement('canvas'); canvas.width = width; canvas.height = width; // ... return canvas; };
El motor de la animación
const createCanvas = (width = 500) => { const canvas
= Object.assign( document.createElement('canvas'), { width, height: width }, ); const update = (angle = 0) => { // Dibujar frame!! window.requestAnimationFrame(() => update(angle < 359 ? angle + 1 : 0)); }; update(); return canvas; };
Definamos el origen
const createCanvas = (width = 500) => { const canvas
= Object.assign( document.createElement('canvas'), { width, height: width }, ); const radius = width / 2; const center = { x: radius, y: radius }; const update = (angle = 0) => { // Dibujar frame!! window.requestAnimationFrame(() => update(angle < 359 ? angle + 1 : 0)); }; update(); return canvas; };
Calculamos la posición del punto en la circunferencia para un
ángulo dado
const update = (angle = 0) => { const radians
= angle * Math.PI / 180; const pointOnCircle = { x: center.x + Math.cos(radians) * radius, y: center.y + Math.sin(radians) * radius, }; // Dibujar frame!! window.requestAnimationFrame(() => update(angle < 359 ? angle + 1 : 0)); };
Dibujando líneas
const drawLine = (ctx, fromX, fromY, toX, toY) => {
ctx.beginPath(); ctx.moveTo(fromX, fromY); ctx.lineTo(toX, toY); ctx.stroke(); };
Dibujando círculos
const drawCircle = (ctx, x, y, radius, color, stroke =
true) => { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); if (stroke) { ctx.stroke(); } if (color) { ctx.fillStyle = color; ctx.fill(); } };
Conclusiones
Conclusiones • Explorar • Jugar • Aprender • Búsqueda de
belleza y simplicidad
Links / Bibliografía • Demo • Código fuente • Beautiful
Trigonometry - Numberphile • https://www.geogebra.org/m/S2W46Thv • https://en.wikipedia.org/wiki/Trammel_of_Archimedes • https://ee.stanford.edu/~hellman/playground/hyperspheres/radians.html • https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API
Fin