Git Product home page Git Product logo

blank-canvas's People

Contributors

andygill avatar endgame avatar fizruk avatar ggreif avatar jeffreyrosenbluth avatar jtdawso avatar nomeata avatar nshaheed avatar roboguy13 avatar ryanglscott avatar sordina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blank-canvas's Issues

Crashing / pausing when rendering

Blank canvas sometimes crashes.

  • This happens when using ghci.
  • The server suddenly stops responding to a specific comet request (returns 404)
  • Manual probing show that this line of requests usually no longer honored (though I've had one that once was)
  • I suspect that it is a STM "race" condition.
  • It could be a kansas-comet bug.

Trigger

Implement the trigger command, that triggers an event, but from the Haskell end.

Slowdown

There are reports from EECS 776 that blank canvas slows down after playing a blank canvas game for a bit (~30 seconds). We need to figure out if that is a blank canvas issue, or an idiom issue.

blank-canvas fails to load static image in a sandbox

To reproduce this bug:

  1. Install the examples in a sandbox
  2. Run .cabal-sandbox/bin/blank-canvas-example-html5canvastutorial
  3. Go to example 1.6.4

The application will then fail with the alert message "Image /images/fan.jpg not found. Add as a static file to fix this."

Replace (#) with (&)

Right now, we have a function (#) :: a -> (a -> b) -> b such that a # f = f a. It works, but there's been talk of using the (#) as a natural transformation instead (currently in the wakarusa repo). With this, we could define natural transformations such as:

instance Transformation Canvas IO DeviceContext where
    (#) = send

However, this would not work for things that we currently use the blank-canvas (#) for, such as grd # addColorStop(0, "#8ED6FF") and (defFont [sansSerif]) { fontSize = 30 # pt }. I think the best way to mitigate such a change would be to use the (&) :: a -> (a -> b) -> b function that was introduced in GHC 7.10 in Data.Function (if one is using an older version of GHC, it's easy to redefine it: a & f = f a). There's also a bit of history in that (&) is also used in lens, so it's not a completely arbitrary choice of name.

@andygill, what are your thoughts?

Overload font with an ADT argument

Right now, font is of type Text -> Canvas (), which is pretty risky since CSS fonts have a pretty specific syntax that can be easy to goof up. To make using fonts more strongly typed, we should introduce a Font ADT (similar in spirit to the one in diagrams-lib) that one can use to optionally overload font.

Fonts have two required arguments: a size and a family, so the function that constructs it would probably look like mkFont :: FontSize -> FontFamily -> Font. The other four arguments are optional, so to prevent an excessive number of functions with combinations of optional arguments, we can allow the user to set them via record syntax, e.g.:

mkFont 16 "Droid Serif" {
    fontStyle   = Italics
  , fontVariant = SmallCaps
  , fontWeight  = 400
}

Should Canvas be in LiftIO

This was originally a debugging mechanism. I used it quite a bit in story-board.

We should consider

type Canvas a = CanvasM Pure a

Then allowing LiftIO for CanvasM IO.

(Or not. I can refactor story-board if needed.)

Surface functions

Add the ability to apply a JavaScript fn to a canvas, without going to Haskell.

Improve documentation

The documentation for many Canvas API functions is lacking or non-existent at the moment. This can be intimidating for beginners, so let's at least add a basic description of what each function does (perhaps using this overview of <canvas>).

Use of ()

Should size have type

size :: Canvas (Float,Float)

or

size :: () -> Canvas (Float,Float)

On the one hand, this is a JavaScript DSL, on the other, its not really Haskell-like.

Audio API

Now that we have a newAudio query working, we should figure out what actions a user can perform with audio, and implement them. Some ideas:

  • Playback controls (play, pause, reload)
  • Configuration other other properties (autoplay, volume, looping, etc.). See here for ideas.

saveRestore

saveRestore should have type C a -> C a, not C () - C ().

Bump upper version bound of transformers

blank-canvas currently requires transformers-0.3.*, but the latest version is 0.4.1.0. I can compile it with 0.4.1.0 without any changes, so raising the upper version bound should suffice.

release supporting GHC-7.10?

Can someone estimate when the version on Hackage will support GHC-7.10? It looks like HEAD already does, but maybe some upstream packages (stringsearch) do not.

We're preparing for a 1.3 Diagrams release, so I'm wondering if the next release of diagrams-canvas will be able to support GHC-7.10.

Add variants of drawImage and putImageData with exact numbers of arguments

drawImage and putImageData are variadic JavaScript functions, which we accomodate by making their blank-canvas equivalents accept lists of Floats as arguments. Since drawImage expects exactly 2, 4, or 8 Float arguments, and putImageData expects exactly 2 or 6 Float arguments, using lists can be error-prone. Thus, we should create variants of drawImage and putImageData that require exact numbers of Float arguments.

test-suite failures

The wiki-suite test seems to never finish, noticed both on ubuntu when building stackage nightly and when running it on OS X. On OS X I just get a blank browser window, after Ctrl-Cing some errors appear before exiting:

Test suite wiki-suite: RUNNING...
("blank-canvas.wiki/images/Load_Image_Data_URL_2.png","Load_Image_Data_URL_2")
"Load_Image_Data_URL_2"
# open (for blank-canvas.wiki/images/Load_Image_Data_URL_2.png)
"Exception in blank-canvas application:"
images/Haskell.jpg: openBinaryFile: does not exist (No such file or directory)
wiki-suite: images/Haskell.jpg: openBinaryFile: does not exist (No such file or directory)
"Exception in blank-canvas application:"
images/Haskell.jpg: openBinaryFile: does not exist (No such file or directory)
wiki-suite: images/Haskell.jpg: openBinaryFile: does not exist (No such file or directory)
"Exception in blank-canvas application:"
images/Haskell.jpg: openBinaryFile: does not exist (No such file or directory)
wiki-suite: images/Haskell.jpg: openBinaryFile: does not exist (No such file or directory)
user interrupt
Test suite wiki-suite: FAIL
Test suite logged to: dist/test/blank-canvas-0.6-wiki-suite.log

I've disabled running the test-suite on stackage for this reason.

Additionally the test suite also doesn't work if used with stack since there's no dist directory then:

./dist/build/wiki-suite/wiki-suite: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)

receiveloop: failed (No error)

This issue happens on Windows and not on Linux, so I'll assume it's Windows-specific. When running a blank-canvas application, refresh the browser. After a brief pause, the console running the blank-canvas application will print out receiveloop: failed (No error). Other than this "failure", nothing seems broken.

devicePixelRatio and other scaling

Have a way of scaling, based on the devicePixelRatio, or the considerations.

Background: 1px on the canvas is 2x2px on the screen. So text looks fuzzy.

By having the css value 1/2 the actual size, real pixels can be used.

Version 0.6 does not compile on 32 bit Linux (compiler crash)

Is this a known issue?

[  190s] [ 4 of 17] Compiling Graphics.Blank.JavaScript ( Graphics/Blank/JavaScript.hs, dist/build/Graphics/Blank/JavaScript.p_o )
[  198s] ghc: panic! (the 'impossible' happened)
[  198s]   (GHC version 7.10.3 for i386-unknown-linux):
[  198s]    Simplifier ticks exhausted
[  198s]   When trying UnfoldingDone eta_aoW1
[  198s]   To increase the limit, use -fsimpl-tick-factor=N (default 100)
[  198s]   If you need to do this, let GHC HQ know, and what factor you needed
[  198s]   To see detailed counts use -ddump-simpl-stats
[  198s]   Total ticks: 8

static file missing

If you try and load an image, and there is no static image available, there is no error message.

Read/IsString instance for Cursor chokes on URLs with too many quotes

Currently, the Read/IsString instance for Cursors don't take into account quotes URLs that have quotes themselves. For example, this will not parse currently: "url(\"https://en.wikipedia.org/wiki/\"Heroes\"\"), default". This should be fixable by tracking quotes with a stack.

Image loading via dynamic URLs

Add support for dynamically adding possible URLs for loading images, and artifacts.

We already support data URLs.

But better would be

url <- loadAsURL("foo/jayhawk.jpg")
img <- newImage (url)

This is because the browser can request it directly (via scotty), rather than send all the data via the command channel.

Presentation thingie does not generate events

I have an USB-dongle that (wirelessly) activates PageUP/Down keys on my keyboard. I have a Mac. However those keystrokes (as well as arrow keys etc. from the keyboard) do not arrive on the server side. I use story-board as the server app, and Chome as the client browser (same with Safari).

Any idea where the change should be made to fix this?

Event returning NaN

Here is the Event from a keypress. ePageXY should be Nothing.

Event {eMetaKey = False, ePageXY = Just (NaN,NaN), eType = "keypress", eWhich = Just 32})

Make sync return Float

sync returns (), which breaks the rule about return () merges with next command.

The ideas is instead return the round trip time.

sync  :: Canvas Float -- how long it took, in seconds
async :: Canvas Float -- also how long it took

measureText can't find "width" key

One of the HTML5 Canvas tutorial examples (1.8.6) currently crashes.

{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.Monoid
import qualified Data.Text as Text

import           Graphics.Blank

main :: IO ()
main = blankCanvas 3000 $ \ctx -> send ctx $ do
    let (w,h) = (width ctx, height ctx)
    let x = w / 2
    let y = h / 2 - 10;
    let text = "Hello World!"
    font "30pt Calibri"
    textAlign "center"
    fillStyle "blue"
    fillText(text, x, y)

    TextMetrics w' <- measureText text
    font "20pt Calibri"
    textAlign "center"
    fillStyle "#555"
    fillText("(" <> Text.pack (show w') <> "px wide)", x, y + 40)

This yields a runtime error:

"Exception in blank-canvas application:"
user error (key "width" not present)
MeasureTextCrashes.hs: user error (key "width" not present)

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.