DK3250 Posted February 22, 2015 Share Posted February 22, 2015 First: I am brand new to this forum, and still don't have an overview of the site design. So, please accept my appologize if the question have been asked before (or is completely out of scope)Second: I am relatively new to both javascript and Phaser - but I consider myself an experienced Python/Pygame programmer. I want to make a Mandelbrot fractal - the matematics is working, but I need to color the individual pixels in my canvas.From the example "Playing with points", I have copied the following two lines:game.context.fillStyle = 'rgb(255,255,0)';game.context.fillRect(p1.x, p1.y, 4, 4);Naturally I have changed the rgb-string to a table look-up, and the Rect size to 1 by 1. The next four lines is from my code: var p = new Phaser.Point(i, j);console.log(color)game.context.fillStyle = color; game.context.fillRect(p.x, p.y, 1, 1); The error I get is:"Cannot set property 'fillStyle' of null", but a preceeding console.log statement show a value, - not null. As I am new here, I cannot attach my file.So I will rephrase my question: What is the best way to color individual pixels using Phaser ?I can also import all code to the page, if it is appropiate(?). Help much appeciated. Quote Link to comment Share on other sites More sharing options...
rich Posted February 22, 2015 Share Posted February 22, 2015 If your game is running in WebGL then you can't set fillStyle, etc on the context as it doesn't exist. You can either use a BitmapData (which would be perfect for this imho) or force the game to use canvas only. DK3250 1 Quote Link to comment Share on other sites More sharing options...
DK3250 Posted February 22, 2015 Author Share Posted February 22, 2015 Thanks, I Googled up 'BitMpData' and can now produce an excellent Mandelbrot picture.Not using Phaser, however. And learning Phaser is one of my targets.I'll find another project; I'll probably get stuck again , and I'll revert to this site for more assistance.Thanks for now. Quote Link to comment Share on other sites More sharing options...
rich Posted February 22, 2015 Share Posted February 22, 2015 http://docs.phaser.io/Phaser.BitmapData.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.