I just found out about your channel and I wish I would have found it sooner! I didn't know a lot of stuff pure js can do. Amazing advanced tutorials, great job!
Hi Yeshaya, I'm happy you found me :) Pure JS can do a lot, I hope to explore much more in future videos. Thank you for taking the time to leave a comment.
This is the stuff I need! Been getting into JavaScript and it's these type of projects that make me continue to dive in and see what the possibilities are! Thanks Frank.
I am fascinated by how much beauty can be made by using Canvas and need to strengthen my portfolio so I am doing it by following these tutorials, I started to go with Pixel-rain tutorial of yours but had some trouble with the PNG tool so I came to something a bit more beginner. I want to get better at javaScript and get a job but have trouble getting motivated but HTML5 Canvas has kind of changed that so I am looking forward to learning with you!!
It can be hard to focus on studies during difficult times like this. That's why it's good to pick up fun project like particles or gamedev once in a while. Hopefully it will keep you motivated. Good luck with your coding Jason. :)
@@Frankslaboratory Thanks very much! I am building out a client's site from scratch right now!. Thanks for the encouragement! I'll need another Canvas break after this LOL
@@Frankslaboratory Every new layout I learn how to create is one more I can use for the next customer! I started getting excited the first time someone put it to me like that. I like it WAY better than trying to build with any website builder. As someone who learned to code HTML and CSS before EVER touching a site builder, they confuse me still lol.
@@BibleTechNutt I have never used site builder, not sure how they work. It gives you great work experience building from scratch, eventually you could be the person building site builders haha. I'm sure these tools are great when you want something quick, and they are improving them all the time, but building from scratch and understanding how it works will always win.
Hi Henrique. Thank you for taking the time to comment, nice to meet you. You are much more experienced than me, I hope to get to that level of programming experience one day. What kind of projects do you build with shaders?
Thank you Henrique, very kind. It means a lot to get this kind of feedback from an experienced dev. If you ever see something in my code that can be simplified or better explained please let me know. I am still learning how to make my videos more accessible for beginner programmers.
I think starting from the basic concept is a good way to get people on board because sometimes I get complains that the effects are too complex. Thanks for nice feedback Mark
Awesome tutorial Frank. I Knew about pixel manipulation but had no idea how to do it, and it wasn't something I was looking into. I am self taught and started trying to learn everything I could about the JavaScript language after learning the basics of several languages. I am more recently learning game development. I had no drive to mess with pixel manipulation until I saw the remarkable programs you built with it. Everything in coding involves a learning curve or memorization of built-in methods when learning a API , framework, or library. I didn't know some of the canvas api's built-in methods, such as getImageData(). Looking forward to watching more videos on pixel manipulation. Your an exceptional developer and this channel is simply phenomenal. Thank you so much, I am learning a lot.
Hi Jeremy, it's always nice to see a comment from you. Thank you for being supportive. I'm learning about new things that can be done as well, and trying to combine them in interesting ways. I discovered a couple of very cool tricks I want to make tutorials on, just need to come up with a good project. Are you saying that after trying many languages you settled on JavaScript or are you still undecided?
Hi Frank, Oh no I don't see myself using any other front end development language anytime soon Plus I have already invested to much time into JavaScript. Its a beautiful expressive versatile language. I learned the basics of Java and a few others. There is so much to learn in JavaScript alone that I don't think I will be looking at becoming an expert in any other language anytime soon. But I do need to eventually pick one or two server side languages. I was thinking node.js since its just JavaScript and PHP or Python. I need to revisit SQL as well. Eventually, I would like to be able to combine front end , server side, and database languages to build an online game . For now, my focus is just to get a HTML5 mobile game developed that's download worthy. A game that only needs session or local storage to store a high score and game state. I am getting close but not quite there. Although I understand the language very well using it to build complex applications is very different. Its like saying that because one can write then they must be able to write a great book or best seller. I did take your game and do quite a bit with it. Built a separate small abstract engine, One-off canvas object, and moved some methods to where they were better suited for what I was doing. I added new methods. I added a loadImage, loadAssets, update, and loadHandler methods to a Game object. I added a health bar that looses health when bubbles hit the top of canvas and changes color from green to red when it hits 50% . The bar disappears when there is no more player health , the game state freezes, and a Game over message is displayed. I also have a state for winning when the score gets to a certain point. I was going to post this code, but I felt it was too long. Like this message. I was thinking of doing a video for this code while promoting your page, but I don't want to do you tube videos right now. I have to find a quite place, get into the mind set, and it takes time. Anyhow your tutorials are awesome and you explain stuff with such clarity and charisma. You could teach courses on Udemy if you don't already. Your tutorials are better than most the videos I watch on Udemy.
Hello, first of all, your videos are fabulous. Especially, when you explain every line of code. Can you please create a tutorial to code an image editor with features like zoom and pan the images drawn on the canvas?
Akash! thank you so much for a lovely comment. Yes I like this idea, putting it on my to do list. Thank you for letting me know what content you are looking for
Is it just me who's experiencing this? I can't set the scannedImage.data = scannedData. The console said that scannedImage.data is a read only property meaning that I can't set the value of that property
@@Frankslaboratory That would be awesome! It's really cool being able to synchronise and create relationships between audio and visual elements, there's so much potential and I look forward to seeing more of it on the web.
If you use vsCode and get the message "Tokenization is skipped for long lines for performance reasons. The length of a long line can be configured via `editor.maxTokenizationLineLength`." 1. Go to Settings (cogwheel bottom left -> settings) 2. Type 'max' in the search bar at the top 3. Two steps down you will find 'Editor: Max Tokenization Line Lenght' By default, this is set to 20'000. Add for example a 1 in front of this and you should be good to go :)
Hey, Frank. Why not set the body to "{ display: flex; }'", with {align-items: center;}, and {justify-content: center;} to center the canvas? Or is this just a personal preference?
Hi Scott, this is a great suggestion thank you. In my job I have to support old internet Explorer, so I guess it became a habit to avoid flexbox, because some of it's properties won't work in Internet Explorer. But for tutorials like this with experimental modern JavaScript code it doesn't really make sense for me not to use it. Thank you for a useful comment, I will try to remember that in the future :)
Hi Doraemon, that's a great idea, I did episode where you can control game character with keyboard arrows, I will do more of that but also maybe clickable controls on screen would be interesting to try
OK, that was some pretty cool stuff -- thanks Frank! "What is it you like about creative coding?" @ 2:26 - I'm the first answer. Are you the third answer, Frank?
Hi Jon, how do you know me so well. For me it is the third one and also the first one. I make a lot of mistakes as well as any student and this is a good practice for me.
Oh. I havent released tutorial for that. Its variation on particle rain effect I show off in this video a lot. The base effect will be the second part of this video when I finish it
This means a lot to me, thank I consider you as my inspiration and when I feel depressed I just take one of your courses to give me the portion of motivation I need@@Frankslaboratory
More pixel manipulation !!!! Awesome 👍 !! This time it's also on a big scale , cool !! And I have finally done with my game , I just ended up adding weird ai I.e. which player car hit the other car it bump toward other side and have it's speed decreased ..... I need to study a ton more , to start making some decent games .... It's gonna sometime
Its good to have a project like that, with your game. It motivates you to learn new coding tricks. Some game mechanics can be tricky to implement if you try to figure it out yourself. Most has already been invented so sometimes its good to look at other peoples code. Even if its in a different programming language. The logic will work the same
Hey great video! Question. I want to store imageData rgb array and use it after it is loaded OUTSIDE load function. So i came up with this code : (inside constructor of class named "BitmapBase64") this.width = 0; this.height = 0; const sprite = new Image(); sprite.src = data; sprite.addEventListener('load',function(){ this.width = sprite.width; this.height = sprite.height; m_context.drawImage(sprite,0,0,sprite.width,sprite.height); const scannedImage = m_context.getImageData(0,0,sprite.width,sprite.height); this.pixels = scannedImage; console.log(this.pixels); }); I tried to store data to pixels but it is undefined when i try to access it. let sprite = new Bitmap('**put base64 text here**); console.log(sprite.pixels); //undefined what am i doing wrong?>?
Thanks for making this awesome videos. I was looking for an intro to JavaScript gamedevelopment. I liked the first video so much, I want to see the whole playlist.
At 8:13 I run into an error: Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data. at Image. (file:///F:/JS_test/Pixel_Manipulation/script.js:12:27)
Thanks, Frank. This text string looks ugly but is seems to be a powerful tool to control every single pixel. I gues this allows to perform some computer vision tricks like pattern recognition?
Hi Aleksandr. Probably there is a way to do that, code can do anything, but not with canvas API because getImageData will get pixel information from canvas element so the image needs to be drawn on canvas for its pixels to be analysed.
Hi, I don't think it makes the code heavier, since the image code needs to be loaded before any JavaScript that depends on that image can run. It doesn't make much difference if that image code is in .js file as base64 data string or if it's read directly from .png file. It has no effect on performance. If you want to use this technique with image files, if you point src attribute to that image it will work, if the image and code file sit on the same server. It will not work locally on an offline machine, since that will trigger CORS.
You get cross origin errors when you use an image file locally on your computer combined with GetImageData method. It's expected. This is an old video, I'm sure I explain and cover how to deal with that in the video itself.
Hi Marleen, did you manage to solve it? I assume you are doing something different than me in the video, most likely running it though server or something right?
I have à problem at 7:48 it say Uncaught DOMExeption: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': the canvas has been tainted by cross-origin data I dont understand ... I am french that not help me 😂
Hi Yeshaya, the pixel data array contains 0-255 values so you would have to convert it, the algorithm to convert rgba to hex is quite simple css-tricks.com/converting-color-spaces-in-javascript/
@@Frankslaboratory Thank you so much! I tried making an image filter tool with this tutorial. It would be awesome if you could check it out in your free time and give me feedback. codepen.io/steelshot/pen/LYZJmGR
Wow you made it into interactive colour shift project with colour picker and everything. I wish I had this idea before making this tutorial, haha. Would have built something like that instead. I followed you on Codepen. This is actually a nice project for coding portfolio as well.
The line 14: const scannedData=scannedImage.data; and the line 18: scannedData[i]=averageColorValue; should produce an error - an attempt to modify a constant. But they work. What am I getting wrong?
Hi, this will not produce an error since you are no reassigning const variable to a completely different value, you are just modifying values within that same array. Assigning const variable doesn't freeze array completely. Const cannot be reassigned but can be modified.
Frank! I love your videos, Thank u ! I don't know why I get this error: Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data. at Image. My JS CODE: const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); canvas.width = 425; canvas.height = 600; const image1 = new Image(); image1.src = './Dua.png'; image1.addEventListener('load', function(){ ctx.drawImage(image1, 0, 0, canvas.width, canvas.height); const scannedImage = ctx.getImageData(0, 0, canvas.width, canvas.height); console.log(scannedImage) })
MAN FUCK HAHAHAHAHA When I got this error, I paused the video and I start a big research to fix it, when I fix the problem, I start the video again, and in the next seconds you explain the error... hahahaha, I passed 3 hours searching how fix this and you explain to me it in 3 minutes, your videos are amazing
Hi Alex, 1 loop is always better yes, I try to do it when possible, unless doing that requires too much explanation and the tutorial is aimed for beginners. Sometimes I choose to be less optimal if it means the video is easier to understand
Your videos are wonderful. I figured out your particle trick, and how to set up a GitHub repo if you want to take a look: github.com/Bad-Wolf-42/particle-painting I don't know if it's okay to post links to my own stuff in comments. If not, then I apologize. I had a lot of fun making this. Thank you.
Hi Wolf. Thank you for your feedback. Impressive. It seems you came up with a different solution to the same problem. You are good, this is not easy to do. Thank you for sharing. You can post anything in comments, sometimes UA-cam puts it in spam folder because it contains a link but I check it once in a while and approve the comments. I think the solution you came up with is actually better than mine :D
How was your week. This is another of my attempts to get you excited about coding with JavaScript. Have fun. Click the LIKE please :)
Thank you so much for this tutorial!
Thanks Will, happy to hear that :D
Hi Shadow, glad to know you like it :D I have more free time on my hands these days
Trying this soon :D
Thank you so much for this tutorial.
I only wanted to know how to identify a pixel but then I found this quite interesting and of really great quality
I just found out about your channel and I wish I would have found it sooner! I didn't know a lot of stuff pure js can do. Amazing advanced tutorials, great job!
Hi Yeshaya, I'm happy you found me :) Pure JS can do a lot, I hope to explore much more in future videos. Thank you for taking the time to leave a comment.
dude you are purely amazing..
This is the stuff I need! Been getting into JavaScript and it's these type of projects that make me continue to dive in and see what the possibilities are! Thanks Frank.
Really? Thank you for letting me know Javis, I'm happy that you found this inspiring in some way :)
Great video and wonderfull approach to break down the topic and teach it! Thank you so much!
What series a beginner like me should follow? I am new to CSS, HTML5 and JavaScript. Thanks a lot for your creative efforts!
the speed and the clarity with which you teach is super
Crystal clear
Hi Nazir, I'm happy to hear a feedback like this, thank you!
It is a good tip about the image load event listener. I spent all day trying to draw an image without this!
Yea it's very important and it is a source of problems ha
To be honest, this video deserves 1M likes!
This is great!!! O-O
Thank you Shadow, you always support my content :)
beautiful tutorial, thank you, it's really clear. I 'm already waiting for the next one ( :
Happy to hear this feedback, thank you Tomas
I am fascinated by how much beauty can be made by using Canvas and need to strengthen my portfolio so I am doing it by following these tutorials, I started to go with Pixel-rain tutorial of yours but had some trouble with the PNG tool so I came to something a bit more beginner. I want to get better at javaScript and get a job but have trouble getting motivated but HTML5 Canvas has kind of changed that so I am looking forward to learning with you!!
It can be hard to focus on studies during difficult times like this. That's why it's good to pick up fun project like particles or gamedev once in a while. Hopefully it will keep you motivated. Good luck with your coding Jason. :)
@@Frankslaboratory Thanks very much! I am building out a client's site from scratch right now!. Thanks for the encouragement! I'll need another Canvas break after this LOL
@@BibleTechNutt I love building sites from scratch, can be a lot of work especially when you get to mobile/table styles etc. Good luck!
@@Frankslaboratory Every new layout I learn how to create is one more I can use for the next customer! I started getting excited the first time someone put it to me like that. I like it WAY better than trying to build with any website builder. As someone who learned to code HTML and CSS before EVER touching a site builder, they confuse me still lol.
@@BibleTechNutt I have never used site builder, not sure how they work. It gives you great work experience building from scratch, eventually you could be the person building site builders haha. I'm sure these tools are great when you want something quick, and they are improving them all the time, but building from scratch and understanding how it works will always win.
I didn't skip any ads in your video. you deserve. it
I have 10 years of experience I even do things with shaders but you earned a new subscriber.
Hi Henrique. Thank you for taking the time to comment, nice to meet you. You are much more experienced than me, I hope to get to that level of programming experience one day. What kind of projects do you build with shaders?
@@Frankslaboratory hehe the important thing is to have fun. Great tutorials man, even for experienced developers.
Thank you Henrique, very kind. It means a lot to get this kind of feedback from an experienced dev. If you ever see something in my code that can be simplified or better explained please let me know. I am still learning how to make my videos more accessible for beginner programmers.
Excellent instruction! You read my mind about what I wanted to figure out.
I think starting from the basic concept is a good way to get people on board because sometimes I get complains that the effects are too complex. Thanks for nice feedback Mark
This is awesome!! Thank-you!!
Awesome tutorial Frank. I Knew about pixel manipulation but had no idea how to do it, and it wasn't something I was looking into. I am self taught and started trying to learn everything I could about the JavaScript language after learning the basics of several languages. I am more recently learning game development. I had no drive to mess with pixel manipulation until I saw the remarkable programs you built with it. Everything in coding involves a learning curve or memorization of built-in methods when learning a API , framework, or library. I didn't know some of the canvas api's built-in methods, such as getImageData(). Looking forward to watching more videos on pixel manipulation. Your an exceptional developer and this channel is simply phenomenal.
Thank you so much, I am learning a lot.
Hi Jeremy, it's always nice to see a comment from you. Thank you for being supportive. I'm learning about new things that can be done as well, and trying to combine them in interesting ways. I discovered a couple of very cool tricks I want to make tutorials on, just need to come up with a good project. Are you saying that after trying many languages you settled on JavaScript or are you still undecided?
Hi Frank, Oh no I don't see myself using any other front end development language anytime soon Plus I have already invested to much time into JavaScript. Its a beautiful expressive versatile language. I learned the basics of Java and a few others. There is so much to learn in JavaScript alone that I don't think I will be looking at becoming an expert in any other language anytime soon. But I do need to eventually pick one or two server side languages. I was thinking node.js since its just JavaScript and PHP or Python. I need to revisit SQL as well. Eventually, I would like to be able to combine front end , server side, and database languages to build an online game . For now, my focus is just to get a HTML5 mobile game developed that's download worthy. A game that only needs session or local storage to store a high score and game state. I am getting close but not quite there. Although I understand the language very well using it to build complex applications is very different. Its like saying that because one can write then they must be able to write a great book or best seller. I did take your game and do quite a bit with it. Built a separate small abstract engine, One-off canvas object, and moved some methods to where they were better suited for what I was doing. I added new methods. I added a loadImage, loadAssets, update, and loadHandler methods to a Game object. I added a health bar that looses health when bubbles hit the top of canvas and changes color from green to red when it hits 50% . The bar disappears when there is no more player health , the game state freezes, and a Game over message is displayed. I also have a state for winning when the score gets to a certain point. I was going to post this code, but I felt it was too long. Like this message. I was thinking of doing a video for this code while promoting your page, but I don't want to do you tube videos right now. I have to find a quite place, get into the mind set, and it takes time. Anyhow your tutorials are awesome and you explain stuff with such clarity and charisma. You could teach courses on Udemy if you don't already. Your tutorials are better than most the videos I watch on Udemy.
Thank you very much for this tutorial!! ♥
Hi Esteban, I'm here to help :)
Wow! Impressive. Very cool, man.
you flipping rule! ty so much, I love it.
Hi Frank! Yes, you can put viruses in images.
Thanks for great tutorials!
That's what I was afraid of :D No idea how virus in image would work, but it's good to be aware of it.
I really like the way you explain things.
Hi Sagar, how are you. I try to explain things properly in videos I mark 'for beginners' like this one. I'm glad you noticed :)
Hello, first of all, your videos are fabulous. Especially, when you explain every line of code. Can you please create a tutorial to code an image editor with features like zoom and pan the images drawn on the canvas?
Akash! thank you so much for a lovely comment. Yes I like this idea, putting it on my to do list. Thank you for letting me know what content you are looking for
Please post part 2 of this as soon as you can!
Hi Mark. I want to make sure its the best possible quality. Will release it soon :)
Is it just me who's experiencing this? I can't set the scannedImage.data = scannedData. The console said that scannedImage.data is a read only property meaning that I can't set the value of that property
Thank you for your all tutorials!!
Thank you for letting me know you found some value here. I will try to make more content like this
You're the best Frank! Thanks for all these amazing tutorials, they are super informative and fun :)
If you get the chance, check out my latest HTML/JS experiment here: sonodrome.co.uk/permute
This is so cool, I love coding experiments like this. Did you use vanilla JS or is there a good library for effects like this
@@Frankslaboratory It's all vanilla, just using HTML5, Canvas and webAudio API
@@sonodrome Love it, I will try to create some sound art effect with my next particle systems video, let's see what comes out of it :D
@@Frankslaboratory That would be awesome! It's really cool being able to synchronise and create relationships between audio and visual elements, there's so much potential and I look forward to seeing more of it on the web.
Very nice. Your videos make coding fun and interesting. Thanks for making these.
You have been going through my library, thank you for leaving nice feedback like this ❤
wonderful tutorial. great work. Makes things easy to understand.😄
Eagerly waiting for part 2
Hi Mitesh, part 2 is in the works :)
Love your tutorials. learned a lot from these tutorials. Keep making, thanks!
Can you please make a tutorial on falling confetti with vanila js.
Sachin! Thank you so much you are very kind. I will make some confetti effects, good idea
King King , I got you thank you very much, subscribed 😎
Great teaching. Subscribed.
Intro 10/10
Thank you :D
If you use vsCode and get the message "Tokenization is skipped for long lines for performance reasons. The length of a long line can be configured via `editor.maxTokenizationLineLength`."
1. Go to Settings (cogwheel bottom left -> settings)
2. Type 'max' in the search bar at the top
3. Two steps down you will find 'Editor: Max Tokenization Line Lenght'
By default, this is set to 20'000. Add for example a 1 in front of this and you should be good to go :)
Hi Joakim, this is a great point, thank you for sharing your knowledge with us!!
Hey, Frank.
Why not set the body to "{ display: flex; }'", with {align-items: center;}, and {justify-content: center;} to center the canvas? Or is this just a personal preference?
Hi Scott, this is a great suggestion thank you. In my job I have to support old internet Explorer, so I guess it became a habit to avoid flexbox, because some of it's properties won't work in Internet Explorer. But for tutorials like this with experimental modern JavaScript code it doesn't really make sense for me not to use it. Thank you for a useful comment, I will try to remember that in the future :)
Amazing,great tutorial,Thank you so much
Hi, glad you liked it, I am working on more effects using this technique, ASCII art etc
Please make a video on how to make mobile controls for javascript game.. like gba controls.. moving forward,backward,left,right
Hi Doraemon, that's a great idea, I did episode where you can control game character with keyboard arrows, I will do more of that but also maybe clickable controls on screen would be interesting to try
Thank you for the series
Glad you like it Deepak :)
OK, that was some pretty cool stuff -- thanks Frank! "What is it you like about creative coding?" @ 2:26 - I'm the first answer. Are you the third answer, Frank?
Hi Jon, how do you know me so well. For me it is the third one and also the first one. I make a lot of mistakes as well as any student and this is a good practice for me.
Great teaching skills ❤️
Thank you Yash ❤️
Hair glittering animation at 1:45 is so nice
Hi Gopinath. I was playing with some variations. This one turned out quite nice. Thank you
@@Frankslaboratory do u have that
@@gopinathkrm58 what do you mean
@@Frankslaboratory I mean which video are u doing that kind of animation
Oh. I havent released tutorial for that. Its variation on particle rain effect I show off in this video a lot. The base effect will be the second part of this video when I finish it
hi sir,
hope u doing will
i have a question howcan i get all pixels for same color in image and then remove this color or change it to white
Actually Creative Coding was my first passion when I came to programming
Amazing. Glad to hear I'm not alone like that. You are talented I saw your work
This means a lot to me, thank I consider you as my inspiration and when I feel depressed I just take one of your courses to give me the portion of motivation I need@@Frankslaboratory
Video begins at 2:56
Wonderful
More pixel manipulation !!!!
Awesome 👍 !! This time it's also on a big scale , cool !!
And I have finally done with my game , I just ended up adding weird ai I.e. which player car hit the other car it bump toward other side and have it's speed decreased .....
I need to study a ton more , to start making some decent games ....
It's gonna sometime
Its good to have a project like that, with your game. It motivates you to learn new coding tricks. Some game mechanics can be tricky to implement if you try to figure it out yourself. Most has already been invented so sometimes its good to look at other peoples code. Even if its in a different programming language. The logic will work the same
@@Frankslaboratory I'll love to try new things , even if it gives weird result , I like to do crazy stuff
Me tooo :D Weird stuff is the best :D
@@Frankslaboratory HAHAHAHA , SO true 😂😝
Had the Cross origin issue. I was able to get it working by starting Chrome with the --allow-file-access-from-files option
Hi Angelo, thank you for sharing, cross origin issues can be tricky to deal with
sorry, frank, but sometimes i get so engrossed in your tutorials from beginning to end that i forget to hit like XD
Hi Jet, you are forgiven hahaha. Thank you for watching my videos, hope to see some of your creative projects in the future :)
great video
Hey great video!
Question.
I want to store imageData rgb array and use it after it is loaded OUTSIDE load function.
So i came up with this code :
(inside constructor of class named "BitmapBase64")
this.width = 0;
this.height = 0;
const sprite = new Image();
sprite.src = data;
sprite.addEventListener('load',function(){
this.width = sprite.width;
this.height = sprite.height;
m_context.drawImage(sprite,0,0,sprite.width,sprite.height);
const scannedImage = m_context.getImageData(0,0,sprite.width,sprite.height);
this.pixels = scannedImage;
console.log(this.pixels);
});
I tried to store data to pixels but it is undefined when i try to access it.
let sprite = new Bitmap('**put base64 text here**);
console.log(sprite.pixels); //undefined
what am i doing wrong?>?
Solved it by viewing the site in Xammp localhost
Hi Marleen, awesome. glad you found it!
Thanks for making this awesome videos. I was looking for an intro to JavaScript gamedevelopment. I liked the first video so much, I want to see the whole playlist.
can you please increase the font size so that people viewing on mobile finds it easier to follow your video
Hi Nazir, the video I just released still has small font size, but I will keep that in mind and increase it for the next ones
You are Amzing
Thank you :)
Gracias, te amo.
🙏🙏❤
At 8:13 I run into an error:
Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
at Image. (file:///F:/JS_test/Pixel_Manipulation/script.js:12:27)
If you keep watching I explain how to fix it in the next couple of minutes. Sorry I structured the video in a way that this error happens at first
Thanks, Frank. This text string looks ugly but is seems to be a powerful tool to control every single pixel. I gues this allows to perform some computer vision tricks like pattern recognition?
i love tuto
Thanks Oly, nice to meet you
thanks!
You are welcome Mohammad :)
Isn't there a chance to get data right from the image, skipping the step of drawing it within the canvas element?
Hi Aleksandr. Probably there is a way to do that, code can do anything, but not with canvas API because getImageData will get pixel information from canvas element so the image needs to be drawn on canvas for its pixels to be analysed.
converting base64 is like putting all the image weight into the code. even is more heavy. is there another solution?
Hi, I don't think it makes the code heavier, since the image code needs to be loaded before any JavaScript that depends on that image can run. It doesn't make much difference if that image code is in .js file as base64 data string or if it's read directly from .png file. It has no effect on performance.
If you want to use this technique with image files, if you point src attribute to that image it will work, if the image and code file sit on the same server. It will not work locally on an offline machine, since that will trigger CORS.
I tried to make a PNG file in MSPaint, but it keeps giving a "cross origin" error when I try to get data.
You get cross origin errors when you use an image file locally on your computer combined with GetImageData method. It's expected. This is an old video, I'm sure I explain and cover how to deal with that in the video itself.
What to do with error: Uncaught DOMException :The operation is insecure?
When console logging scannedImage.
Hi Marleen, did you manage to solve it? I assume you are doing something different than me in the video, most likely running it though server or something right?
I have à problem at 7:48 it say Uncaught DOMExeption: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': the canvas has been tainted by cross-origin data
I dont understand ... I am french that not help me 😂
I address that problem if you keep watching the video
Could you make a video about fluid simulation with Navier-Stokes equation???! Sir
Like this? www.outpan.com/app/44bdd9869c/interactive-fluid-simulation I would love to make this one yea
@@Frankslaboratory Yess!!! Wow that app is fantastic o.O
@@albedobond3827 Yes, the code seems complex, will try to break it down to see if it can be simplified. I'm not familiar with this technique yet
@@Frankslaboratory You should!! Thank your for your kind answering😍😍👍
Is there a way to get the pixel data in hex code or would you have to convert rgba to hex using js?
Hi Yeshaya, the pixel data array contains 0-255 values so you would have to convert it, the algorithm to convert rgba to hex is quite simple css-tricks.com/converting-color-spaces-in-javascript/
@@Frankslaboratory Thank you so much! I tried making an image filter tool with this tutorial. It would be awesome if you could check it out in your free time and give me feedback.
codepen.io/steelshot/pen/LYZJmGR
Wow you made it into interactive colour shift project with colour picker and everything. I wish I had this idea before making this tutorial, haha. Would have built something like that instead. I followed you on Codepen. This is actually a nice project for coding portfolio as well.
@@Frankslaboratory wow! Thank you😄
The line 14:
const scannedData=scannedImage.data;
and the line 18:
scannedData[i]=averageColorValue;
should produce an error - an attempt to modify a constant. But they work. What am I getting wrong?
Hi, this will not produce an error since you are no reassigning const variable to a completely different value, you are just modifying values within that same array. Assigning const variable doesn't freeze array completely. Const cannot be reassigned but can be modified.
@@Frankslaboratory I see. Thank you
@@Frankslaboratory thanks I had the same doubt
Frank! I love your videos, Thank u ! I don't know why I get this error: Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
at Image.
My JS CODE:
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 425;
canvas.height = 600;
const image1 = new Image();
image1.src = './Dua.png';
image1.addEventListener('load', function(){
ctx.drawImage(image1, 0, 0, canvas.width, canvas.height);
const scannedImage = ctx.getImageData(0, 0, canvas.width, canvas.height);
console.log(scannedImage)
})
Hi. I address this issue if you watch 5 more minutes into the video. Let me know how it goes:)
MAN FUCK HAHAHAHAHA When I got this error, I paused the video and I start a big research to fix it, when I fix the problem, I start the video again, and in the next seconds you explain the error... hahahaha, I passed 3 hours searching how fix this and you explain to me it in 3 minutes, your videos are amazing
Ty
I'm here to help
Where is the part 2 plZ anyone can give me link?
you have adjusted 2 loops into 1 loop which is much better now.
Hi Alex, 1 loop is always better yes, I try to do it when possible, unless doing that requires too much explanation and the tutorial is aimed for beginners. Sometimes I choose to be less optimal if it means the video is easier to understand
Can you make tetris game using circle ball
If color of three of 3 ball is same in horizontal or vertical the ball will disappear
Anyone ?????
Hai Ultimate Challange Am a Web Game Developer
@@EDMVibes24 Just try this and let me know
... my brain!!!!!!!!! it hurts ahhhh!!!!!
超強
Thank you, although I can't really read traditional Chinese :)
@@Frankslaboratory it means "that's so impressive!" :D
At last you like aliens unique tutorial
HI Sadam, happy you like the tutorial, I am trying to bring more creative coding on UA-cam
the thumbnail-
What's wrong with it 😅
Your videos are wonderful. I figured out your particle trick, and how to set up a GitHub repo if you want to take a look:
github.com/Bad-Wolf-42/particle-painting
I don't know if it's okay to post links to my own stuff in comments. If not, then I apologize. I had a lot of fun making this. Thank you.
Hi Wolf. Thank you for your feedback. Impressive. It seems you came up with a different solution to the same problem. You are good, this is not easy to do. Thank you for sharing. You can post anything in comments, sometimes UA-cam puts it in spam folder because it contains a link but I check it once in a while and approve the comments. I think the solution you came up with is actually better than mine :D
🥹😍
lol
😀