none
mahreen miangul 7th November 2016 RRS feed

  • Question

  • hello everybody i think i am learning for example are two programs ID PZH291 and ID MWC265 one is drawing shapes and one is animating shapes  the shapes have been taken from small basic tutorials i faced one problem which i could not solve if some will help me angle in func while drawing shapes with thanks

                                   mahreen miangul - mussa-maina

    Monday, November 7, 2016 1:56 PM

Answers

  • in MWC265  , "angle" sample is written.

    shape[78]  = "func=rect;x=661;y=55;width=6;height=14;angle=330;bc=#000000;pc=#000000;pw=2;"
    shape[79]  = "func=rect;x=642;y=25;width=5;height=18;angle=338;bc=#000000;pc=#000000;pw=2;"
    shape[80]  = "func=rect;x=608;y=6;width=3;height=19;angle=241;bc=#000000;pc=#000000;pw=2;"
    shape[81]  = "func=rect;x=628;y=23;width=6;height=25;angle=294;bc=#000000;pc=#000000;pw=2;"
    shape[82]  = "func=rect;x=640;y=7;width=5;height=20;angle=358;bc=#000000;pc=#000000;pw=2;"
    shape[83]  = "func=rect;x=633;y=0;width=5;height=18;angle=241;bc=#000000;pc=#000000;pw=2;"
    shape[84]  = "func=ell;x=627;y=39;width=46;height=21;bc=#000000;pc=#000000;pw=2;"
    shape[85]  = "func=ell;x=636;y=76;width=54;height=7;angle=6;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[86]  = "func=ell;x=619;y=86;width=25;height=4;angle=289;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[87] = "func=ell;x=613;y=97;width=19;height=3;angle=347;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[88] = "func=ell;x=769;y=104;width=26;height=6;angle=7;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[89] = "func=ell;x=707;y=75;width=46;height=6;angle=165;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[90] = "func=ell;x=738;y=84;width=43;height=9;angle=238;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[91] = "func=rect;x=616;y=10;width=5;height=20;angle=345;bc=#000000;pc=#000000;pw=2;"
    shape[92] = "func=ell;x=637;y=43;width=11;height=11;bc=#E3D4D1;pc=#000000;pw=2;"
    shape[93] = "func=ell;x=684;y=75;width=39;height=8;angle=152;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[94] = "func=ell;x=705;y=83;width=38;height=9;angle=257;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[95] = "func=ell;x=726;y=103;width=20;height=8;angle=24;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[100] = "func=ell;x=661;y=68;width=46;height=21;angle=12;bc=#000000;pc=#000000;pw=2;"
    shape[101] = "func=ell;x=703;y=73;width=46;height=21;bc=#000000;pc=#000000;pw=2;"
    shape[102] = "func=ell;x=649;y=63;width=73;height=34;angle=352;bc=#000000;pc=#000000;pw=2;"
    shape[103] = "func=ell;x=638;y=74;width=54;height=7;angle=18;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[104] = "func=ell;x=612;y=87;width=48;height=7;angle=282;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[105] = "func=ell;x=600;y=112;width=30;height=5;angle=347;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[106] = "func=ell;x=709;y=76;width=39;height=8;angle=152;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[107] = "func=ell;x=691;y=96;width=56;height=8;angle=268;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[108] = "func=ell;x=719;y=128;width=30;height=5;angle=14;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[109] = "func=ell;x=683;y=75;width=39;height=8;angle=152;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[110] = "func=ell;x=723;y=99;width=79;height=9;angle=238;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[111] = "func=ell;x=781;y=134;width=30;height=5;angle=14;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[112] = "func=ell;x=615;y=52;width=14;height=5;angle=348;bc=#000000;pc=#000000;pw=2;"
    s=1
    GraphicsWindow.Width=1000
    for i=78 To 112
      GraphicsWindow.BrushColor = shape[i]["bc"]  '  brushcolor
      GraphicsWindow.penColor = shape[i]["pw"]    '  pencolor
      If shape[i]["func"]="ell" Then 
        shp[i] = Shapes.AddEllipse(shape[i]["width"]*s, shape[i]["height"]*s)  '  ellipse
      ElseIf shape[i]["func"]="rect" Then 
        shp[i] = Shapes.AddRectangle(shape[i]["width"]*s, shape[i]["height"]*s) '  rectangle
      EndIf
      Shapes.Rotate(shp[i], Shape[i]["angle"])     ' <--------  rotating angle
      Shapes.Animate(shp[i], shape[i]["x"]*s, shape[i]["y"]*s, 500)
    EndFor

    Wednesday, November 9, 2016 2:34 PM
    Answerer
  • I tried the program MWC265, we can see two states of alternating images creating a pseudo-animation, then everything works well with this program.

     
    also, the section of program submitted by NaochanOn is excellent, and works very well, we see ant moving and take shape.

    STAGE 1:

    STAGE 2

    Wednesday, November 9, 2016 4:20 PM
    Answerer
  • if you want to rotate ellipse by using Graphics.Drawline , use this method.   VDV774

    '  Rotating ellipse  using GraphicsWindow.DrawLine command   VDV774
    '  (x-x0)^2/a^2+(y-y0)^2/b^2=1   ellipse
    PW=4
    GraphicsWindow.PenColor="Red"
    GraphicsWindow.PenWidth=PW
    x0=200
    y0=150
    a=100   '  width
    b=60    '  height
    For x= -a To a
      y1=b*math.SquareRoot(1-X*X/a/a)
      y2=-y1
      GraphicsWindow.DrawLine(x0+x,y1+y0,x0+x,y2+y0)
    EndFor

    X0=450
    GraphicsWindow.BrushColor="white"
    While "True"
      angle=angle+5
      rad= Math.GetRadians(angle)
      GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()
      rotate_ellipse()
      Program.Delay(500)
      GraphicsWindow.FillRectangle(x0-a-PW,y0-a-PW,2*(a+PW),2*(a+PW))
    endwhile

    Sub rotate_ellipse
      For x= -a To a
        y1=b*math.SquareRoot(1-X*X/a/a)
        y2=-y1
        NewY1=x*math.Sin(rad)+y1*math.Cos(rad)
        NewY2=x*math.Sin(rad)+y2*math.Cos(rad)
        NewX1= x*math.Cos(rad)-y1*math.sin(rad)
        NewX2=  x*math.Cos(rad)-y2*math.sin(rad)
        GraphicsWindow.DrawLine(x0+NewX1,y0+NewY1,x0+NewX2,y0+NewY2)
      EndFor
    EndSub

    Friday, November 11, 2016 6:40 AM
    Answerer
  • see RCQ916-0

    many error exists.  see  <----  marked lines.

    1) shape array contains 6 data from 1 to 6 . so, for endfor loop should be For 1 to 6 .

    2) shape array data should be separated by using ";" .

    3)  line data should contain X1,Y1,X2,Y2 data.   

    4) line shape is added as below 

    ElseIf shape[i]["func"]="line" Then  '  <---------line
        shp[i] = Shapes.Addline(shape[i]["x1"]*s, shape[i]["y1"]*s,shape[i]["x2"]*s, shape[i]["y2"]*s) '  <---------line

    Friday, November 11, 2016 10:31 AM
    Answerer

All replies

  • hello everybody i think i am learning for example are two programs ID PZH291 and ID MWC265 one is drawing shapes and one is animating shapes  the shapes have been taken from small basic tutorials i faced one problem which i could not solve if some will help me angle in func while drawing shapes with thanks

                                   mahreen miangul - mussa-maina


    I think nobody is intresting in replying please be a sport
    Wednesday, November 9, 2016 6:41 AM
  • @mussamaina,

    I think it is better to explain what your problem with the angle is. Your programs are long and give no errors, so what is it that you want solverd?


    Jan [ WhTurner ] The Netherlands

    Wednesday, November 9, 2016 10:52 AM
    Answerer
  • @mussamaina,

    I think it is better to explain what your problem with the angle is. Your programs are long and give no errors, so what is it that you want solverd?


    Jan [ WhTurner ] The Netherlands

      shape[1] = "func=ell;x=81;y=190;width=36;height=67;angle=332;bc=#834216;pw=0;"
      shape[2] = "func=ell;x=200;y=188;width=35;height=67;angle=20;bc=#834216;pw=0;"

    can draw x,y width, height, brush color, can not draw the "angle" of the shape thanking you again for taking intrest. with thanks again mahreen miangul mussa-maina ps please give asimple example.



    Wednesday, November 9, 2016 11:31 AM
  • in MWC265  , "angle" sample is written.

    shape[78]  = "func=rect;x=661;y=55;width=6;height=14;angle=330;bc=#000000;pc=#000000;pw=2;"
    shape[79]  = "func=rect;x=642;y=25;width=5;height=18;angle=338;bc=#000000;pc=#000000;pw=2;"
    shape[80]  = "func=rect;x=608;y=6;width=3;height=19;angle=241;bc=#000000;pc=#000000;pw=2;"
    shape[81]  = "func=rect;x=628;y=23;width=6;height=25;angle=294;bc=#000000;pc=#000000;pw=2;"
    shape[82]  = "func=rect;x=640;y=7;width=5;height=20;angle=358;bc=#000000;pc=#000000;pw=2;"
    shape[83]  = "func=rect;x=633;y=0;width=5;height=18;angle=241;bc=#000000;pc=#000000;pw=2;"
    shape[84]  = "func=ell;x=627;y=39;width=46;height=21;bc=#000000;pc=#000000;pw=2;"
    shape[85]  = "func=ell;x=636;y=76;width=54;height=7;angle=6;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[86]  = "func=ell;x=619;y=86;width=25;height=4;angle=289;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[87] = "func=ell;x=613;y=97;width=19;height=3;angle=347;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[88] = "func=ell;x=769;y=104;width=26;height=6;angle=7;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[89] = "func=ell;x=707;y=75;width=46;height=6;angle=165;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[90] = "func=ell;x=738;y=84;width=43;height=9;angle=238;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[91] = "func=rect;x=616;y=10;width=5;height=20;angle=345;bc=#000000;pc=#000000;pw=2;"
    shape[92] = "func=ell;x=637;y=43;width=11;height=11;bc=#E3D4D1;pc=#000000;pw=2;"
    shape[93] = "func=ell;x=684;y=75;width=39;height=8;angle=152;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[94] = "func=ell;x=705;y=83;width=38;height=9;angle=257;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[95] = "func=ell;x=726;y=103;width=20;height=8;angle=24;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[100] = "func=ell;x=661;y=68;width=46;height=21;angle=12;bc=#000000;pc=#000000;pw=2;"
    shape[101] = "func=ell;x=703;y=73;width=46;height=21;bc=#000000;pc=#000000;pw=2;"
    shape[102] = "func=ell;x=649;y=63;width=73;height=34;angle=352;bc=#000000;pc=#000000;pw=2;"
    shape[103] = "func=ell;x=638;y=74;width=54;height=7;angle=18;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[104] = "func=ell;x=612;y=87;width=48;height=7;angle=282;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[105] = "func=ell;x=600;y=112;width=30;height=5;angle=347;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[106] = "func=ell;x=709;y=76;width=39;height=8;angle=152;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[107] = "func=ell;x=691;y=96;width=56;height=8;angle=268;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[108] = "func=ell;x=719;y=128;width=30;height=5;angle=14;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[109] = "func=ell;x=683;y=75;width=39;height=8;angle=152;bc=#5E635B;pc=#5E635B;pw=2;"
    shape[110] = "func=ell;x=723;y=99;width=79;height=9;angle=238;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[111] = "func=ell;x=781;y=134;width=30;height=5;angle=14;bc=#907D5B;pc=#5E635B;pw=2;"
    shape[112] = "func=ell;x=615;y=52;width=14;height=5;angle=348;bc=#000000;pc=#000000;pw=2;"
    s=1
    GraphicsWindow.Width=1000
    for i=78 To 112
      GraphicsWindow.BrushColor = shape[i]["bc"]  '  brushcolor
      GraphicsWindow.penColor = shape[i]["pw"]    '  pencolor
      If shape[i]["func"]="ell" Then 
        shp[i] = Shapes.AddEllipse(shape[i]["width"]*s, shape[i]["height"]*s)  '  ellipse
      ElseIf shape[i]["func"]="rect" Then 
        shp[i] = Shapes.AddRectangle(shape[i]["width"]*s, shape[i]["height"]*s) '  rectangle
      EndIf
      Shapes.Rotate(shp[i], Shape[i]["angle"])     ' <--------  rotating angle
      Shapes.Animate(shp[i], shape[i]["x"]*s, shape[i]["y"]*s, 500)
    EndFor

    Wednesday, November 9, 2016 2:34 PM
    Answerer
  • I tried the program MWC265, we can see two states of alternating images creating a pseudo-animation, then everything works well with this program.

     
    also, the section of program submitted by NaochanOn is excellent, and works very well, we see ant moving and take shape.

    STAGE 1:

    STAGE 2

    Wednesday, November 9, 2016 4:20 PM
    Answerer
  • if you want to rotate ellipse by using Graphics.Drawline , use this method.   VDV774

    '  Rotating ellipse  using GraphicsWindow.DrawLine command   VDV774
    '  (x-x0)^2/a^2+(y-y0)^2/b^2=1   ellipse
    PW=4
    GraphicsWindow.PenColor="Red"
    GraphicsWindow.PenWidth=PW
    x0=200
    y0=150
    a=100   '  width
    b=60    '  height
    For x= -a To a
      y1=b*math.SquareRoot(1-X*X/a/a)
      y2=-y1
      GraphicsWindow.DrawLine(x0+x,y1+y0,x0+x,y2+y0)
    EndFor

    X0=450
    GraphicsWindow.BrushColor="white"
    While "True"
      angle=angle+5
      rad= Math.GetRadians(angle)
      GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()
      rotate_ellipse()
      Program.Delay(500)
      GraphicsWindow.FillRectangle(x0-a-PW,y0-a-PW,2*(a+PW),2*(a+PW))
    endwhile

    Sub rotate_ellipse
      For x= -a To a
        y1=b*math.SquareRoot(1-X*X/a/a)
        y2=-y1
        NewY1=x*math.Sin(rad)+y1*math.Cos(rad)
        NewY2=x*math.Sin(rad)+y2*math.Cos(rad)
        NewX1= x*math.Cos(rad)-y1*math.sin(rad)
        NewX2=  x*math.Cos(rad)-y2*math.sin(rad)
        GraphicsWindow.DrawLine(x0+NewX1,y0+NewY1,x0+NewX2,y0+NewY2)
      EndFor
    EndSub

    Friday, November 11, 2016 6:40 AM
    Answerer
  • if you want to rotate ellipse by using Graphics.Drawline , use this method.   VDV774

    '  Rotating ellipse  using GraphicsWindow.DrawLine command   VDV774
    '  (x-x0)^2/a^2+(y-y0)^2/b^2=1   ellipse
    PW=4
    GraphicsWindow.PenColor="Red"
    GraphicsWindow.PenWidth=PW
    x0=200
    y0=150
    a=100   '  width
    b=60    '  height
    For x= -a To a
      y1=b*math.SquareRoot(1-X*X/a/a)
      y2=-y1
      GraphicsWindow.DrawLine(x0+x,y1+y0,x0+x,y2+y0)
    EndFor

    X0=450
    GraphicsWindow.BrushColor="white"
    While "True"
      angle=angle+5
      rad= Math.GetRadians(angle)
      GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()
      rotate_ellipse()
      Program.Delay(500)
      GraphicsWindow.FillRectangle(x0-a-PW,y0-a-PW,2*(a+PW),2*(a+PW))
    endwhile

    Sub rotate_ellipse
      For x= -a To a
        y1=b*math.SquareRoot(1-X*X/a/a)
        y2=-y1
        NewY1=x*math.Sin(rad)+y1*math.Cos(rad)
        NewY2=x*math.Sin(rad)+y2*math.Cos(rad)
        NewX1= x*math.Cos(rad)-y1*math.sin(rad)
        NewX2=  x*math.Cos(rad)-y2*math.sin(rad)
        GraphicsWindow.DrawLine(x0+NewX1,y0+NewY1,x0+NewX2,y0+NewY2)
      EndFor
    EndSub

    hello and thanking you in advance  have drawn a shape ID NQX810 and tried to animate it ID RCQ916 but am not geting anywhere am sorry on my ignorense will ned help in both program still i think i am happy to come this far in only ten months programming with no prevence experiance its all due to small basic forum and you gurus

                  thankingyou again with love from mussa-maina

                                           mahreen miangul
    Friday, November 11, 2016 8:34 AM
  • see RCQ916-0

    many error exists.  see  <----  marked lines.

    1) shape array contains 6 data from 1 to 6 . so, for endfor loop should be For 1 to 6 .

    2) shape array data should be separated by using ";" .

    3)  line data should contain X1,Y1,X2,Y2 data.   

    4) line shape is added as below 

    ElseIf shape[i]["func"]="line" Then  '  <---------line
        shp[i] = Shapes.Addline(shape[i]["x1"]*s, shape[i]["y1"]*s,shape[i]["x2"]*s, shape[i]["y2"]*s) '  <---------line

    Friday, November 11, 2016 10:31 AM
    Answerer