Programming Panning & Zooming

  Рет қаралды 65,262

javidx9

javidx9

Күн бұрын

A genuinely practical video today! In this video, I take a look at a really useful technique to easily add panning and zooming to your applications.
Source: github.com/OneLoneCoder/Javid...
/ discord
Blog: www.onelonecoder.com
Twitter: @javidx9
Twitch: javidx9

Пікірлер: 104
@neuemage
@neuemage 6 жыл бұрын
Welcome to "Coding in the wilderness", I'm your host Javid
@javidx9
@javidx9 6 жыл бұрын
"Here we see a rare console programmer, out of its natural habitat...."
@salagajeff6357
@salagajeff6357 4 ай бұрын
Thank you very much, if it weren't for you, I would never have figured out how to do zoom to the cursor. I looked at so much information on how to do this, and only you explained how.
@3DSage
@3DSage 6 жыл бұрын
I'm really glad you showed this topic! One that is so important but most people don't take the time to explain as well as you do.
@javidx9
@javidx9 6 жыл бұрын
Hey 3DSage, its a bit boring on the surface, but I bet all programmers at some point will need to know how to do it.
@seditt5146
@seditt5146 6 жыл бұрын
More Views in a few hours than my entire channel has over a few months of its existence. Glad to see the Channel picking up steam Javid!
@seditt5146
@seditt5146 5 жыл бұрын
Here thought i had not seen this video yet javid yet I come here and find my comment lol.
@2frankos
@2frankos 3 жыл бұрын
You, sir, enlightened me with an issue I had for a couple of days now: panning vs scaled texture. I was trying to pan a texture within a frame at where my location coordinates were translated. Works like a charm. I'll try to add zooming later on, I'll see how I hit my head around that, but thanks again!
@3DSage
@3DSage 6 жыл бұрын
How about making a video on optimization? Sin and cosine look up tables, bitshift multiply and divide, minimizing looping and so on.
@seditt5146
@seditt5146 6 жыл бұрын
I second this Javid, it would be a very good topic I think. Maybe get into Fast Sqrt and perhaps put your Fast Sin algorithm on display a bit more as well.
@johnnyserup5500
@johnnyserup5500 4 жыл бұрын
3DSage I think he already made one
@ForcesOfOdin
@ForcesOfOdin 4 жыл бұрын
This is super useful and practically language independent, thank you so much.
@Cgeta4
@Cgeta4 3 жыл бұрын
Oh my god a tutorial that actually teaches about how to zoom towards the cursor!
@chriswinslow
@chriswinslow 6 жыл бұрын
Excellent video and well explained too. This demonstration can be used in many applications. Thank you for sharing your valuable knowledge with the world.
@javidx9
@javidx9 6 жыл бұрын
Cheers Chris!
@Fragler01
@Fragler01 3 ай бұрын
You are a legend. I have been trieing to implement these methods in a HTML canvas project with Javascript. I have not found anyone explaining it for javascript, however the algebra translates through any programming languages, so thanks a lot 😁👍
@javidx9
@javidx9 3 ай бұрын
Thanks! I'm pleased you found it useful!
@vincentcleaver1925
@vincentcleaver1925 6 жыл бұрын
Thanks​! I'm applying everything I learned on this channel to my Python code; wrote some pseudo perlin noise for my world-building, low res, low poly
@javidx9
@javidx9 6 жыл бұрын
Very nice, make sure to send some pics!
@floretionguru2977
@floretionguru2977 4 жыл бұрын
This is exactly what I was looking for- thanks my friend!
@joshuaeirman2197
@joshuaeirman2197 5 жыл бұрын
Amazing little program, I love the mouse drag!
@lennarth.6214
@lennarth.6214 2 жыл бұрын
This is your most underrated video. Love the work
@gresh1134
@gresh1134 Жыл бұрын
THANK YOU!!! I'd been banging my head against a wall trying to figure out the math for this myself, and this worked perfectly!
@hatkidchan_
@hatkidchan_ 4 жыл бұрын
oh, that's exactly what I'm looking for. you saved a lot of my time, thanks
@socksockmaster
@socksockmaster 2 жыл бұрын
Very good explanation, thank you!!! I was banging my head against this problem for a while
@manuellehmann267
@manuellehmann267 6 жыл бұрын
Interesting, enjoayable and educational as always! Thx!
@javidx9
@javidx9 6 жыл бұрын
Cheers donnerbrenn!
@mmx555
@mmx555 5 жыл бұрын
i did not now i can write two lines of code at once !!! thanks man. ( if you can point things like that out next time, it will be great. !) i am glad find you in youtube !
@NoobishAlpha
@NoobishAlpha 4 жыл бұрын
Thanks to you I managed to program the pan !
@skeletonrowdie1768
@skeletonrowdie1768 3 жыл бұрын
AMAZING THANK YOU. You have no idea how I broke my brain over this.
@MrSanchezHD
@MrSanchezHD 6 жыл бұрын
A quality video as always. The things you can do in relatively few lines of code. Very interesting.
@javidx9
@javidx9 6 жыл бұрын
Thanks!, I agree, this is a simple technique but very powerful.
@reidblanton1436
@reidblanton1436 3 жыл бұрын
Thank you! This was very helpful, sir.
@krakenofdeath1701
@krakenofdeath1701 6 жыл бұрын
Nice large educational video! Im sure a lot of peeps will learn a bunch from it! -UE4
@javidx9
@javidx9 6 жыл бұрын
Cheers Kraken!
@herkyrannala1892
@herkyrannala1892 3 ай бұрын
This is what I've been looking for..Thank You Very Much!!!
@gkarapeev
@gkarapeev 4 жыл бұрын
Love this, thank you so much!
@thefoolishgmodcube2644
@thefoolishgmodcube2644 6 жыл бұрын
Outstanding, it could make up to be a useful sprite or map editor
@javidx9
@javidx9 6 жыл бұрын
Yeah, or any kind of 2D editor, circuit diagrams, audio tools. Very versatile.
@vrajshah8075
@vrajshah8075 Жыл бұрын
This is so cool. Thank you very much!
@rednibcoding3412
@rednibcoding3412 4 жыл бұрын
Nice video and awesome channel! I'm interested in almost every topic you cover in your channel. And I'm also kind of nostalgic when it comes to old blocky graphics, reminds me of my childhood. Still have a working NES and im proud of it :). I have one question: could you make a video about visualizing big datasets with olcPixelGameEngine? A bit like you've shown in this video. But with reading curve data from a large csv file (eg. +2gb). So the data has to be read dynamically from the file when the user pan/zoom the view (only data that is been displayed lie in memory), this would make it possible to visualize any size of csv-file/data.
@user-py8hd1xl7z
@user-py8hd1xl7z 2 жыл бұрын
I don't understand what you do in code, but everything in note i do understand. Note explaining helps get concept and now i can implement it myself. I think in programming videos better explain general concepts with hand written notes with no code. There is so much things in code that confuse me that i don't get what is going on. Only way to get though this is try to code it myself ( not just copy video code, implement it myself ) Anyway It's helpful video. But i wish more bloggers do more general concept content.
@unknownpng650
@unknownpng650 Жыл бұрын
same im trying to implement the zoom in c language using a different library for graphical interface
@duckyyy2682
@duckyyy2682 10 ай бұрын
thank you very much for this useful video!
@spjewkes
@spjewkes 6 жыл бұрын
Nice video. If I could, I’d give you another thumbs up for the conspicuous can of Vimto.
@javidx9
@javidx9 6 жыл бұрын
lol cheers Steve, one day they'll give some free ones, one day...
@vincentcleaver1925
@vincentcleaver1925 6 жыл бұрын
had to Google it- en.m.wikipedia.org/wiki/Vimto
@PhilBoswell
@PhilBoswell 6 жыл бұрын
Vim-TOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO ;-)
@themastergames7780
@themastergames7780 5 жыл бұрын
as always great videos man keep it up
@javidx9
@javidx9 5 жыл бұрын
Cheers buddy!
@johnnyserup5500
@johnnyserup5500 4 жыл бұрын
I enjoyed building this using your olcPixelGameEngine, and I noticed that I could select cells outside the grid, also the initial start of the chart was somewhat off. Any suggestions on how to handle the offset for chart, with respect to only drawing inside the grid?
@bsunjic
@bsunjic Жыл бұрын
Thank a lot!
@PhilBoswell
@PhilBoswell 6 жыл бұрын
This is ripe for encapsulation, so your programs just keep track of what is happening in the Game World and the underlying engine takes care of the transformations: nicely done ^_^
@javidx9
@javidx9 6 жыл бұрын
Absolutely, a "zoomable canvas" class is something you would use over and over.
@BlastinRope
@BlastinRope 3 жыл бұрын
All of my projects turn into future proofing something that as no future already
@colepeterson5392
@colepeterson5392 6 жыл бұрын
consistently awesome!!!!!!!!!!!!!!!!!!
@javidx9
@javidx9 6 жыл бұрын
Thank you!
@johnnyserup5500
@johnnyserup5500 4 жыл бұрын
Any chance you could give some info on how olcPixelGameEngine could be used togethers with a device context (DC), I would like to render in a MFC Dialog box if possible
@shankar4510
@shankar4510 3 жыл бұрын
Hi . I am Trying to zoom out from the pixel matrix where I use p[i +j*i] in a loop to access width and height (single dimention array for screen surface). however the painting app has to retain the previous drawn pixel when zoomed out as well. Does This meathod work for such type of data as well ? what should I do ?
@shankar4510
@shankar4510 3 жыл бұрын
I program in C and find dufficult to understand . Can You point me to some math website you refer to ? Are you using K-Times Zoom Algorithm ?
@qislegit.donttrustthemedia6232
@qislegit.donttrustthemedia6232 4 жыл бұрын
Have you ever seen/played PilotWings on the NES? What kind of graphics engine does it use? It appears 3D but I'm curious as to what techniques are used to get that type of 3D effect. Is it raycasting?
@javidx9
@javidx9 4 жыл бұрын
It was on the SNES. Its a hardware affine transform called "Mode7". I made a video that emulates the effect called Programming pseudo3d planes.
@qislegit.donttrustthemedia6232
@qislegit.donttrustthemedia6232 4 жыл бұрын
@@javidx9 Awesome! Thank you so much! 🙏🏻
@movietrailerspreview9098
@movietrailerspreview9098 3 жыл бұрын
we use this in our web also on image zooming, right thanks man
@johnnyserup5500
@johnnyserup5500 4 жыл бұрын
Could you make a video about creating an audio sample Visualizer ? or did you already make a video about showing sampled sound ?
@johnnyserup5500
@johnnyserup5500 4 жыл бұрын
Also this video is a perfect start for next topic - how to visualize FFT ; so far there are videos about this in JavaScript, but it would be nice to see it done in C++ with your pixel game engine
@philtoa334
@philtoa334 4 жыл бұрын
Thx
@unknownpng650
@unknownpng650 Жыл бұрын
can someone help me how to implement this in c , i would like to understand the concept of zooming in and out from programming perspective
@crew575
@crew575 5 жыл бұрын
There is no funcion 'Fill' anymore i think. Can i replace it with 'FillRect'?
@hemrajsinghgheeseewan3550
@hemrajsinghgheeseewan3550 5 жыл бұрын
Hello guys. I am searching for a Scalable Coordinate system which can accommodate a drawing of any size. Can you guys help me find a sample of this in JAVA? Thanks in advance.
@javidx9
@javidx9 5 жыл бұрын
Hi Kev, "any size" may bring about a lot of philosophical computation problems for you to overcome, do you have a more refined specification?
@hemrajsinghgheeseewan3550
@hemrajsinghgheeseewan3550 5 жыл бұрын
Thanks a lot for the response Mr Javid. So, my idea is that I will have x-Axis and y-Axis, both negative and positive sides a on frame. Then, I have to draw a basic shape (square, circle, polygons), from the centre of origin, on the axes. Now, I have 2 options. A and B. Option A: The Scales on the Axes must grow according to the size of the shapes that I am inputting in a text box. Suppose the axes are both initialised to a scale of 10 to -10. If I input a radius of 20 using a basic text box, the scale should then increase to 20 and -20 on both axes. The circle then is shown on the axes. Option B: The scale is initialled to a value, say 10 to -10 on both axes. Then, I input a radius which is within the range of 0 to 10, say 5. Then, I should be able to Zoom or enlarge the circle (using any method: mouse sliding, mouse scroll, or any other methods) and once I reach the last value on my scale, the scale should start to increase with the circle. Its like the Axes grow while I am zooming/enlarging the shape. Either on of those two would be just fine.
@kartune0832
@kartune0832 Жыл бұрын
i was wondering, does it works with sprites?
@jonathanmoore5619
@jonathanmoore5619 3 жыл бұрын
Is there anyway of writing text whilst also increasing the pixel density? So, I guess a separate part of the screen for txt with a wider font size associated too it...I'm thinking legend here... Axis details... And then a more granular pixel setting inside these bounds?
@javidx9
@javidx9 3 жыл бұрын
Generally all applications operate at a single pixel density, a limitation imposed by the display hardware. One can emulate different densities by drawing 2x2 pixels or 3x3 pixels at a time instead of just the one.
@jonathanmoore5619
@jonathanmoore5619 3 жыл бұрын
@@javidx9 so when looping through the screen array buffer... To fill the screen... Change from, for example 4*4 to 8*8 for pixels. Is that what you mean? One final thing.. Ive watch nearly all the vids, is there a brief summary to show the general difference between the console and pixel engines? In terms of the general idea?
@javidx9
@javidx9 3 жыл бұрын
@@jonathanmoore5619 Yes pretty much. The difference between CGE and PGE is fundamentally nothing - they have the same functions, experience and are compatible. However, PGE is maintained, supported, cross platform, very powerful, documented and used by many. The CGE is none of those things.
@jonathanmoore5619
@jonathanmoore5619 3 жыл бұрын
@@javidx9 kk
@noahwatson4310
@noahwatson4310 2 жыл бұрын
I don't think there's a need for seperate X and Y scale values as, in this program, they're updated in exactly the same way. Therefore the only use of having two scale values instead of one would be to leave the door open for zooming in only 1 axis on its own, which seems like something you'd only do by mistake.
@javidx9
@javidx9 2 жыл бұрын
Plenty of graphing applications would want zooming per axis, let alone electrical instrumentation, audio generation and editing tools, numerical analysis tools.
@noahwatson4310
@noahwatson4310 2 жыл бұрын
@@javidx9 that's very true, I suppose I was just focused on the use case of displaying a 2d world and only left my initial reply after making a mistake involving the scaling.
@joseloeza371
@joseloeza371 3 жыл бұрын
Greetings from Dayton Ohio
@javidx9
@javidx9 3 жыл бұрын
Greetings!
@ananbig8935
@ananbig8935 9 ай бұрын
why my square is rectangle ,did my console setting wrong?please help me 8:08
@ananbig8935
@ananbig8935 9 ай бұрын
why my square is rectangle ,did my console setting wrong?please
@rcookman
@rcookman 5 жыл бұрын
I just did this in an application.
@javidx9
@javidx9 5 жыл бұрын
Hey thats great rcookman! lol, before or after watching the video? :D
@rcookman
@rcookman 5 жыл бұрын
Before, cool video thanks for sharing.
@berozzzgaarengineer
@berozzzgaarengineer Жыл бұрын
from this how much can you zooming
@javidx9
@javidx9 Жыл бұрын
Theoretically there is no limit. Practically the precision of the data type for your variables will become a factor.
@fckyo333ujhjjkrrrr
@fckyo333ujhjjkrrrr 6 жыл бұрын
New Video!
@javidx9
@javidx9 6 жыл бұрын
lol, that was quick :D
@fckyo333ujhjjkrrrr
@fckyo333ujhjjkrrrr 6 жыл бұрын
javidx9 got the notification :]
@ashutoshaswal
@ashutoshaswal 4 жыл бұрын
😵😵
@alkimista9055
@alkimista9055 Жыл бұрын
Thats not for me, I passed the entire night seeing your videos and searching for answers and i dont get any knowledge about this, I start this 21:00 and now its 07:40 and i dont get any worth
@kiprus1476
@kiprus1476 3 жыл бұрын
Пора учить английский...
@6Pope9
@6Pope9 Ай бұрын
the way you're typing x triggers me so much
Programming Racing Lines
33:04
javidx9
Рет қаралды 37 М.
Универ. 10 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:04:59
Комедии 2023
Рет қаралды 2,4 МЛН
Climbing to 18M Subscribers 🎉
00:32
Matt Larose
Рет қаралды 34 МЛН
Why You Should Always Help Others ❤️
00:40
Alan Chikin Chow
Рет қаралды 131 МЛН
СНЕЖКИ ЛЕТОМ?? #shorts
00:30
Паша Осадчий
Рет қаралды 7 МЛН
What was Coding like 40 years ago?
29:05
The Coding Train
Рет қаралды 1,7 МЛН
The mind behind Linux | Linus Torvalds | TED
21:31
TED
Рет қаралды 6 МЛН
Hacker101 - JavaScript for Hackers (Created by @STOKfredrik)
24:17
Cross Platform Graphical User Interfaces in C++
44:49
javidx9
Рет қаралды 858 М.
Solid.js Just Got WAY Better
13:11
Theo - t3․gg
Рет қаралды 81 М.
Programming Pseudo 3D Planes aka MODE7 (C++)
27:16
javidx9
Рет қаралды 102 М.
Practical Polymorphism C++
41:44
javidx9
Рет қаралды 124 М.
Coding Challenge 166: ASCII Text Images
22:42
The Coding Train
Рет қаралды 1,1 МЛН
The Math behind (most) 3D games - Perspective Projection
13:20
Brendan Galea
Рет қаралды 372 М.
What Is The Most Complicated Lock Pattern?
27:29
Dr. Zye
Рет қаралды 1,3 МЛН
cute mini iphone
0:34
승비니 Seungbini
Рет қаралды 2,2 МЛН
Will the battery emit smoke if it rotates rapidly?
0:11
Meaningful Cartoons 183
Рет қаралды 27 МЛН
🔥Идеальный чехол для iPhone! 📱 #apple #iphone
0:36
Не шарю!
Рет қаралды 1,3 МЛН
ВЫ ЧЕ СДЕЛАЛИ С iOS 18?
22:40
Overtake lab
Рет қаралды 136 М.