Author Topic: Shape Script - Cube with sides that won't stretch  (Read 11903 times)

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Shape Script - Cube with sides that won't stretch
« Reply #15 on: March 31, 2017, 11:08:34 am »
Here's my take on it.
Code: [Select]
shape main
{
layouttype= "border";

addsubshape ("top", "N");
addsubshape ("side", "E");
addsubshape ("front", "CENTER");


shape top
{
preferredheight=25;
startpath();
moveto(0,100);
setfixedregion(0,0,25,0);
lineto(25,0);
lineto(100,0);
setfixedregion(75,0,100,0);
lineto(75,100);
lineto(0,100);
endpath();
fillandstrokepath();
}

shape side
{
preferredwidth=25;
startpath();
moveto(0,100);
lineto(0,0);
setfixedregion(0,-25,0,0);
lineto(100,-25);
setfixedregion(0,75,0,100);
lineto(100,75);
lineto(0,100);
endpath();
fillandstrokepath();
}

shape front
{
h_align= "center";
rectangle (0, 0, 100, 100);
printwrapped ("#qualifiedname#");
}
}
The size of the front face of the rectangular prism is equal to the object size minus 25 for each dimension.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Shape Script - Cube with sides that won't stretch
« Reply #16 on: March 31, 2017, 04:36:28 pm »
Very tricky :-) If you take a 10/90 relation, it almost looks like the native node:

Code: [Select]
shape main
{
layouttype= "border";

addsubshape ("top", "N");
addsubshape ("side", "E");
addsubshape ("front", "CENTER");


shape top
{
preferredheight=10;
startpath();
moveto(0,100);
setfixedregion(0,0,10,0);
lineto(10,0);
lineto(100,0);
setfixedregion(90,0,100,0);
lineto(90,100);
lineto(0,100);
endpath();
fillandstrokepath();
}

shape side
{
preferredwidth=10;
startpath();
moveto(0,100);
lineto(0,0);
setfixedregion(0,-10,0,0);
lineto(100,-10);
setfixedregion(0,90,0,100);
lineto(100,90);
lineto(0,100);
endpath();
fillandstrokepath();
}

shape front
{
h_align= "center";
rectangle (0, 0, 100, 100);
printwrapped ("#qualifiedname#");
}
}

q.

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
Re: Shape Script - Cube with sides that won't stretch
« Reply #17 on: July 08, 2017, 10:27:39 am »
Thanks to all of you and especially Simon for the solution.