Discussion forum about PANORAMIC language
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Discussion forum about PANORAMIC language

Mac, Windows & Android application development with PANORAMIC language
 
HomeHome  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  
Latest topics
» What happened with the panoramic language ?
by Wed Jan 03, 2024 4:09 pm

» Hello world.
by Wed May 09, 2018 11:53 pm

» Biomorphes de PICKOVER
by Sun Jun 18, 2017 2:33 am

» In less than 10 lines of code
by Fri Jun 16, 2017 5:03 am

» Effect Dopler
by Fri Jun 16, 2017 3:29 am

» SuperEllipse
by Wed Jun 14, 2017 4:01 am

» Plants
by Wed Jun 14, 2017 3:38 am

» Mira's attractor
by Wed Jun 14, 2017 3:30 am

» Triangle of Sierpinski
by Wed Jun 14, 2017 3:22 am

» Esthétique polaire
by Wed Jun 14, 2017 3:16 am

» Butterfly effect : Lorenz equations
by Wed Jun 14, 2017 3:08 am

» Collision detection
by Tue Jun 13, 2017 5:09 am

» The Bees Laline Paull Epub Books
by Mon Oct 10, 2016 8:58 pm

» PANORAMIC for Mac OSX 10 is available
by Tue Aug 09, 2016 6:08 pm

» ide
by Sat Jul 16, 2016 12:27 am

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

 

 Draw a forest

Go down 
2 posters
AuthorMessage
papydall

papydall


Number of posts : 39
Age : 73
Localisation : TUNISIA
Registration date : 2013-03-16

Draw a forest Empty
PostSubject: Draw a forest   Draw a forest EmptyFri Oct 18, 2013 12:37 pm

Hello everybody.

Here is a small code to draw a forest.
Good entertainment!

Code:
' *********************************
' * *
' * FOREST.BAS BY PAPYDALL
' **     English version
' * *
' *********************************
init()
sun(xsun%,ysun%,rsun%)
go()
end
' ******************************************************************************

SUB init()
    dim ss% : ss% = 20
    dim sang,sang1(ss%),xx(ss%),yy(ss%)
    dim rad : rad = 3.141592653579793/180
    dim compteur% : compteur% = 0
    dim xpos%,ypos% : xpos% = 320 : ypos% = 500
    dim xp,yp,xp1,yp1,x,y,x1,y1,ran1,ran2,s2,zx,zy
    dim a$,a0$,a1$,b$,st,gen%,k%,s,ang,ang1,an,j%,cl,i%
    dim xsun%,ysun%, rsun% :  xsun% = int(rnd(800)+100) : ysun% = 50 : rsun% = 20
    dim titre$ :  titre$ = " *** <CLICK> TO STOP"
    titre$ = titre$ + " *** BUT YOU WILL LOSE NOTHING IF YOU WAIT A FEW MINUTES !!!"
    width 0,1000 : height 0, 700 : color 0,10,100,150 : cls

END_SUB
' ******************************************************************************
SUB sun(x%,y%,r%)
    2d_circle x%,y%,r% : 2d_flood x%,y%,255,255,0
END_SUB
' ******************************************************************************

SUB go()
    dim_local cr%,cv%,cb%, exit%
    exit%=0
    repeat
      cr% = int(rnd(160)) : cv% = int(rnd(140)) : cb%=int(rnd(255))
      xpos% = int(rnd(800) +100)
      B$ = "" : A$ = "" : A0$ = "" : A1$ = ""
      st = 0 : gen% = mod(compteur%,13)+1 : compteur% = compteur% + 1
      caption 0,"FOREST BY PAPYDALL : NUMBER OF DRAWN PLANTATIONS : " + str$(compteur%) + string$(5," ") + titre$
      select gen%
         case 1
              k% = 6 : s = 1.5 : ang1 = int(rnd(80)+8 )
              A$ = "0" : A1$ = "11" : A0$ = "1##10!+0!-0"
         case 2
              k% = 5 : s = 3 : ang1 = int(rnd(20)+16)
              A$ = "1" : A1$ = "11-#-1+0+0!+#+1-0-0!" : A0$ = "0"
         case 3
              k% = 6 : s = 1.5 : ang1 = int(rnd(45)+8 )
              A$ = "0" : A1$ = "11" : A0$ = "1#+0!1#-0!0"
         case 4
              k% = 5 : s = 3 : ang1 = int(rnd(10)+10)
              A$ = "1" : A1$ = "1#+0!#=0!1#+1+-0!#-1-+0!" : A0$ = "0-0++0"
         case 5
              k% = 5 : s = 3 : ang1 = int(rnd(16)+16)
              A$ = "1" : A1$ = "11-#-1+0+0!+#+1-0-0!" : A0$ = "#0-0++0!"
         case 6
              k% = 4 : s = 2.5 : ang1 = int(rnd(10)+10)
              A$ = "1" : A1$ = "1#+10!1#-10!1" : A0$ = "#0-0++0!"
         case 7
              k% = 4 : s = 1.75 : ang1 = int(rnd(30)+10)
              A$ = "1" : A1$ = "1#+1-10!1#-1+10!10" : A0$ = "#0-0++0!"
         case 8
              k% = 4 : s = 3 : ang1 = int(rnd(15)+10)
              A$ = "1" : A1$ = "11#+1-1+10!#-1+1-10!" : A0$ = "#0-0++0!"
         case 9
              k% = 4 : s = 3.5 : ang1 = 10
              A$ = "1" : A1$ = "11#+1+1-#0-0++0!!0#-1-1+#0-0++0!!" : A0$ = "#0-0++0!"
         case 10
              k% = 4 : s = 3.6 : ang1 = int(rnd(5)+10)
              A$ = "#+1-1!#-1+1!" : A1$ = "1#-1+0!1#+1-0!0" : A0$ = "#0-0++0!"
         case 11
              k% = 3 : s = 2.75 : ang1 = int(rnd(3)+8 )
              A$ = "1" : A1$ = "11#+10-10+10-10!1#-10+10-10+10!0" : A0$ = "0"
         case 12
              k% = 3 : s = 4 : ang1 = int(rnd(60)+20)
              A$ = "1" : A1$ = "1#-10-10-10!1#+10+10+10!1#10!" : A0$ = "0"
         case 13
              k% = 4 : s = 2 : ang1 = int(rnd(8 )+10)
              A$ = "0" : A1$ = "111" : A0$ = "11#+0!#++0!#+++0!#-0!#--0!#---0!0"
      end_select

      for j% = 1 to k%
          cl = len(A$)
          for i% = 1 to cl
              if mid$(A$,i%,1) = "1"
                 B$ = B$ + A1$
              else
                 if mid$(A$,i%,1)="0"
                    B$ = B$ + A0$
                 else
                    B$ = B$ + mid$(A$,i%,1)
                 end_if
              end_if
          next i%
          A$ = B$ : B$ = ""
          ang = 360.0/ang1 : x = 0 : y = 0 : an = 0 : cl = len(A$)
          for i% = 1 to cl
              if mid$(A$,i%,1) = "1"
                 ran1 = rnd(1) : ran2 = rnd(1) : s2 = s + 0.5 *(ran1-ran2)* s
                 ran1 = rnd(1) : ran2 = rnd(1) : an = an + 5.0 *(ran1-ran2)
                 sang = an : x1 = s2 * sin(an*rad)+ x : y1 = s2 * cos(an*rad)+ y
                 xp = 2 * x + xpos% : yp = ypos% - 2 * y
                 xp1 = 2 * x1 + xpos% : yp1 = ypos% - 2 * y1
                 2d_pen_color 0,90+cv%,0 : 2d_line xp,yp , xp1,yp1
                 x = x1 : y = y1
             else
                if mid$(A$,i%,1) = "0"
                   zx = sin(an*rad): zy = cos(an*rad)
                   x1 = zx * s + x : y1 = zy * s + y
                   xp = 2 * x + xpos% : yp = ypos% - 2 * y
                   xp1 = 2 * x1 + xpos% : yp1 = ypos% - 2 * y1
                   2d_pen_color 90+cr%,65 + cv%,cb% : 2d_line xp,yp , xp1,yp1
                   x1 = 0.25 * zx * s + x : y1 = 0.25 * zy * s + y
                   xp1 = 2 * x1 + xpos% : yp1 = ypos% - 2 * y1
                   2d_pen_color 255,0,0 : 2d_line xp,yp , xp1,yp1
               else
                  if mid$(A$,i%,1) = "-"
                     ran1 = rnd(1) : ran2 = rnd(1)
                     an = an - ang - 10 *(ran1-ran2) : sang = an
                  else
                     if mid$(A$,i%,1)="+"
                        ran1 = rnd(1) : ran2 = rnd(1)
                        an = an + ang + 10 *(ran1-ran2) : sang=an
                     else
                        if mid$(A$,i%,1)="#"
                           st = st + 1 : sang1(st) = sang
                           xx(st) = x : yy(st) = y
                        else
                           if mid$(A$,i%,1)="!"
                              x = xx(st) : y = yy(st)
                              an = sang1(st) : sang = an : st = st-1
                           end_if
                        end_if
                     end_if
                 end_if
               end_if
             end_if
             if scancode<>0 then exit% = 1: exit_for
          next i%
          if exit%=1 then exit_for
      next j%
    until exit% = 1
END_SUB
' **************** E N D ***************
Back to top Go down
froggy one

froggy one


Number of posts : 1
Registration date : 2013-10-19

Draw a forest Empty
PostSubject: Re   Draw a forest EmptySat Oct 19, 2013 6:43 pm

Very Happy  Papydall, I've just discovered your program on the british forum, that's beautiful, looks like fern. I'm still learning programmation with your exercises. I do like your style, leading us to further questions and trials. See you back on the french side, bye !
Back to top Go down
papydall

papydall


Number of posts : 39
Age : 73
Localisation : TUNISIA
Registration date : 2013-03-16

Draw a forest Empty
PostSubject: Re: Draw a forest   Draw a forest EmptySat Oct 19, 2013 7:54 pm

Thank you Froggy One.
This program was already posted on the French forum for some time.
Back to top Go down
Sponsored content





Draw a forest Empty
PostSubject: Re: Draw a forest   Draw a forest Empty

Back to top Go down
 
Draw a forest
Back to top 
Page 1 of 1
 Similar topics
-
» Panoramic Draw
» to write or draw with the mouse

Permissions in this forum:You cannot reply to topics in this forum
Discussion forum about PANORAMIC language :: Panoramic for Windows :: Source code (snippets)-
Jump to: