Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Decides if a point at a specific location is filled or not.
- list carpet;
- //param x is the x coordinate of the point being checked
- //param y is the y coordinate of the point being checked
- //param width is the width of the Sierpinski Carpet being checked
- //param height is the height of the Sierpinski Carpet being checked
- //return 1 if it is to be filled or 0 if it is not
- isSierpinskiCarpetPixelFilled(integer x,integer y,integer width,integer height)
- {
- // base case 1 of 2
- if (x<1)
- {
- carpet += "0";
- }
- {
- //If the grid was split in 9 parts, what part(x2,y2) would x,y fit into?
- integer xTwo; // an integer from 0..2 inclusive
- xTwo = x*6/(width+3);
- integer yTwo; // an integer from 0..2 inclusive
- yTwo = y*6/(height+3);
- // base case 2 of 2
- if (xTwo==1 && yTwo==1) // if in the centre squaure, it should be filled.
- carpet += "1";
- // general case
- //offset x and y so it becomes bounded by 0..width/3 and 0..height/3
- //and prepares for recursive call
- x-=xTwo*width/3;
- y-=yTwo*height/3;
- }
- }
- // www.lsleditor.org by Alphons van der Heijden (SL: Alphons Jano)
- default
- {
- state_entry()
- {
- llSay(0, "Hello, Avatar!");
- }
- touch_start(integer total_number)
- {
- integer i;//loop 1
- integer j;//loop 2
- integer x;
- integer y;
- integer width = 3;
- integer height = 3;
- for (i=0;i<width;i++)
- {
- isSierpinskiCarpetPixelFilled(x,y,i/3,j/3);
- x++;
- if(i == width)
- {}//gonna do a double loop here instead of it being recursive
- }
- llSay(0, llList2String(carpet,0));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement