Challenge: Faking 3D extrusion of a polygon

Björnke von Gierke bvg at mac.com
Sat May 28 19:37:34 EDT 2011


you can create one polygon that shows all the lines, by inserting empty lines at the right place. for example:

40,75
331,189
131,149
19,349
40,75

40,75
65,75
331,189
356,189
156,149
19,349
44,349
40,75

40,75
65,75
356,189
331,189
156,149
44,349
19,349
40,75

however this can at sometimes produce problems with the fill if they're opaque. so watch out for that.

On 28 May 2011, at 21:36, Michael Kristensen wrote:

> Challenge: Faking 3D extrusion of a polygon
> 
> Hi 
> This is a challenge of making a fake 3D extrusion of a random shaped polygon. 
> 
> In very simple cases you can just copy the polygon, put it behind with a little offset and shade it a little darker than the front polygon.
> 
> But if the offset gets a little larger then one can see that the two polygons doesn't form one object.
> 
> This is a far as I have come:
> 
> Make a random polygon and name it P1
> Make the color fx light green and set the lineSize to 0
> 
> Make two copies of P1 and send them behind P1
> Name the two copies P2 and P3
> Color them both the same darker shade of the green color.
> 
> Now make a Button with this script:
> 
> on mouseUp
>   lock screen
>   put points of grc P1 into points1
> 
>   set points of grc P2 to points1
>   move grc P2 relative 25,0
>   put points of grc P2 into points2
> 
>   put line 1 of points1 & return after newPoints
>   put line 1 of points2 & return after newPoints
> 
>   repeat with i = 2 to number of lines of points1-1
>      if not within(grc P2,line i of points1) then put line i of points1 & return after newPoints
>      if not within(grc P1,line i of points2) then put line i of points2 & return after newPoints
> 
>      if within(grc P1,line i of points2) and within(grc P2,line i of points1) then put line i of points2 & return after newPoints
>   end repeat
> 
>   put line 1 of points1 & return after newPoints2
>   put line 1 of points2 & return after newPoints2
> 
>   repeat with i = 2 to number of lines of points1-1
>      if not within(grc P1,line i of points2) then put line i of points2 & return after newPoints2
>      if not within(grc P2,line i of points1) then put line i of points1 & return after newPoints2
> 
>      if within(grc P1,line i of points2) and within(grc P2,line i of points1) then put line i of points2 & return after newPoints2
>   end repeat
> 
>   set points of grc P2 to newpoints
>   set points of grc P3 to newpoints2
> end mouseUp
> 
> Clicking the Button should give you an extruded looking object.
> 
> BUT…..
> Both P2 and P3 are faulty.
> Only together on top of each other they look right.
> 
> Can you make it better?
> Can you make the extruded look with only one extra object (apart from the original)?
> 
> Mic
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list