Java Graphics Programming Tutorial - How To Draw Shapes, Paths, Curves, and Apply Transformations

  Рет қаралды 90,132

choobtorials

choobtorials

Күн бұрын

Пікірлер: 88
@tambuko8075
@tambuko8075 Жыл бұрын
He has no business exerting this much effort into his videos and yet time and time again has proven to be a great teacher. You sir are a blessing to not only this community but the world as a whole. More educators should be like you. Keep up God's work Choobtorials.
@choobtorials
@choobtorials Жыл бұрын
Thank you so much!!!
@CrasyWolfang
@CrasyWolfang 2 жыл бұрын
This is the best coding tutorial I've ever seen. Next to zero clutter, very clear demos, and very relevant info. I don't even mind the slow pace. I'll definitely revisit this channel for more tutorials.
@osternosousa
@osternosousa Ай бұрын
Very good indeed. I love it.
@michaellarkins6140
@michaellarkins6140 3 жыл бұрын
Wish I had a teacher like you. Your students are so lucky. Thanks for sharing ur java lessons. Your teaching style and coding style is need and easy to understand. Love ur visuals. I would pay for more java courses.
@choobtorials
@choobtorials 3 жыл бұрын
Thank you for the kind words! We've been fully online at our university for the last year and it has been really exhausting. So hearing someone say this helps remind me that the effort is all worth it.
@osternosousa
@osternosousa Ай бұрын
Wish this class had 12 hours.
@OldSchoolBoBo
@OldSchoolBoBo 3 жыл бұрын
duuude, 6 mins in and you already clarified several questions which went through my head. Thats some quality teaching here.
@choobtorials
@choobtorials 3 жыл бұрын
Hey, thanks for the comment! Glad I could help!
@choobtorials
@choobtorials 3 жыл бұрын
JAVA GRAPHICS PROGRAMMING Timestamps: 00:00​ Introduction 00:42​ Creating a class that extends JComponent 02:11​ Overriding the paintComponent method 02:28​ What is the Graphics object for? 03:21​ How to convert / cast the Graphics object into a Graphics2D object 04:23​ The java.awt.geom package 04:58​ How to create a rectangle using the Rectangle2D.Double class 05:26​ How does the JComponent coordinate space work? Where is x=0 and y=0? 06:33​ How to choose a color for drawing or filling shapes in Java 06:47​ The RGB Channels 07:06​ Java Color Constants 07:19​ How to fill the shape with the chosen color 07:32​ How to view the drawing / graphics 08:10​ How to add a solid-colored background to a JFrame 09:41​ How to create a circle using the Ellipse2D.Double class 10:04​ How to set a new color 10:21​ How to create a line using the Line2D.Double class 10:46​ How to draw the line using the draw method 10:59​ The graphics stacking order 11:39​ Antialiasing 12:04​ How to create a RenderingHints object to apply antialiasing 12:42​ The setRenderingHints method 13:05​ Decluttering the paintComponent method 13:33​ How to draw a cloud using ellipses 14:35​ Creating the Cloud class 15:12​ Using the Cloud class to create and draw a cloud 16:30​ Visualizing the connection between the DrawingCanvas class and the Cloud class 17:19​ Making the clouds customizable 21:36​ A note on the Override annotation 21:56​ Next Topics: Paths, Curves, and Transformations 22:43​ How to create a path using the Path2D.Double class 23:24​ What is the difference between the moveTo and lineTo methods? 24:37​ How to close a path using the closePath method 25:07​ How to create curved segments using the curveTo method 25:40​ What are Bézier handles? 27:35​ Heart-shaped path 28:02​ What is graphics translation? 28:35​ How to apply graphics translation in Java 29:29​ Visualizing how graphics translation works 30:43​ Applying additional translations 31:44​ How to reset the translation (Method 1 - Hardcoding reset values) 33:29​ How to reset the translation (Method 1 - Using an AffineTransform object) 33:36​ What is an AffineTransform object? 37:04​ Why use translate? 37:33​ How to rotate shapes using the rotate method 38:08​ How to use the Math.toRadians method to convert degrees to radians 38:45​ Rotation pivot points explained 39:42​ How to change the pivot point when rotating shapes in Java 40:28​ The effect of calling the rotate method multiple times 41:52​ How to reset the rotation using an AffineTransform object 42:46​ Thanks for watching!
@ArKa_47
@ArKa_47 3 жыл бұрын
I want to call this a high quality tutorial :) The overlayed graphics which show quiete instantly what would happens are great. kind regards
@rorymax
@rorymax 2 жыл бұрын
15:00 I’m pretty sure you can combine Shapes into an Area object and render that. You then also have the ability to check if a point lies within your hybrid shape, etc
@perelium-x
@perelium-x Жыл бұрын
Your channel is so so underrated, keep up the good work man! You've been a great help
@DiegoIbarra-d3h
@DiegoIbarra-d3h 2 ай бұрын
Thank you so much for this video, it helped out a lot! I hope you consider uploading more java graphics tutorials in the near future.
@JuliaNeubauer
@JuliaNeubauer 3 жыл бұрын
Super difficult material that you’ve made graphically understandable. Thank you for your excellent presentation.
@rede_neural
@rede_neural 2 жыл бұрын
Such an underrated channel
@GODWYNIDRISLOZADA-o1w
@GODWYNIDRISLOZADA-o1w 2 ай бұрын
Good morning po, Sir Choob, Godwyn here. For radians, I find it helpful na if one expresses the radian value as "double /MATH.PI". That way, it saves us from having to compute in our heads and focus on the code structure.
@gracekaranja3910
@gracekaranja3910 2 жыл бұрын
Finally got to understand graphics, best tutorial ever!
@TuanNguyen-ie2zm
@TuanNguyen-ie2zm 2 жыл бұрын
20:02 your pronunciation & accent is so professional, glad to see this video, thank you very much!
@choobtorials
@choobtorials 2 жыл бұрын
Thank you! Glad you enjoyed the video!
@kasper3246
@kasper3246 3 ай бұрын
Extremely high quality video. Thank you so much :)
@aksHandler
@aksHandler Жыл бұрын
Very smoothly explained. Wonderful.
@codehorror8076
@codehorror8076 2 жыл бұрын
Wow, subbed! This was one of the best videos I've seen this year.
@choobtorials
@choobtorials 2 жыл бұрын
Thank you!!!
@lingyuanyan1722
@lingyuanyan1722 Жыл бұрын
Thank you for this awesome video. Drawing in Java is something that is very confusing for me and particularly other noobs, as it is a large leap in skill gap, but this tutorial was a great help to me and the best tutorial yet addressing this topic. thank you sincerely, I will definitely revisit this video and other of your tutorials in the future.
@MrSemIsAwesome
@MrSemIsAwesome 2 жыл бұрын
Seriously: Thank you so much for this awesome tutorial. This is excellent and you should be proud of yourself.
@choobtorials
@choobtorials 2 жыл бұрын
Thanks for the kind words! Appreciate it!
@thecodingcanuck8185
@thecodingcanuck8185 3 жыл бұрын
Fantastic video! Great dynamic visuals and your explanations were extremely comprehensive and easy to understand.
@Ragnak_
@Ragnak_ 3 жыл бұрын
The fact I could understand everything you said impresses me. This was such a nice and well explained video on Graphics for java and I have more confidence now to dabble in it.
@AAsad-3786
@AAsad-3786 Жыл бұрын
This was the best video tutorial I have come across, straightforward and to the point. I was hoping you would show how to rotate the composite shape of heart in your tutorial or another video. It will be greatly appreciated.
@by_danali
@by_danali 3 жыл бұрын
very informative! love this video. thanks choobtorials!
@rahulnair7714
@rahulnair7714 3 жыл бұрын
What an excellent tutorial, simply brilliant! Thank you very much.
@choobtorials
@choobtorials 3 жыл бұрын
Thank you for the comment! Really appreciate it! Glad you liked the tutorial!
@danwest9900
@danwest9900 3 жыл бұрын
Superlative quality tutorial video! Thank you for posting!!!
@choobtorials
@choobtorials 3 жыл бұрын
Glad you liked it! Thanks for leaving a comment! Please share the link with others. Would really appreciate it!
@oguzhantopaloglu9442
@oguzhantopaloglu9442 3 жыл бұрын
Extremely informative and well explained!
@choobtorials
@choobtorials 3 жыл бұрын
Thank you! Appreciate the comment. Thanks for watching.
@choobtorials
@choobtorials 2 жыл бұрын
Can’t really say with just that info. There could be any number of things that are wrong . I suggest just going through the lines very carefully. There might be a typographical error or maybe a missing line somewhere.
@BaiLanRenSheng
@BaiLanRenSheng 3 жыл бұрын
A very underrated channel
@choobtorials
@choobtorials 3 жыл бұрын
Thanks! Appreciate what you said. I’ll just keep making videos!
@urishpolansky3953
@urishpolansky3953 3 жыл бұрын
waiting for you next video
@SujithManchala
@SujithManchala 3 жыл бұрын
Informative👍, thank you!
@Mraeth8n
@Mraeth8n 3 жыл бұрын
Wow such an awesome video! I've learned alot!
@choobtorials
@choobtorials 3 жыл бұрын
I’m glad you did! Thanks for watching!
@ThanhLe-ve1cj
@ThanhLe-ve1cj 3 жыл бұрын
very easy to understand.
@tas9214
@tas9214 3 жыл бұрын
Copied the exact same code till around minute 7:32, but the blue rectangle isn't showing up. Only the window opens, and there's nothing on there. Help? Thank you ^^ Edit: using public void paint(Graphics g) instead of protected void paintComponent(Graphics g) worked. Why is that? Edit 2: Doing DrawingCanvas extends JPanel, then overriding the paintComponent method also works. I'm quite confused. Any help much appreciated.
@choobtorials
@choobtorials 3 жыл бұрын
Hmmm not sure. Can you try changing it to extend JComponent again just to double-check?
@tas9214
@tas9214 3 жыл бұрын
@@choobtorials It worked! Woah😆 Thanks!
@choobtorials
@choobtorials 3 жыл бұрын
Haha I think maybe it was a typo in the method signature. Could have been something as small as just a single character with the wrong casing. So instead of overriding the paintComponent method, Java thought you were making a new, completely different one. Glad it works now!
@microsoftgamerx854
@microsoftgamerx854 Жыл бұрын
Amazing! . Can you make video on animination too
@brahimelhabzi5009
@brahimelhabzi5009 3 жыл бұрын
Thanks, it was exactly what I needed to know
@dapomeroy
@dapomeroy 2 жыл бұрын
This is great, thank you!
@SublimeNotions
@SublimeNotions 2 жыл бұрын
How would I generate those clouds automatically in an array and have the array print? Such that every time I run the program I have a randomly generated field of clouds. Ive been stuck on something like this for a couple of days. In my case though I want to generate a hundred or more objects and I want them to be random each time.
@choobtorials
@choobtorials 2 жыл бұрын
You can use Math.random() to generate values for the x, y, and size of the clouds. And put it in a loop to make it repeat as many times as needed.
@otengsamuel5175
@otengsamuel5175 2 жыл бұрын
I am struggling with my assignment and its states that, I should rotate dollar sign ($) using the drawSting method in java and also let it translate in the in its own path, meaning as the dollar sign is rotating, it should translate on a dollar sign path. This has become a challenge for me and I need your help to making a video and tag me on it please.
@meowsifer9324
@meowsifer9324 Жыл бұрын
ily sir choobs
@choobtorials
@choobtorials Жыл бұрын
🥰🥰🥰
@rooveloft5273
@rooveloft5273 2 жыл бұрын
7:55 the g2d.run() function isn't working for me :(
@choobtorials
@choobtorials 2 жыл бұрын
Can you check again? There’s no run method for the Graphics2D class mentioned in the video. And 7:55 is showing the DrawingTester class.
@rooveloft5273
@rooveloft5273 2 жыл бұрын
@@choobtorials That was 8:40 sorry! It was g2d.fill() method! At line 19
@choobtorials
@choobtorials 2 жыл бұрын
Hmm could be a lot of things. Can’t really know without more details. But could be a missing line of code somewhere or a mistake in the values for the rectangle or maybe the colors. If you’re getting a compile error, then there might be a syntax error somewhere.
@rooveloft5273
@rooveloft5273 2 жыл бұрын
@@choobtorials Ok, something was definitely wrong on my comp. I was learning so I wrote the exact code you did. I deleted the files and retyped the same code again, and now my computer decides that g2d.fill is now correct!😑 I am resuming your tutorial! Question: Can fillRect() method be used in place of fill()?
@mihirkulkarni5324
@mihirkulkarni5324 3 жыл бұрын
Does the JFrame have to be declared inside the Main function?
@choobtorials
@choobtorials 3 жыл бұрын
Generally speaking, no. It doesn’t have to be directly instantiated in the main method.
@fugeratube1334
@fugeratube1334 2 жыл бұрын
great tutorial thanks bro
@idirdjouab7931
@idirdjouab7931 Жыл бұрын
Thank you !!
@mechanicraft-mc7203
@mechanicraft-mc7203 3 жыл бұрын
Super helpful!
@hepno
@hepno 3 жыл бұрын
Thank you so much!
@choobtorials
@choobtorials 3 жыл бұрын
You’re welcome! Thanks for watching!
@luizinniziul2976
@luizinniziul2976 3 жыл бұрын
Que conteúdo magnifico 🤝
@854Rri
@854Rri Жыл бұрын
You save my life
@jbars2448
@jbars2448 2 жыл бұрын
Thank you.
@andreleao.prodemge
@andreleao.prodemge 2 жыл бұрын
Olá, tudo bem? Alguém pode me ajudar em como faço pra usar o Graphics2D sem ser usando JFrame, JPanel ou Applets? Tipo, meu projeto é web, preciso que o desenho seja renderizado numa DIV. Alguém pode me ajudar? Já procurei em muitos sites e todos só falam de JFrame, JPanel, Applets...
@choobtorials
@choobtorials 2 жыл бұрын
Unfortunately, you can’t. Graphics2D belongs to the Java library. It is not part of JavaScript. If you want to draw directly on a div, you can use the canvas element along with JavaScript.
@byte_hubs
@byte_hubs 3 жыл бұрын
how on the earth can it be free well-done
@choobtorials
@choobtorials 3 жыл бұрын
Haha thanks! If you could share it with others, I would greatly appreciate it.
@gabekramer388
@gabekramer388 2 жыл бұрын
I followed all of your steps and mine still didnt show up in my JFrame
@choobtorials
@choobtorials 2 жыл бұрын
It most likely means that you have a typo somewhere. For example, the paintComponent method could have been misspelled. One small mistake, such as using the wrong letter casing, will make the program not work as expected.
@gabekramer388
@gabekramer388 2 жыл бұрын
I thought figured that but I get no errors in the terminal so that's what is throwing me off....I was wondering if it was the version of Java maybe?
@choobtorials
@choobtorials 2 жыл бұрын
Not sure. Hard to say without more details. Does the JFrame come out at least? And if it does, it’s just blank?
@hkroot6183
@hkroot6183 3 жыл бұрын
❤❤❤❤
@dudedudedudedude5381
@dudedudedudedude5381 2 жыл бұрын
This is so underrated. just Why?
@choobtorials
@choobtorials 2 жыл бұрын
Duuuude. Waiting patiently for the day when the gods of the KZbin algorithm shower their blessings upon my humble channel.
@autopratama6152
@autopratama6152 2 жыл бұрын
please share source code?
@benkigera
@benkigera 3 жыл бұрын
Man , i was giving up on graphics, my professor is so dumb to be honest .
@choobtorials
@choobtorials 3 жыл бұрын
Sorry to hear about your prof. Hope this video helped. And feel free to share the link with your classmates, too!
@cate01a
@cate01a 3 жыл бұрын
I feel this is overly verbose, long, and could be simplified further
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1,1 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Java 2D graphics 🖍️
20:12
Bro Code
Рет қаралды 158 М.
How to Make a 2D Game in Java #1 - The Mechanism of 2D Games
18:11
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
Honda's New V3 Electrical Compressor Engine Explained
14:52
driving 4 answers
Рет қаралды 7 М.
Java 2D animation 🎞️
17:17
Bro Code
Рет қаралды 110 М.
Java KeyListener 🚀
13:11
Bro Code
Рет қаралды 101 М.
Build a Java Desktop Application - Full Course (Sudoku)
1:34:29
freeCodeCamp.org
Рет қаралды 367 М.
Java snake game 🐍
43:30
Bro Code
Рет қаралды 1,5 МЛН
Multithreading in Java Explained in 10 Minutes
10:01
Coding with John
Рет қаралды 982 М.