Browse Search Popular Register Upload Rules User list Login:
Search:
Displaying Poygon, Help!

Image:
screenshot of the scene

Author: lololoer

Group: Default

Filesize: 49.72 kB

Date added: 2014-02-10

Rating: 5

Downloads: 352

Views: 315

Comments: 5

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

I have tried a lot of times different ways to make display a polygon with pixels (boxes)
and the best of all my try is this, it doesn't seem to display the polygon as it should.
Could anyone help me?
Last edited at 2014/02/10 15:47:12 by lololoer
Please log in to rate this scene
edit
Similar scenes
Title: MRWP but I can’t text box Part 4
Rating: 5
Filesize: 79.9 kB
Downloads: 385
Comments: 0
Ratings: 1
Date added: 2019/06/19 02:19:18
Made with: Algodoo before v1.8.5
Rating: rated 5
download
Title: Spaceway Part 3
Rating: 5
Filesize: 30.2 kB
Downloads: 502
Comments: 0
Ratings: 1
Date added: 2018/12/08 18:00:37
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Terrain Mapping Device
Rating: 8.5467
Filesize: 13.6 kB
Downloads: 3370
Comments: 14
Ratings: 19
Date added: 2009/09/01 01:24:12
Made with: Algodoo before v1.8.5
Rating: rated 8.5
download
Title: X-Y Scanner
Rating: 7.6667
Filesize: 21.6 kB
Downloads: 90
Comments: 0
Ratings: 3
Date added: 2008/10/11 10:39:53
Made with: Phun
no image found for this scene
Rating: rated 7.7
download
Title: RUBIK'S CUBE
Rating: 7.3077
Filesize: 133.65 kB
Downloads: 2920
Comments: 11
Ratings: 7
Date added: 2013/05/04 07:46:32
Made with: Algodoo v2.1.0
Rating: rated 7.3
download
Title: pssd (phun solid state disk)
Rating: 5.625
Filesize: 22.95 kB
Downloads: 595
Comments: 2
Ratings: 2
Date added: 2009/04/29 08:06:51
Made with: Phun
Rating: rated 5.6
download
Responses to this scene
show list
Title: Pixelate Polygon II
Rating: 5
Filesize: 28.76 kB
Downloads: 418
Comments: 8
Ratings: 1
Date added: 2014/02/13 01:30:15
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Pixelate Polygon I
Rating: 5.625
Filesize: 14 kB
Downloads: 564
Comments: 1
Ratings: 2
Date added: 2014/02/13 01:29:18
Made with: Algodoo v2.1.0
Rating: rated 5.6
download
lololoer - I believe it is working, but the pixels are so large that the image does not look like the original polygon. I tried making the pixels smaller and increasing their number by 4 times. The resulting image looks close to the original image but the lag is so bad that it takes 15 seconds per frame to update.

Also, the pixel located at [0.125,0.125] stays white. It does not have a gray scale, but it's not a fault of the pixel. There may be a bug in the calculation, but I'm not certain.

So, I believe it is working, but the resolution is so bad that it looks like it doesn't work!
The bottom side of the "group displayer" (pixels(boxes)), does not change when the polygon is over it too!

Thanks! :tup:
I assume you wish to pixelate a polygon. You define a function within a defined function within a defined function. This is not good, for reasons that Xray has already mentioned. Each function needs to defined only once, not 105 times a second. I got an "out of memory" while running this scene. If you can explain what the "AnyOf" and "scene.my.displaySurface" functions are supposed to do, then maybe we can help.

P.S.: Here is how they can be run as three separate functions that need to be defined once in the console;

scene.my.xFor = (n1, n2, code)=>{
n2 > n1 ? {
m := (n1 + n2) / 2;
scene.my.xFor(n1, m, code);
scene.my.xFor(m + 1, n2, code)
} : {code(n1)}
};

scene.my.AnyOf = (ra, d, x, poly, disp)=>{
min := disp.pos + [50, 50];
n = string.length(ra) - 1;
Scene.my.xFor(0, n, (i)=>{
math.vec.dist(ra(i), d) < x ? {
min = poly.pos + (ra(i) / 2)
} : {}
});
min
};

scene.my.displaySurface = (poly, disp)=>{
sf = ((readable(poly)).surfaces)(0);
s = scene.my.AnyOf(sf, disp.pos, 0.25, poly, disp);
dist = math.vec.dist(s, disp.pos);
[0.0, 0.0, dist * 2.0, 1.0]
};

P.P.S.:

For each box
myBox = clone box
myPoly = clone polygon
newPoly = Intersect myPoly with myBox
V = 1 - newPoly.area/box.area
box.colorHSVA = [0,0,V,1]
Next
Last edited at 2014/02/11 10:18:43 by s_noonan
s_noonan, the function isn't actually uploading per each frame, see it.
AnyOf is supposed to read the nearest surface to each box.
displaySurface traduces the distance to the nearest surface to colorHSVA's value element.
Last edited at 2014/02/11 17:15:11 by lololoer
Although "scene.my.displaySurface" is only loaded once, it creates (2) functions (scene.my.xFor and AnyOf) each time it's called. Wit 64 boxes calling "scene.my.displaySurface" 105 times a second, it seems that the scene can create up to 13440 new functions a second (64 * 2 * 105). If you use the (3) independent functions shown in my previous response, then no new fuctions are created when the scene is running.

Regarding "AnyOf is supposed to read the nearest surface to each box.", it doesn't. The following should do what I think you intended:

scene.my.xFor = (n1, n2, code)=>{
n2 > n1 ? {
m := (n1 + n2) / 2;
scene.my.xFor(n1, m, code);
scene.my.xFor(m + 1, n2, code)
} : {code(n1)}
};

scene.my.displaySurface = (poly, disp)=>{
ra = scene.my.sf;
n = string.length(ra) - 1;
v = 100;
Scene.my.xFor(0, n, (i)=>{
d = math.vec.dist(poly.pos + ra(i), disp.pos);
d < v ? {v = d} : {}
});
disp.colorHSVA = [0.0, 0.0, 2 * v, 1.0]
};

in poly onSpawn:
scene.my.poly = entity;
scene.my.sf = (readable(owner)).surfaces(0);

in poly postStep:
pos = app.mousepos

in box postStep:
scene.my.displaySurface(scene.my.poly,en­tity)

At any rate, this does not pixelate the polygon but should pixelate the border of the polygon. I tried to design the code for minimum lag, but it didn't seem to help much.
Last edited at 2014/02/12 01:29:12 by s_noonan