News for hackers. Stuff that matters.

HunorBorbely

Re: on Monday December 02, 2024 @10:39AM (#42297213)
In this advent calendar-themed tutorial, you will learn the fundamentals of Scalable Vector Graphics (SVG), from the basics to advanced concepts like animation and interactivity.
Re:JavaScript Game Tutorial with HTML Canvas: Gorillas on Monday February 05, 2024 @11:03AM (#39262606)
In this JavaScript Game Tutorial, we code a modern version of the 1991 classic game, Gorillas!

This tutorial is both a JavaScript Game Tutorial and an introduction to the HTML Canvas elements. First, we learn how to draw on a Canvas element with JavaScript. How to draw the background, the buildings, the gorillas, and the bomb.

Then we add interaction. We add event handlers, we cover how to aim, how to animate the bomb across the sky, and how to detect if the bomb hit the enemy or a building.

In the end, we also add AI logic for the enemy gorilla, so you can play against the computer.

Re:Learn SVG with 25 examples – How to code images in HTML on Friday December 08, 2023 @04:33AM (#38567039)
Day 24 is a basic example of React + SVG. Once you get the basics of React you can just start coding images based on this tutorial.
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @06:30PM (#38563248)
Thank you. The whole project actually started as an advent calendar. Then I started thinking okay, what should be the content of it :)
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @04:24PM (#38562013)
True. When you make art with CSS then you don't start with Illustrator either
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @03:01PM (#38561094)
Yes, I was thinking of fixing the second point, but then I was annoyed with it and left it like that. If I knew that it blows up here on Hacker News I would have fixed it.

I'm not sure where you see horizontal scrollbars though. Are you on Windows?

Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @02:56PM (#38561030)
It's an interesting point. Writing tutorials like this also made me realize what's the difference between a function property and a function argument. I just used them completely interchangeably before. So element is more accurate here?
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @02:51PM (#38560969)
Added a Table of Contents below. Probably it helps SEO as well :)
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @01:55PM (#38560231)
Lol :) Maybe I should just put this below the calendar. What do you think?
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @01:54PM (#38560219)
Ouch. Some browsers might not support every feature. Gradients also have some issues. Luckily it seems to be all right so far in desktop browsers.
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @01:48PM (#38560141)
The funny thing about writing tutorials like this as a non-native speaker myself is also googling how to call things like the "clapper". I also didn't know what it was called before writing this article.
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @01:45PM (#38560097)
Super cool effect. Yes, SVGs can be a rabbit hole. This is just scratching the surface of it
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @01:43PM (#38560084)
Thank you for the great feedback, I really appreciate it. I fixed some errors you found. Let me know if something still doesn't work. It's still a bit in the process of fine-tuning.

For instance, does anyone know why the thumbnail preview does not work on Twitter? It works with the sub-pages.

Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @01:41PM (#38560052)
Totally. There are many cases when HTML Canvas is way more performant, but if you don't build the next Figma, then working with SVG is way more convenient
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @12:07PM (#38558886)
Thank you, I'm glad it helped. Cool comics!
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @12:04PM (#38558841)
Yes, and imagine if I would have figured out how to do the view transitions properly :)
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @11:25AM (#38558269)
Okay, I fixed the links to the interactive demos (somehow deep links do not always work on that site, probably because it's made with Vue). I don't see the problem with bio.link. What issue do you see?
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @11:23AM (#38558229)
Yes, there's some bug with using gradients that I couldn't figure out yet. Are you looking at it on mobile? On desktop it works for me
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @11:22AM (#38558202)
Good catch. Yes, I rearranged some chapters and I missed this link. Thank you, fixed
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @11:06AM (#38557951)
With text I wasn't experimenting too much, apart from the example where it follows a line.

I know there is text anchor: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/t...

And someone suggested the foreignObject tag that might be useful here: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/for...

Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @11:04AM (#38557907)
That is true, good idea. I might update it with a note on this
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @10:57AM (#38557793)
Damn, something is always broken. Let me look into it.

As for foreignObject, I also didn't knew about it. That's awesome

Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @10:54AM (#38557763)
Yes, since HTML5 you can inline an SVG. You don't need Webpack or anything like that, it just works.

One of the examples in this tutorial is also a data-driven diagram generated from React. You can do pretty cool things by combining the two.

Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @10:53AM (#38557735)
Thank you. Let me know if you have any feedback. It's still under fine-tuning. And of course if you share it, that helps a lot :)
Re:Learn SVG with 25 examples – How to code images in HTML on Thursday December 07, 2023 @10:48AM (#38557669)
For more complex graphics you would probably still use a designer tool. But for some simple ones, you can probably code them yourself. Like if you need an arrow or a hamburger menu icon, you can just jump straight into code. Sometimes I also just start with pen and paper and then figure out the coordinates from there, and adjust till it looks good enough.

Older »