Pages

Showing posts with label Classes. Show all posts
Showing posts with label Classes. Show all posts

Thursday, 7 July 2011

Colour Wheel - HSV Colour Space

I've just been playing around with colour wheels and colour representation in flash. I had a think about whether it was possible to represent every single colour in the RGB spectrum on a single 2D image. Closer inspection reveals that it isn't possible because RGB is made up of three components - red, green and blue - and therefore needs three dimensions. This is why if you look up different colour representations on Wikipedia you might see them represented by cones, or cubes. I decided to work in the HSV colour space which is  formed of Hue (rotation), Saturation (The amount of colour compared to black/white) and Value (Essentially the brightness). The resulting colour wheel can be seen below:


Just click on the image to launch the app. By rolling over the wheel the colour in the box will show the selected colour. Use the up/down arrow keys to alter the "V" value of the wheel. This should allow you to view a complete (discrete) representation of every colour in the RGB spectrum. 

If you're interested in source code just click here to download the FlashBuilder project and AS files. Enjoy!

Monday, 9 August 2010

FlashMath Demo 1

Just a really simple demo, which uses the FlashMath library. Click to launch it. The demo uses a string evaluation function to generate the curve. This function is also used to calculate the integral of the curve using Simpsons rule between min and max, and by clicking on the graph, finite differencing is used to calculate the gradient of the curve. Data set and graph classes are used to store / draw the data. The parser was created by http://www.undefined.ch/ and is a really useful tool! The demo might be a bit buggy at the moment, but its a good sign of things to come!

Tuesday, 3 August 2010

Experimentalized Maths Library

It struck me today, that although I reuse a lot of code and classes, the one thing I tend to rewrite each and every time I start a new program is the mathematics. I dread to think how many hours this has wasted me over the years, so I finally decided to write a toolkit encompassing almost anything maths based. So far I've written a couple of constant utilities, one for mathematical constants, and one for scientific constants and a complex number class. Currently on the list are:
  • Matrices
  • Data sampling and statistics
  • Quadrature (integration) - Rectangle, Trapezium & Simpson's rule 
  • Numerical differentiation - finite differencing ✔,  runge-kutta (and other ODE solvers)
  • Graphs
  • Vectors ( 2, 3  and N dimensional)
  • Geometry class & trigonometry solvers
  • Probability
  • Random numbers (Mersenne Twister, other PRNGs)
  • Time and date
  • Complex numbers 
  • Bitwise operators 
  • Mathematical constants 
  • Scientific constants 
It would be great if you could let me know what kinds of maths utilities you would find useful, and even better if you have some of your own code and would like to collaborate with me on this.

Update: Your suggestions:

  • Bezier curves (Cubic & Quadratic), Bezier surfaces?

Tuesday, 23 February 2010

Image Transform Tool

I've just been playing around with this little class made by Ruben Swieringa.

It allows any image to be transformed by providing any four corner points. In the demo I used an animation of mine (Strange Attractors).

Click on the image to begin then try dragging around the corners. I'll see if I can come up with any other experiments using this neat class. Any bitmap data can be used, so videos, images and animations can all be dragged around in 3 dimensions....