Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Trigonometría Bella
Search
Lupo Montero
September 25, 2020
Programming
48
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
350
WebThing: construyamos una lámpara 💡
lupomontero
1
100
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
40
Reduzco, reuso y reciclo
lupomontero
0
46
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
66
Primeros pasos con Rust y WebAssembly
lupomontero
0
560
Paralelizando promesas
lupomontero
0
370
Other Decks in Programming
See All in Programming
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
180
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
100
AIと壁打ちしながら進めるコスト管理
fufuhu
2
2k
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
760
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
130
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
2
220
高専キャリア LT 発表内容
crysta1221
6
5.6k
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
190
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
200
不幸な GC
chencmd
0
890
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
510
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
220
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
520
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Amusing Abliteration
ianozsvald
1
290
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
The SEO identity crisis: Don't let AI make you average
varn
0
550
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
210
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
260
Prompt Engineering for Job Search
mfonobong
0
450
Color Theory Basics | Prateek | Gurzu
gurzu
0
460
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
680
Design in an AI World
tapps
1
310
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