Package fractal

Class Fractal

java.lang.Object
fractal.Fractal

public class Fractal extends Object
this is a class to create fractal and render it but you can use it to draw other thing actualy.
Version:
1.0
Author:
Physic Dev
  • Constructor Details

    • Fractal

      public Fractal(int dim, BiFunction<double[],Integer,Integer> check)
      Parameters:
      dim - the dimension of the fractal
      check - a function that compute the maximum depth at which the given coordinate is in the fractal.
  • Method Details

    • getDimension

      public int getDimension()
      dimension getter
      Returns:
      the dimension
    • getMaxDepth

      public int getMaxDepth()
      give the maximum depth of computing
      Returns:
      the maximum depth
    • getSampling

      public int getSampling()
      get the sampling value
      Returns:
      the sampling value
    • setMaxDepth

      public void setMaxDepth(int maxDpt)
      change the maximum depth of computing
      Parameters:
      maxDpt - the maximum depth
    • setSampling

      public void setSampling(int samp)
      set the sampling value
      Parameters:
      samp - the sampling value
    • checkPix

      public int checkPix(double... coord)
      compute the maximum depth in which the coordinate coord is in the fractal not that if the output is equal to maxDepth the coordinate may be deeper
      Parameters:
      coord - the coordinate
      Returns:
      the maximum depth at which the coordinate is in the fractal/
    • drawFractal

      public BufferedImage drawFractal(int width, int height, Color c, Color back, int depth)
      Compute an image of the fractal to do so it will check take one coordinate for every pixel (the coordinate is located at the top left corner of the pixel) and will check if the pixel is deep enough in the fractal to be drawn. this method will not be precise for rendering little detail but is faster than the Sampling method. the fractal will be drawn from (0,0) to (1,1)
      Parameters:
      width - the width of the image
      height - the height of the image
      c - the color of the fractal
      back - the color of the background
      depth - any pixel lower than this depth will be drawn.
      Returns:
      a BufferedImage of the fractal
    • drawFractal

      public BufferedImage drawFractal(int width, int height, Color c, Color back, int depth, double[] origin, double[] Xvec, double[] Yvec)
      Compute an image of the fractal to do so it will check take one coordinate for every pixel (the coordinate is located at the top left corner of the pixel) and will check if the pixel is deep enough in the fractal to be drawn. this method will not be precise for rendering little detail but is faster than the Sampling method. in addition you can specify the part of the space you want to draw. note that you can draw 2D section of a fractal with dimension higher than 2.
      Parameters:
      width - the width of the image
      height - the height of the image
      c - the color of the fractal
      back - the color of the background
      depth - any pixel lower than this depth will be drawn.
      origin - the origin from which the picture is drawn, the origin is located at the top left of the image
      Xvec - the amount that would be draw along the X axis (horizontal left to right). the top right coordinate will be equal to the origin + Xvec
      Yvec - the amount that would be draw along the Y axis (vertical top to bottom). the bottom left coordinate will be equal to the origin + Yvec
      Returns:
      a BufferedImage of the fractal
    • drawFractalSampling

      public BufferedImage drawFractalSampling(int width, int height, Color c, Color back, int depth)
      this method is similar to drawFractal(int, int, Color, Color, int) except instead of using one coordinate at the top left corner of each pixel to determine if the pixel should be drawn, it will check multiple random coordinate within the pixel and measure how much the pixel should be lit. the amount of test by pixel is determine by the attribute sampling.
      Parameters:
      width - the image width
      height - the image height
      c - the color that a pixel would be if every tested coordinates are in the fractal
      back - the color that a pixel would be if none of the tested coordinate are in the fractal.
      depth - limit used to determine if a pixel is or is not in the fractal
      Returns:
      a Buffered Image of the fractal
    • drawFractalSampling

      public BufferedImage drawFractalSampling(int width, int height, Color c, Color back, int depth, double[] origin, double[] Xvec, double[] Yvec)
      this method is similar to drawFractal(int, int, Color, Color, int, double[], double[], double[]) except instead of using one coordinate at the top left corner of each pixel to determine if the pixel should be drawn, it will check multiple random coordinate within the pixel and measure how much the pixel should be lit. the amount of test by pixel is determine by the attribute sampling.
      Parameters:
      width - the image width
      height - the image height
      c - the color that a pixel would be if every tested coordinates are in the fractal
      back - the color that a pixel would be if none of the tested coordinate are in the fractal.
      depth - limit used to determine if a pixel is or is not in the fractal
      origin - the origin from which the picture is drawn, the origin is located at the top left of the image
      Xvec - the amount that would be draw along the X axis (horizontal left to right). the top right coordinate will be equal to the origin + Xvec
      Yvec - the amount that would be draw along the Y axis (vertical top to bottom). the bottom left coordinate will be equal to the origin + Yvec
      Returns:
      a BufferedImage of the fractal
    • drawFractalSampling

      public BufferedImage drawFractalSampling(int width, int height, Color c, Color back, double light, int depth, double[] origin, double[] Xvec, double[] Yvec)
      this method is similar to drawFractalSampling(int, int, Color, Color, int, double[], double[], double[]) but with an additional parameter used to increase the brightness of the fractal. use this method if you want to create multiple frame of the fractal with a zoom level that change. This way you can correct the increase of brighness cause by the zoom.
      Parameters:
      width - the image width
      height - the image height
      c - the color that a pixel would be if every tested coordinates are in the fractal
      back - the color that a pixel would be if none of the tested coordinate are in the fractal.
      light - this value indicate the multiplier of light.
      depth - limit used to determine if a pixel is or is not in the fractal
      origin - the origin from which the picture is drawn, the origin is located at the top left of the image
      Xvec - the amount that would be draw along the X axis (horizontal left to right). the top right coordinate will be equal to the origin + Xvec
      Yvec - the amount that would be draw along the Y axis (vertical top to bottom). the bottom left coordinate will be equal to the origin + Yvec
      Returns:
      a BufferedImage of the fractal