JavaScript ❄️ Christmas Calendar 📅 Day 11 🎄

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น • 18

  • @___d3p1
    @___d3p1 หลายเดือนก่อน +5

    I love how you used the translation and rotation to replicate each snowflake branch!

    • @Radu
      @Radu  หลายเดือนก่อน

      :-)

  • @spacticals
    @spacticals หลายเดือนก่อน +2

    i thought that it would be the toughest but you break it very easily . awesome

    • @Radu
      @Radu  หลายเดือนก่อน

      It looks complex, but the symmetry makes it easier to generate :-)

  • @bennybrouwer
    @bennybrouwer หลายเดือนก่อน +3

    Before the branching loop: ctx.lineCap = "round"; gives it a bit more natural appearance. (I think).

    • @Radu
      @Radu  หลายเดือนก่อน +1

      Good idea! Stay tuned on the 17th :-) the 'round' snowflake might just make an appearance!

  • @egbertludema
    @egbertludema หลายเดือนก่อน +1

    Love these vids! I follow them almost daily!

    • @Radu
      @Radu  หลายเดือนก่อน

      Awesome! Thank you! :-)

  • @shaddow11ro
    @shaddow11ro หลายเดือนก่อน +1

    I was waiting to see 3 screens of code... but Radu did not want my wish come true! Soo instead he makes it a function! :) I did not expected that! Great work as usual Radu!

    • @Radu
      @Radu  หลายเดือนก่อน

      Yeah, ironically the item coming out today looks simpler, but the code is 3 times larger :-D

    • @shaddow11ro
      @shaddow11ro หลายเดือนก่อน +1

      @Radu 😄

  • @HansMilling
    @HansMilling 17 วันที่ผ่านมา +1

    What is the benefit of using rotation/translation of the canvas, compared to parading an angle to the function and use cos/sin? Less complex code? But what about the drawing speed in case you need to draw thousands?

    • @Radu
      @Radu  13 วันที่ผ่านมา +1

      :-) good question. I've done some experiments in the past, and yes, using trigonometric functions is faster than rotating the canvas for each item. But they are expensive operations as well, so they should be used sparingly. Maybe cache the values if they tend to repeat, or something like that.
      Anyway, yes, here I use rotation because the code is short and we don't need to worry about efficiency so much (not animating or drawing a very complex scene)
      But in this case, we do one rotation, and then draw one 'branch', consisting of 3 different lines... It could be that this is faster than using trigonometry to get the point coordinates for each of those lines... But I don't know... my intuition says it could be faster, or that at some point it will become faster, when increasing the complexity of a single branch (adding more lines)
      But I don't know internally how all the canvas things work... and I don't really want to know :-D I have seen there is variation on different browsers (some things take longer than others on one browser and it's vice-versa on another).
      My approach with these things is to try several approaches and test. But I usually only do that when the application really needs it (complex scenes with animation that shouldn't lag).

  • @69zwaan
    @69zwaan หลายเดือนก่อน +1

    really nice! nice idea to play some kind of memory game. If you take 2 of the same cards, you win. is really nice as a Christmas memory :-)

    • @Radu
      @Radu  หลายเดือนก่อน +1

      Hey, that's a great idea :-)
      Maybe I'll code the memory game next Christmas... using these images or those submitted by other people!

    • @69zwaan
      @69zwaan หลายเดือนก่อน +1

      @@Radu success

  • @danysinchro
    @danysinchro หลายเดือนก่อน +1

    I didn't get how you rotate the branches inside the loop. It is always rotate for the same value, isn't?

    • @Radu
      @Radu  หลายเดือนก่อน

      The rotate method is cumulative ;-)