Program för random picture

Här nedan finns programkoden i Hypertalk som genererar bilderna med slumpmässiga variationer. Bildernas namn föregår koden. Alla element i koden är ej presenterade. En del anropade funktioner( ) finns ej med. Hypertalk är högnivåspråk som påminner om pascal. Självaste uppritningen av bilden återfinns i kommandot "drag from x,y to dx,dy" dvs "rita bilden från kordinaten x,y till kordinaten dx,dy"

 

Kalinga

on dragning x,y,dx,dy

  put trunc(abs(x-dx)/10) into a

  put trunc(abs(y-dy)/10) into b

  if dx < x then put -1 into t

  else put 1 into t

  if dy < y then put -1 into z

  else put 1 into z

  put empty into f

  repeat 10  --until f > 8*a

    put random of a into d

    put random of b into e

    add d to f

    drag from x,y to (x + t*d),(y + z*e)

    put x+t*d into x

    put y+z*e into y

  end repeat

  drag from x,y to dx,dy

end dragning

on linjedragning

  put random of 512 into x

  put random of 688 into y

  put x &"," & y after kordinater

  repeat 20

    put (30 + random of 100) into e

    put (30 + random of 100) into f

    put polaritet() into t

    put polaritet() into z

    put x+z*e into dx

    put y+t*f into dy

    send "dragning x,y,dx,dy"

    put dx into x

    put dy into y

    put ","& dx & "," & dy after kordinater

    put number of items in kordinater into k

    put random of k into g

    if 2*trunc(g/2) = g then subtract 1 from g

    put item g of kordinater into x

    put item (g+1) of kordinater into y

  end repeat

end linjedragning

 

Risfält i storm

function polaritet

  put random of 2 into i

  if i = 2 then put -1 into i

  return i

end polaritet

on linjeDragning

  put random of 512 into x

  put random of 688 into y

  put polaritet() into z

  put -1*z into t

  repeat 5

    put (12 + random of 12) into dx

    put (12 + random of 12) into dy

    repeat 10

      drag from x,y to x +z*(dx),y +t*(dy)

      put polaritet() into z

      put -1*z into t

      add z*random of 12 to x

      add t*random of 12 to y

      add z*random of 12 to dx

      add t*random of 12 to dy

    end repeat

    add z*dx-random of 12 to x

    add t*dy-random of 12 to y

  end repeat

end linjeDragning


 

Trädtoppar

on linjeDragning

  put random of 512 into x

  put random of 688 into y

  put polaritet() into z

  put (30 + random of 100) into dx

  put (30 + random of 100) into dy

  put 1 into e

  put x+z*dx into dx

  put y + dy into dy

  send "dragning x,y,dx,dy"

  put 1 into t

  repeat random of 60

    send "dragning x,y,dx,dy"

    if z = 1 then put -1 into t

    add random of 6 to x

    add t*(random of 6) to y

    add random of 6 to dx

    add t*(random of 6) to dy

  end repeat

  add 10-random of 10 to x

  add 10-random of 10 to y

end linjeDragning

function polaritet

  put random of 2 into i

  if i = 2 then put -1 into i

  return i

end polaritet

on dragning x,y,dx,dy

  put trunc(abs(x-dx)/10) into a

  put trunc(abs(y-dy)/10) into b

  if dx < x then put -1 into t

  else put 1 into t

  repeat until y > dy

    put random of a into d

    put random of b into e

    drag from x,y to (x + t*d),(y + e)

    put x+t*d into x

    put y+e into y

  end repeat

end dragning

 

Himalaya

function polaritet

  put random of 2 into i

  if i = 2 then put -1 into i

  return i

end polaritet

 

on dragning x,y,dx,dy

  put trunc(abs(x-dx)/10) into a

  put trunc(abs(y-dy)/10) into b

  if dx < x then put -1 into t 

  else put 1 into t

  if dy < y then put -1 into z

  else put 1 into z

  put empty into f

  repeat 10  --until f > 8*a

    put random of a into d

    put random of b into e

    add d to f

    drag from x,y to (x + t*d),(y + z*e)

    put x+t*d into x

    put y+z*e into y

  end repeat

  drag from x,y to dx,dy

end dragning

 

 

on linjedragning 

  put random of 256 into x

  put random of 688 into y

  put x &"," & y into kordinater

  repeat 20

    put 1 into z

    put 1 into t

    put x into a

    put y into b

    repeat with r = 1 to 4

      put (30 + random of 100) into e

      put (30 + random of 100) into f

      if r = 2 then put -1 into t

      if r = 3 then put -1 into z

      put x+z*e into dx

      put y+t*f into dy

      if r = 4

      then

        put a into dx

        put b into dy

      end if

      send "dragning x,y,dx,dy"

      put dx into x

      put dy into y

      put ","& dx & "," & dy after kordinater

    end repeat

    put number of items in kordinater into k

    put random of k into g

    if 2*trunc(g/2) = g then subtract 1 from g

    put item g of kordinater into x

    put item (g+1) of kordinater into y

  end repeat

end linjedragning