Advertisement
ZornTaov

Untitled

Sep 21st, 2010
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1.  
  2.  
  3.  
  4. // www.lsleditor.org by Alphons van der Heijden (SL: Alphons Jano)
  5. default
  6. {
  7.  
  8. //Decides if a point at a specific location is filled or not.
  9. //param x is the x coordinate of the point being checked
  10. //param y is the y coordinate of the point being checked
  11. //param width is the width of the Sierpinski Carpet being checked
  12. //param height is the height of the Sierpinski Carpet being checked
  13. //return 1 if it is to be filled or 0 if it is not
  14. integer isSierpinskiCarpetPixelFilled(integer x, integer y, integer width, integer height)
  15. {
  16. // base case 1 of 2
  17. if (x<1){
  18. return 0;
  19. }
  20.  
  21. //If the grid was split in 9 parts, what part(x2,y2) would x,y fit into?
  22. integer xTwo = x*6/width; // an integer from 0..2 inclusive
  23. integer yTwo = y*6/height; // an integer from 0..2 inclusive
  24.  
  25. // base case 2 of 2
  26. if (xTwo == 1 && yTwo == 1){ // if in the centre squaure, it should be filled.
  27. return 1;
  28. }
  29.  
  30. // general case
  31.  
  32. //offset x and y so it becomes bounded by 0..width/3 and 0..height/3
  33. return isSierpinskiCarpetPixelFilled(x-(xTwo*width/3), y-(yTwo*height/3), width/3, height/3);
  34. }
  35.  
  36.  
  37.  
  38. state_entry()
  39. {
  40. integer width = 30;
  41. integer height = 30;
  42. for (integer j=0; j<height; j++){
  43. string row = "";
  44. for (integer i=0;i<width;i++)
  45. {
  46. row += (string)isSierpinskiCarpetPixelFilled(i,j,width,height);
  47. }
  48. llSay(0, row);
  49. }
  50. }
  51. touch_start(integer total_number)
  52. {
  53.  
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement