Introducing SVG
SVG is an XML-based language. With SVG you can add to graphics onto the stage. We are not going to dive deep into the depths of SVG, but we will get familiar with it for the sake of our slideshow. By the end of this lesson, we will swap our buttons with SVG based buttons.
Video Transcript
00:00Who would have thought that this is chapter four? So I am excited. I am really excited
00:07Yeah, I'm not that excited, but I'm kind of excited because we're gonna be talking in this lesson about
00:12CS VG SVG SVG. I remember the acronym. I should get a star
00:20Graph effects imagine that there was a starter. We're not that big of a budget to do that. All right, so
00:27SVG we're not gonna dig too deep into it
00:29But SVG is that XML based language that enables us to create graphics?
00:33There's a lot of things you could learn about SVG
00:35We're just gonna see a sampling of it because that's not our core topic and we're prepping ourselves to the main topic
00:42You sure of this chapter, which is gonna be a few of the plugins of the animation plugins and see when are they useful and
00:49When do we want to turn them on and use them? So let's just jump right into it and let's SVG it
00:55Well, actually chapter four. Wow, we're doing a lot of stuff
01:00All right
01:00So chapter four it is and our project right now what I want to work on is right now
01:04You see these buttons that we have here. I don't really like them for a few reasons
01:09One is that we're using a graphic and we're in the days of HTML 5. There's no reason for us not to use
01:16CSS or to use basically
01:19What we're gonna be doing which is gonna be SVG because I wanted to show you how SVG works and in the process
01:25Get us ready to work with another tween
01:28Plugin. Alright, so let's get started
01:31What I'm gonna do first of all is I'm gonna get rid of these buttons and I'm gonna substitute them with actually a drawing that
01:36We draw ourselves using SVG
01:39Now obviously this course is not about SVG in general, but we're gonna see the basics of how SVG works
01:44So let's get to it. So the first step that I want to do is I want to
01:49So the first step that I want to do, excuse me
01:56So the first step that I want to do is I want to find those buttons and by the way
02:00I'm starting off chapter 4 with basically the exact same
02:05Configuration that we had in chapter 3. I just moved on and copied my JS files to chapter 4 do the same
02:12All right
02:13So now that we're we got that intro out of the way
02:15what I want to do is I want to delete all those a buttons get rid of them completely and
02:19Instead of that what I want to do is I want to define a space for our SVG
02:24Now to do that. All I need to do is just define an SVG element
02:27And again, this is very dependent on if your browser supports it
02:31But most modern browsers will all modern browsers support the basics of operations of SVG already
02:38Now SVG needs to have a height and a width so I'm going to define it right away
02:44I'm gonna set my height to 20 pixels and for my width. I'm going to set a width of a hundred pixels
02:51Perfect next step what I'm going to do is I want to go ahead and close that SVG and
02:58Last but not least is actually start drawing out our element and I want to draw out a circle
03:04so I'm going to go ahead there and just type the word circle and
03:08I'm going to set my values of a center point of that X so center point of our X and notice this
03:1320 and 100 is basically our
03:16Drawing area. So I want to put it in the center of our height. So that would be 10 pixels and
03:23I also want to sorry
03:25No, not comma and I also want to set our y position and I'm gonna set that y position to be 10 pixels as well
03:31so like that it's right smack in the middle of our
03:34Square if we had your square of 10 20 pixels. Well, we have your five squares of 20 pixels really
03:40So I'm putting it slap in the middle 10 10
03:43Next is I needed to find also a radius and I'm gonna pick a radius of six
03:48Pixels, so that means our circle should be in total
03:52From side to side its length would be 12 pixels
03:55Which is a lot it gives us a lot of space here a lot of room to finagle
04:00Now the reason why I'm doing that is because I also want to set a stroke width and I'm gonna set a stroke
04:06Not
04:08Stoke and I'm gonna set that stroke with to be 3 pixels as well
04:14So all in all our element is gonna be 9 pixels
04:17I could have made it all the way to 10 pixels because then it would be actually
04:21The total width would be 20 pixels
04:24But we were happy with this because that would mean that we have your 9 times 2 which would put us at 18
04:30Giving us a little bit of margin in case we want to add another effect at any point
04:34Alright, so next step now that we said that we also want to set our color
04:37So I'm gonna go ahead and set my color by defining my fill and I'm gonna set my fill color to be white
04:43So I'm gonna go ahead there and send the white value
04:46So I'm gonna send their ampersand and 1 2 3 4 5 6 and by the way
04:51I could have if I wanted to also set there a value that would have been just just write the word white
04:56But I actually want to animate this later on so I'm gonna leave it the way with a direct color
05:02and the next thing I also want to define my stroke color and
05:06For my stroke color, I'm gonna set the define as a light shade of gray
05:10So I'm gonna go for C C C C C C which basically would give me a nice light shade of gray
05:16So it's really just creating a almost a halo around the circle that I'm creating
05:21If I save this and go back into my application and click on refresh. We're gonna see that my button disappeared
05:26We're gonna have your a much larger button and it's gonna have a halo effect on it
05:31All that's left for me to do is to create four buttons because we need four buttons for what we created, right?
05:37so let's go ahead and create those four buttons because we have four panels and I'm gonna go ahead and just copy this and
05:44all I really need to do is change my X position because I want to move in my X my I want to move from
05:51Right to left note from left to right right. I'm gonna move from left to right
05:54So I'm gonna give a spacing here with it. So like we'll have a two or four pixel space in between each item
06:00So I'm just gonna jump
06:02I'm gonna jump 20 pixels each round making sure that there's not gonna be an overlap and
06:09Let me go ahead and do that
06:10Oh, it's in the last item and if I save that just by creating all these items go back to my application and click on refresh
06:16Now we're gonna have four SVG circles in our application. Now, that's all we're gonna talk about SVG in general
06:24The next step is we want to make sure that our buttons now work again. So to make them work again
06:28I'm gonna go back into my code and find where I'm actually sending my slideshow my buttons
06:33You'll see that that's actually the first thing we send the slideshow is our button
06:37So I'm gonna go ahead and change my button to be our
06:41Let's see. What was it called? It was our circle. So I'm just gonna send here circle instead
06:46Instead of our a parameter and if I save this go back into my application click on refresh
06:52Our application will will work now now
06:55Obviously a lot of the configurations that actually put us our CSS and our element
06:59Are not working anymore and we're gonna go ahead and animate them in the next lecture
07:04So that's it. So we configure it and set our SVG
07:07This is our intro to SVG and all we're really going to talk about SVG in this lesson
07:12We could always find more SVG sample codes online just by searching them up online
07:17So that's it for this lesson in the next lesson. We're going to continue where we left off and start configuring and animating our
07:24SVG element, so we'll see you in the next lesson
