Liberty BASIC Community Forum
« Dwawing wipples ( ripples with a lisp..) »

Welcome Guest. Please Login or Register.
Jun 25th, 2017, 05:20am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Dwawing wipples ( ripples with a lisp..)  (Read 283 times)
tenochtitlanuk
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1154
xx Dwawing wipples ( ripples with a lisp..)
« Thread started on: Nov 30th, 2015, 5:54pm »

Twenty minutes of coding gave me the code that produced lots of 'lovely' screens like this.
User Image
I call them ripples because if you make the radius go up by 4 rather than two they LOOK like ripples In a can of paint. After taking LSD. Perhaps!
Each circle grows outwards.
Each left-mouse-click creates a new one.
Ex-or plotting and serendipity does the rest
Code:
    nomainwin

    WindowWidth  =800
    WindowHeight =800

    button #w.b, "Save", [saveScreen], LR, 50, 640

    open "Growing circles" for graphics_nsb as #w

    #w "trapclose [quit]"
    #w "size 2 ; down ; fill 50 50 50 ; flush"
    #w "when leftButtonUp [newCentre]"
    #w "rule _R2_NOTXORPEN"

    numDrops =0

    N =40
    dim startX( N), startY( N), radius( N), color$( N)

    startX( 0) =400: startY( 0) =400: radius( 0) =2: color$( 0) ="200 200 40"
    timer 500, [growThem]

    wait

  [quit]
    close #w
    end

  [growThem]
    scan
    for i =0 to numDrops
        #w "up; goto "; startX( i); " "; startY( i); " ; down ; color "; color$( i); " ; circle "; radius( i)
        if radius( i) <400 then radius( i) =radius( i) +2
    next i
    wait

  [newCentre]
    if numDrops <N then '   create a new one
        numDrops =( numDrops +1)
        startX( numDrops) =MouseX: startY( numDrops) =MouseY: radius( numDrops) =2: color$( numDrops) =randCol$()
    else    '   kill one and replace by new one
        r =int( N *rnd( 1))
        startX( r) =MouseX: startY( r) =MouseY: radius( r) =2: color$( r) =randCol$()
    end if
    wait

    function randCol$()
        randCol$ =str$( int( 256 *rnd( 1))) +" " +str$( int( 256 *rnd( 1))) +" " +str$( int( 256 *rnd( 1)))
    end function

  [saveScreen]
    #w "getbmp scr 1 1 800 800"
    bmpsave "scr", "wipple-" +str$( time$( "seconds")) +".bmp"
    wait
 
« Last Edit: Nov 30th, 2015, 5:57pm by tenochtitlanuk » User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1661
xx Re: Dwawing wipples ( ripples with a lisp..)
« Reply #1 on: Dec 1st, 2015, 02:00am »

It overlap in really nice 3d-ish way.
Still can't understand how drawining circles produce us stright lines?
User IP Logged

The existence of bug reports means somebody is using the software and actually cares to report back to you that he is having a problem with it, instead of just deleting it from their hard disk.
(Janusz Marcin Gorycki)
tenochtitlanuk
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1154
xx Re: Dwawing wipples ( ripples with a lisp..)
« Reply #2 on: Dec 1st, 2015, 02:25am »

RR points out that it is a way of specifying XOR that fails. Omit the line! I was playing with what to do when the lines overlap.
BUT the LB Help says...
Code:
print #handle, "rule "; _R2_NOTXORPEN
This command specifies whether drawing overwrites (rulename OVER) graphics already on the screen or uses the exclusive-OR technique (rulename XOR). It is also possible to use Windows constants to select a drawing rule (as shown above). Here are the constants that Windows defines:
_R2_BLACK
_R2_WHITE
_R2_NOP
_R2_NOT
_R2_COPYPEN <- the default LB drawing rule
_R2_NOTCOPYPEN
_R2_MERGEPENNOT
_R2_MASKPENNOT
_R2_MERGENOTPEN
_R2_MASKNOTPEN
_R2_NOTMERGEPEN
_R2_MASKPEN
_R2_NOTMASKPEN
_R2_XORPEN
_R2_NOTXORPEN <- the xor LB drawing rule 

ie the last two lines seem swapped!
User IP Logged

tenochtitlanuk
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1154
xx Re: Dwawing wipples ( ripples with a lisp..)
« Reply #3 on: Dec 1st, 2015, 02:54am »

Easy to modify to show Moire effects.. or simulate a 'Ripple tank' demo of wave motion...
User Image
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1661
xx Re: Dwawing wipples ( ripples with a lisp..)
« Reply #4 on: Dec 1st, 2015, 04:10am »

>> ie the last two lines seem swapped!
I remember XORPEN and NOTXORPEN somehow related to drawing on black or on white... (so LB default is to draw on white)
yes yes
XOPRPEN first time draws un-changed colors on black, on secont draw operation restores black.
While LB default NOTXORPEN first time draws un-changed colors on WHITE, on secont draw operation restores it.
User IP Logged

The existence of bug reports means somebody is using the software and actually cares to report back to you that he is having a problem with it, instead of just deleting it from their hard disk.
(Janusz Marcin Gorycki)
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 889
xx Re: Dwawing wipples ( ripples with a lisp..)
« Reply #5 on: Dec 3rd, 2015, 06:42am »

whit 2 rasters of point

also you get somthing nice

Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
nomainwin
open "moiere" for graphics as #m
  #m "trapclose [quit]"
  for x = -100 to 100
    for y = -100 to 100
      sx = x * 3
      sy = y * 3
      call punt winx/2 + sx , winy/2 + sy
      call rotate sx , sy , 0.1
      call punt winx/2 + sx , winy/2 + sy
    next y
  next x
wait
sub rotate byref k , byref l , r
  s = sin( r )
  c = cos( r )
  hk = k * c - l * s
  hl = k * s + l * c
  k = hk
  l = hl
end sub
sub punt x , y
  #m "goto " ; int(x) ; " " ; int(y)
  #m "down"
  #m "set " ; int(x) ; " " ; int(y)
  #m "up"
end sub
[quit]
  close #m
end
 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
tenochtitlanuk
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1154
xx Re: Dwawing wipples ( ripples with a lisp..)
« Reply #6 on: Dec 3rd, 2015, 1:46pm »

For anyone inspired by Moire patterns, have a look at http://www.herocomm.com/Details/MoireStory.htm
Easy to create in LB, at least as good as the originals. Print some on laser/inkjet transparency sheets and superpose.
I got hooked via CT Stong/Scientfic American way, way back.....
User IP Logged

tenochtitlanuk
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1154
xx Re: Dwawing wipples ( ripples with a lisp..)
« Reply #7 on: Dec 4th, 2015, 2:46pm »

Just a quick demo of typical Moire sheets- one on transparency film- and the superposition patterns.
User Image
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls