Canvas Renderer

Written by

in

My weird first renderer using a 2D canvas element to draw primitives.

https://garstka.dev/static/canvas_renderer/index.html

So first of all, this is really not the right way to draw things, webgl exists, and I actually have another project here. But this is dear to my heart because it was an old project I attempted back in high school and it really almost worked in so many ways. It was at the time the closest I could get to truly coding something from scratch, even if I didn’t realize at the time that canvas was anywhere near low level graphics. But nevertheless I learned a LOT about graphics programming on my hunt for visualizing 3D cubes (I should eventually link even older prototypes I have which are even jankier).

This is an updated version of that initial project, with the same… mechanics for 3d rendering but everything surrounding it cleaned up much nicer. The webgl has even more modern patterns but this already is way cleaner in my opinion.

So for how it works, essentially this is rendering isometric and drawing full triangles ordered by the centroid… there is no depth buffer or anything, two triangles cannot intersect. This surprisingly works pretty well given that massive limitation, concave low poly shapes struggle the most from this, but with small enough polys the centroid is a pretty good estimate for depth and you just get some visual artifacting around the edges while rotating.

Because this is isometric, we can skip most of the projection and matrix math that would normally be done for 3D affairs and just use the x and y values:

JavaScript
const x1 = (v1.x * S) + transform.x; 
const y1 = (v1.y * S) + transform.y; 
const x2 = (v2.x * S) + transform.x; 
const y2 = (v2.y * S) + transform.y; 
const x3 = (v3.x * S) + transform.x; 
const y3 = (v3.y * S) + transform.y; 
drawTriangle(x1, y1, x2, y2, x3, y3, shaded_color);


Here I was applying some scaling and translation, although I would write this differently even now looking back at it.

Maybe I’ll write more details some other time but that’s all I got on my mind for now.

Comments

30 responses to “Canvas Renderer”

  1. hohuxqtqoo Avatar

    kmkflrxqrdxrefrsfufshuztkqipst

  2. kfkhekyukm Avatar

    gpngirigwwioeuvrspkdiyxtrgrsge

  3. qcman88 Avatar

    QCman88… hmm, I think I saw this recommended in a forum. Is it worth it? Give it a quick look: qcman88

  4. 922betcassino Avatar

    Gave 922betcassino a whirl. The casino vibe is definitely there. Live dealer games seemed pretty smooth. Could be worth a look if you’re into that: 922betcassino

  5. betviplogin Avatar

    Alright, betviplogin, you’re up! Smooth login process, got in without a hassle. That’s what I like to see. One less headache! Get logged in here: betviplogin

  6. 6677betlogin Avatar

    6677betlogin, huh? That’s a mouthful! Hope the login process is easier than saying the name. Looking for a reliable spot to gamble. 6677betlogin

  7. 11cc Avatar

    Alright folks, let’s talk 11cc. Simple, straightforward, and gets the job done. No fancy bells and whistles, just good ol’ fun. Give it a whirl 11cc.

  8. 77ssbet Avatar

    Crikey! Just stumbled across 77ssbet. Looks promising. Got some interesting games if you want to try your luck. See for yourself at 77ssbet.

  9. ecbetcris Avatar

    This site has become my regular stop for both sports and casino action. The odds are competitive and the payment options fit my needs perfectly. I really appreciate how straightforward everything is from sign up to cash out. ecbetcris

  10. mmk888login Avatar

    I have been hunting for a spot that balances luck and skill and this one hits the mark every session. The interface is clean the payments are smooth and I always get that little rush when I log in. It is like the site genuinely wants me to keep coming back for more. mmk888login

  11. paryajpammexico Avatar

    Wow, this platform really changed how I play online. Everything feels transparent and the bonuses actually make sense instead of being tricky. I play after work and the interface is super easy to navigate. Definitely recommend checking it out if you want a chill gaming session. paryajpammexico

  12. fancybetinfo Avatar

    Found this place by accident and it quickly became my daily stop. The layout is clean and the betting markets cover everything I follow. Support staff are polite and always ready to guide new members through the process. fancybetinfo

  13. juegoscasinoonline Avatar

    I have been searching for a reliable spot to try my luck and this place truly delivers. The slot collection is massive and the welcome bonus gave me a fantastic head start. Customer support replied instantly when I had a quick question about the wagering requirements. Definitely my new go to for late night gaming sessions. juegoscasinoonline

  14. winnerspinvip Avatar

    VIP status here really changes the game. I love how they track my play style and offer personalized bonuses that actually make sense. The interface is clean and loading times are super quick. Definitely my new favorite spot. winnerspinvip

  15. ph123login Avatar

    Alright, I finally figured out the correct ph123login address. So many fake ones out there! Just in case, here’s the real deal ph123login.

  16. 8jililoginapp Avatar

    Alright, so I downloaded the 8jililoginapp app. It’s not bad! Makes it super convenient to play on my phone. Could be a little smoother, but overall a solid experience. Here’s the link: 8jililoginapp

  17. 79ok Avatar

    79ok, yeah, it’s alright. Functional site, easy to get started and place a bet. Nothing super fancy, but gets the job done! Give it a try: 79ok

  18. jljl72login Avatar

    Quick and easy login process. I appreciate how they keep the site secure and easy to access from my mobile phone. Glad I found jljl72login.

  19. bd3kkk Avatar

    Playing on here has become my favorite way to unwind after work. The graphics are crisp and the sound effects make every win feel completely rewarding. I also love that they update their promotions regularly so there is always something new to chase. bd3kkk

  20. gamdomnaslgirilir Avatar

    Finally found a spot that runs perfectly on my mobile without draining my data. The interface is clean and the game selection feels curated with real attention to detail. I really like how responsive the team is and how they handle promotions with such transparency. It makes every session feel refreshing and trustworthy. gamdomnaslgirilir

  21. auluckydreams Avatar

    I have been searching for a spot that actually delivers on its promises and this place checks every box. The graphics are gorgeous and the gameplay feels completely balanced. It is rare to find a site this trustworthy in the online space. auluckydreams

  22. idstudiobet78 Avatar

    Finally found a site that actually pays out consistently. The customer support team is also very helpful when I had issues with my account. Highly recommend idstudiobet78.

  23. 98pakgame Avatar

    Really impressed with the game selection here. Everything loads quickly and the graphics are crisp. 98pakgame is definitely a hidden gem.

  24. c333plataforma Avatar

    Super easy registration process. I was able to start playing in under two minutes. Great job by the c333plataforma team.

  25. jilibet178casinologin Avatar

    Everything about this site is professional and user friendly. The games are fair and the rewards are real. Check out jilibet178casinologin

  26. phjljl72 Avatar

    The local support is top notch and they actually answer your questions quickly. It makes the whole experience much better. Give phjljl72 a try.

  27. idsuper89 Avatar

    Top notch gaming experience! The server is stable and there is zero lag during my sessions. Big thanks to idsuper89 for the quality service.

  28. phjilimk Avatar

    Very reliable and transparent with their rules. It is refreshing to find a site that treats players fairly. My choice is phjilimk.

  29. pebizzocasino Avatar

    I have been exploring different online platforms and I must say the experience here is truly refreshing. The game selection keeps me entertained for hours and the support team actually listens to what we need. Everything runs smoothly on my phone too. Highly recommend giving it a try if you want a trustworthy spot to play. pebizzocasino

  30. 1xbetphilippineslogin Avatar

    The most reliable way to access my account in the Philippines. The login is secure and the sports betting options are endless. Love it. Use 1xbetphilippineslogin

Leave a Reply

Your email address will not be published. Required fields are marked *