Jump to content

Color of individual pixels with Phaser


DK3250
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...