• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Reply to: .NET

Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on ".NET"

Collapse

  • Guest's Avatar
    Guest replied
    Re: Franco

    People ACTUALLY still write code when there's that great FREE library out there called Google? :rolleyes

    I just cut'n'shut bits together rather like one of those backstreet 2nd hand car dealers do in east London.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    Oh my gawd, Spodly has learnt how to google. There's no stopping him now.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    because
    fvariable ci fvariable c fvariable zi fvariable z
    : >2? z f@ fdup f* zi f@ fdup f* f+ 4.0e f> ;
    : nextr z f@ fdup f* zi f@ fdup f* f- c f@ f+ ;
    : nexti z f@ zi f@ f* 2.0e f* ci f@ f+ ;
    : pixel c f! ci f! 0e z f! 0e zi f! 150 50 do nextr nexti zi f! z f! >2? if i unloop exit then loop 0 ;
    : left->right -1.5e 400 0 do fover fover pixel emit 0.005e f+ loop fdrop ;
    : top->bottom -1e 400 0 do left->right 0.005e f+ loop fdrop ;
    .( P5) cr .( 400 400) cr .( 255) cr top->bottom bye
    looks remarkably similar to this...
    fvariable ci fvariable c fvariable zi fvariable z
    : >2? z f@ fdup f* zi f@ fdup f* f+ 4.0e f> ;
    : nextr z f@ fdup f* zi f@ fdup f* f- c f@ f+ ;
    : nexti z f@ zi f@ f* 2.0e f* ci f@ f+ ;
    : pixel c f! ci f! 0e z f! 0e zi f! 150 50 do nextr nexti zi f! z f! >2? if i unloop exit then loop 0 ;
    : left->right -1.5e 400 0 do fover fover pixel emit 0.005e f+ loop fdrop ;
    : top->bottom -1e 400 0 do left->right 0.005e f+ loop fdrop ;
    .( P5) cr .( 400 400) cr .( 255) cr top->bottom bye
    Which can be found here

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    So you didn't steal the code then Threaded?

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    Spodly: Nah, not that one, the one I posted before these two was clearly obfuscated.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    Threaded, you've posted that tulipe before.

    Also, I suggest if you're gonna steal someone elses code you might be kind enough to credit them for it.

    Spod.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    Dim: To do somat like that you'd want this:

    fvariable ci fvariable c fvariable zi fvariable z
    : >2? z f@ fdup f* zi f@ fdup f* f+ 4.0e f> ;
    : nextr z f@ fdup f* zi f@ fdup f* f- c f@ f+ ;
    : nexti z f@ zi f@ f* 2.0e f* ci f@ f+ ;
    : pixel c f! ci f! 0e z f! 0e zi f! 150 50 do nextr nexti zi f! z f! >2? if i unloop exit then loop 0 ;
    : left->right -1.5e 400 0 do fover fover pixel emit 0.005e f+ loop fdrop ;
    : top->bottom -1e 400 0 do left->right 0.005e f+ loop fdrop ;
    .( P5) cr .( 400 400) cr .( 255) cr top->bottom bye


    the other did ascii. Can yours do ascii?

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    Now Now Threaded, where are the stack comments? Proper FORTH coders would never leave out the stack comments.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    That's great threaded, but does it display this?



    No, didn't think so. :\

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    Here's a Mandelbrot done in Forth. much easier to understand and considerably shorter.

    hex 4666 dup negate do i 4000 dup 2* negate do 2a 0 dup 2dup 1e 0 do 2swap * d >>a 4 pick + -rot - j + dup dup * e >>a rot dup dup * e >>a rot swap 2dup + 10000 > if 3drop 2drop 20 0 dup 2dup leave then loop 2drop 2drop type 268 +loop cr drop 5de +loop

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re:.

    "But, apart from making you look quite hard, why would want to?"

    Might provoke an erection.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    But, apart from making you look quite hard, why would want to?
    Wrong, it doesn't make me look hard, I'm a geek, it makes me hard!!!

    As for a reason, maybe for the same reason I like to run Linux on my iPaq.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    Well, you can of course code directly in MSIL rather than say C#.

    But, apart from making you look quite hard, why would want to?

    If you are interested msdn.microsoft.com/msdnmag/issues/01/05/bugslayer/print.asp

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    DP, thanks, like it!

    So, why aren't people coding it by hand then?

    I've got a .net environment for my 'phone, must have a play...

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Franco

    It looks like this coded by hand.

    Code:
     .method private hidebysig instance 
               void DrawMandelbrot(class [System.Drawing]System.Drawing.Graphics g,
                                   float32 fpMandelWidth, int32 ipIterations) cil managed {
    
        .locals (
        [0] float32 x, // Complex Real portion
        [1] float32 y, // Complex Imaginary portion
        [2] float32 fpGranularity, // Resolution of image on screen
        [3] int32 ipPixelX, // X position on screen
        [4] int32 ipPixelY, // Y position on screen
        // Escape Velocity locals
        [5] float32 fpX,
        [6] float32 fpY,
        [7] float32 fpXTemp,
        [8] float32 fpYTemp,
        [9] float32 fpX2, // X Squared
        [10] float32 fpY2, // Y Squared
        [11] int32 i // Loop variable used to calc escape velocity
        )
        // Calculate Granularity
        ldc.r4 4
        ldarg fpMandelWidth
        div
        stloc fpGranularity
    
    
        // Initialise point on screen
        ldc.i4.0
        dup
        stloc ipPixelX
        stloc ipPixelY
    
    
        // Start the real portion off
        ldc.r4 -2.5
        stloc x
    
    NextReal:
    
        // Start the imaginary portion off
        ldc.r4 -1.5
        stloc y
    
    NextImaginary:
    
        // Calculate Escape Velocity
    
        // Initialise locals
        ldloc x
        stloc fpX
    
        ldloc y
        stloc fpY
    
        ldloc x
        dup
        mul
        stloc fpX2
    
        ldloc y
        dup
        mul
        stloc fpY2
    
    
        // Initialise i
        ldc.i4.0
        stloc i
    NextIteration:
    
    
        ldloc x
        ldloc fpX2
        ldloc fpY2
        sub
        add
        stloc fpXTemp
    
        ldloc y
        ldloc fpY
        ldloc fpX
        ldc.r4 2
        mul
        mul
        add
        stloc fpYTemp
    
        // Calculate X squared
        ldloc fpXTemp
        dup
        mul
        stloc fpX2
    
        // Calculate Y squared
        ldloc fpYTemp
        dup
        mul
        stloc fpY2
    
        // If X Squared plus Y Squared is greater than 4, then we are guaranteed 
        // divergence to Infinity
        ldloc fpX2
        ldloc fpY2
        add
        ldc.r4 4
        bge Divergence
    
        // The previous values in the sequence become the current values in the sequence
        ldloc fpXTemp
        stloc fpX
        ldloc fpYTemp
        stloc fpY
    
    
        // Incrememt i
        ldc.i4.1
        ldloc i
        add
        stloc i
    
        ldloc i
        ldarg ipIterations
        blt NextIteration // Assume convergence to zero if we reach our iteration limit
    
    Divergence:
    
        // Draw Pixel. i is now the escape velocity
    
        // Load the Graphics context
        ldarg g
    
        // Calculate the color based on the escape velocity
    
    
        ldarg ipIterations
        ldloc i
        sub
        stloc i
    
        // Red
        ldloc i
        ldc.i4 12
        mul
        ldc.i4 256
        rem
    
        // Green
        ldloc i
        ldc.i4 16
        mul
        ldc.i4 256
        rem
    
        // Blue
        ldloc i
        ldc.i4 5
        mul
        ldc.i4 256
        rem
    
        call value class [System.Drawing]System.Drawing.Color 
                               [System.Drawing]System.Drawing.Color::FromArgb(int32,
                                                                              int32,
                                                                              int32)
    
    
        // Create a new Pen on the stack
        ldc.r4 1
        newobj instance void [System.Drawing]System.Drawing.Pen::.ctor(value class 
                                                  [System.Drawing]System.Drawing.Color,
                                                    float32)
    
        // Load the coords of the point to draw
        ldloc ipPixelX
        ldloc ipPixelY
    
        // Width and Height
        ldc.i4.2
        dup
    
        call instance void [System.Drawing]System.Drawing.Graphics::DrawRectangle(class 
                                                   [System.Drawing]System.Drawing.Pen,
                                                    int32,
                                                    int32,
                                                    int32,
                                                    int32)
    
        // Next PixelY
        ldc.i4.1
        ldloc ipPixelY
        add
        stloc ipPixelY
    
        // Advance through the imaginary portion
        ldloc y
        ldloc fpGranularity
        add
        stloc y
    
        ldloc y
        ldc.r4 1.5
        blt NextImaginary
    
        // Advance through ipPixelX
        ldc.i4.1
        ldloc ipPixelX
        add
        stloc ipPixelX
    
        // Start at the top of the screen for the next column
        ldc.i4.0
        stloc ipPixelY
    
        // Advance through the real portion
        ldloc x
        ldloc fpGranularity
        add
        stloc x
    
        ldloc x
        ldc.r4 1.5
        blt NextReal
    
        ret
    } // method

    Leave a comment:

Working...
X