Author Topic: Procedural Texture (noise)  (Read 3053 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Procedural Texture (noise)
« on: August 10, 2012, 09:06:05 AM »
This in an on-going project to help p develop a dialogs and controls library, with a seperable GUI layer. I'm currently using Peter's GDI windows system.

The full code can be found in projectsA/Controls (Oxygen-in-Progress).

Code: OxygenBasic
  1.  
  2. '$ filename "t.exe"
  3. '#include "../../inc/RTL32.inc"
  4. '#include "../../inc/RTL64.inc"
  5.  
  6. #include "Controls.inc"
  7.  
  8.  
  9. class ColorDialogBox
  10. ====================
  11.   '
  12.  indexbase 0
  13.   '
  14.  'FlatBox     im1
  15.  'ShadeBox    im1
  16.  NoiseBox    im1
  17.   '
  18.  DialogBox   d1
  19.   Slider      s1,s2,s3,s4,s5,s6
  20.   Slider      v1,v2,v3,v4,v5,v6,v7,v8
  21.   sys         r,g,b,h,l,s,p,q
  22.   sys         RgbZone,HcsZone
  23.   '
  24.  method constructor()
  25.   '
  26.  'images
  27.  '
  28.  im1<=320,160,0x7f7f7f,2
  29.   im1.create
  30.   '
  31.  'controls
  32.  '
  33.  d1<=20,40,600,400,"Procedural Noise"
  34.   s1<=100,100,10,15,50,150,100,100,"Red"
  35.   s2<=100,140,10,15,50,150,140,140,"Green"
  36.   s3<=100,180,10,15,50,150,180,180,"Blue"
  37.   s4<=100,220,10,15,50,150,220,220,"Hue"
  38.   s5<=100,260,10,15,50,150,260,260,"Luminance"
  39.   s6<=100,300,10,15,50,150,300,300,"Saturation"
  40.   s4.sc=240 'show scale
  41.  s5.sc=240 'show scale
  42.  s6.sc=240 'show scale
  43.  v1<=360,300,08,07,360,360,250,350,"A"
  44.   v2<=380,300,08,07,380,380,250,350,"B"
  45.   v3<=400,300,08,07,400,400,250,350,"C"
  46.   v4<=420,300,08,07,420,420,250,350,"D"
  47.   v5<=440,300,08,07,440,440,250,350,"E"
  48.   v6<=460,300,08,07,460,460,250,350,"F"
  49.   v7<=480,300,08,07,480,480,250,350,"G"
  50.   v8<=500,300,08,07,500,500,250,350,"H"
  51.   v1.bfeedback 128
  52.   v2.bfeedback  64
  53.   v3.bfeedback  32
  54.   v4.bfeedback  16
  55.   v5.bfeedback   8
  56.   v6.bfeedback   4
  57.   v7.bfeedback   2
  58.   v8.bfeedback   1
  59.   end method
  60.   '
  61.  method destructor
  62.   im1.destroy
  63.   end method
  64.   '
  65.  method set()
  66.   s1.set
  67.   s2.set
  68.   s3.set
  69.   s4.set
  70.   s5.set
  71.   s6.set
  72.   v1.set
  73.   v2.set
  74.   v3.set
  75.   v4.set
  76.   v5.set
  77.   v6.set
  78.   v7.set
  79.   v8.set
  80.   end method
  81.   '
  82.  method show()
  83.   d1.show
  84.   im1.rf=s1.fvalue 1
  85.   im1.gf=s2.fvalue 1
  86.   im1.bf=s3.fvalue 1
  87.   im1.nn=>
  88.     v1.bvalue,v2.bvalue,v3.bvalue,v4.bvalue,
  89.     v5.bvalue,v6.bvalue,v7.bvalue,v8.bvalue
  90.   im1.show d1.px+d1.sx-im1.w-10, d1.py+10
  91.   s1.show
  92.   s2.show
  93.   s3.show
  94.   s4.show
  95.   s5.show
  96.   s6.show
  97.   v1.show
  98.   v2.show
  99.   v3.show
  100.   v4.show
  101.   v5.show
  102.   v6.show
  103.   v7.show
  104.   v8.show
  105.   end method
  106.   '
  107.  method anchor()
  108.   d1.anchor
  109.   s1.anchor
  110.   s2.anchor
  111.   s3.anchor
  112.   s4.anchor
  113.   s5.anchor
  114.   s6.anchor
  115.   v1.anchor
  116.   v2.anchor
  117.   v3.anchor
  118.   v4.anchor
  119.   v5.anchor
  120.   v6.anchor
  121.   v7.anchor
  122.   v8.anchor
  123.   end method
  124.  
  125.   method move()
  126.   d1.move(xMouse-sxMouse,yMouse-syMouse)
  127.   tx=d1.px-d1.spx 'with limits
  128.  ty=d1.py-d1.spy 'with limits
  129.  s1.move tx,ty
  130.   s2.move tx,ty
  131.   s3.move tx,ty
  132.   s4.move tx,ty
  133.   s5.move tx,ty
  134.   s6.move tx,ty
  135.   v1.move tx,ty
  136.   v2.move tx,ty
  137.   v3.move tx,ty
  138.   v4.move tx,ty
  139.   v5.move tx,ty
  140.   v6.move tx,ty
  141.   v7.move tx,ty
  142.   v8.move tx,ty
  143.   end method
  144.   '
  145.  method HcsFeedback(sys c)
  146.   ColorRGBToHLS c,h,l,s
  147.   s4.ffeedback h,240
  148.   s5.ffeedback l,240
  149.   s6.ffeedback s,240
  150.   end method
  151.   '
  152.  method RgbFeedback(sys c)
  153.   r=c and 255
  154.   shr c,8
  155.   g=c and 255
  156.   shr c,8
  157.   b=c and 255
  158.   s1.bfeedback r
  159.   s2.bfeedback g
  160.   s3.bfeedback b
  161.   end method
  162.   '
  163.  method GetHcsColor() as sys
  164.   h=s4.fvalue 240
  165.   l=s5.fvalue 240
  166.   s=s6.fvalue 240
  167.   return ColorHLStoRGB h,l,s
  168.   end method
  169.   '
  170.  method GetRgbColor() as sys
  171.   return s1.bvalue()+s2.bvalue()*0x100+s3.bvalue()*0x10000
  172.   end method
  173.   '
  174.  method zone() as sys
  175.   return d1.zone
  176.   end method
  177.   '
  178.  method zones(sys *RgbZone,*HcsZone)
  179.   RgbZone=s1.zone()+s2.zone()+s3.zone()
  180.   HcsZone=s4.zone()+s5.zone()+s6.zone()
  181.   end method
  182.   '
  183.  method action()
  184.   if mouseButton=0
  185.     anchor
  186.     q=0
  187.   end if
  188.   if q
  189.     move
  190.   elseif MouseButton
  191.     set
  192.     zones RgbZone,HcsZone
  193.     if RgbZone then
  194.       HcsFeedback GetRgbColor
  195.     elseif HcsZone
  196.       RgbFeedback GetHcsColor
  197.     elseif v1.zone() or v2.zone() or v3.zone() or v4.zone() or
  198.            v5.zone() or v6.zone() or v7.zone() or v8.zone()
  199.       '
  200.    elseif zone
  201.       q=1
  202.     end if
  203.   end if
  204.   end method
  205.   '
  206. end class
  207.  
  208. 's=recordof ColorDialogBox
  209. 'putfile "t.txt", s
  210.  
  211. new ColorDialogBox cdb
  212.  
  213. AscKey=-1
  214. do
  215.   if EscKey then exit do
  216.   if mouseButton=0
  217.     sxMouse=xMouse
  218.     syMouse=yMouse
  219.   end if
  220.   cdb.action
  221.   if MouseButton or AscKey
  222.     ClsColor 0x606060 'cdb.GetRgbColor
  223.    cdb.show
  224.     AscKey=0
  225.     FlipBuffer
  226.     sleep 5
  227.   else
  228.     events
  229.     sleep 50
  230.   end if
  231. end do
  232.  
  233. del cdb
  234.  

Charles


Compiled demo:

X

Aurel

  • Guest
Re: Procedural Texture (noise)
« Reply #1 on: August 10, 2012, 12:13:45 PM »
Nice try,but this can't replace real api apps.
by the way ...oh forget never mind...

Peter

  • Guest
Re: Procedural Texture (noise)
« Reply #2 on: August 10, 2012, 12:16:45 PM »
Hi Charles,

is a fantastic work by you!
I like it very much.  I have made a little bit grass for my  Alien planet.

X

Charles Pegge

  • Guest
Re: Procedural Texture (noise)
« Reply #3 on: August 10, 2012, 07:49:14 PM »

There are no limitations :)

kryton9

  • Guest
Re: Procedural Texture (noise)
« Reply #4 on: August 10, 2012, 10:14:38 PM »
That's really nice Charles. Thanks for the cool program.