Giter Club home page Giter Club logo

Comments (6)

dmjio avatar dmjio commented on June 15, 2024

@noughtmare I'd try using the loadImage function, if that still gives you problems I can look into it tonight. The example I have might be outdated.

from arrayfire-haskell.

noughtmare avatar noughtmare commented on June 15, 2024

@dmjio loadImage loads an image from disk, I want to generate an image programmatically (and then show it in a window).

from arrayfire-haskell.

dmjio avatar dmjio commented on June 15, 2024

@noughtmare I think the type needs to be CBool (b8). Can confirm soon.

from arrayfire-haskell.

noughtmare avatar noughtmare commented on June 15, 2024

@dmjio If I use CBool then I get the error:

free(): invalid size
Aborted

from arrayfire-haskell.

dmjio avatar dmjio commented on June 15, 2024

@noughtmare there's been some fixes (related to double free'ing of pointers) that are now in HEAD, am working on the Graphics module now with success. drawSurface in particular.

As I inspect more with what the C++ is doing before it sends it to the C, we'll have better working visualization code, and examples !

main :: IO ()                                                                                                                                                                                                   
main = do                                                                                                                                                                                                       
  window <- createWindow 800 600 "hey"                                                                                                                                                                          
  let x = iota [60,1] [1,60] / 29                                                                                                                                                                               
      y = iota [1,60] [60,1] / 29                                                                                                                                                                               
  go window (0 :: Array Float) x y                                                                                                                                                                              
    where                                                                                                                                                                                                       
      go window t x y = do                                                                                                                                                                                      
        let z = 10*x*(-abs(y)) * cos(x*x*(y+t))+sin(y*(x+t))-1.5                                                                                                                                                
        drawSurface window x y z (Cell (-1) (-1) "there" ColorMapDefault)                                                                                                                                       
        closed <- isWindowClosed window                                                                                                                                                                         
        unless closed $ go window (t + 0.07) x y  

image

from arrayfire-haskell.

dmjio avatar dmjio commented on June 15, 2024

@noughtmare, for drawImage, try something like this:

main :: IO ()                                                                                                                                                                                                   
main = render =<< createWindow 800 600 "hey"                                                                                                                                                                          
    where                                                                                                                                                                                                       
      render window = do                                                                                                                                                                                            
        let x = iota [1,60] [60,1] / (30 :: Array Float)                                                                                                                                                        
            cell = Cell (-1) (-1) "" ColorMapDefault                                                                                                                                                        
        drawImage window x cell                                                                                                                                                                                 
        closed <- isWindowClosed window                                                                                                                                                                         
        unless closed (render window)

image

I'll update the documentation to reflect this.

from arrayfire-haskell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.