Code Monkey home page Code Monkey logo

g9's People

Contributors

anderspitman avatar antiboredom avatar antimatter15 avatar bijection avatar joeltg 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

g9's Issues

Is it possible to check for which point is being dragged?

I'll take the example code from "using Max and Min to limit a point's range of motion" as a starting point:

 var initial = {
    x1: -100,
    x2: 0,
    x3: 100,
}

function render(data, ctx){
    var m = Math.max(Math.min(data.x2, data.x3 - 20), data.x1 + 20)
    ctx.point(m,0, {affects: ['x2']})
    ctx.point(data.x2,20, {affects: ['x2']})
    ctx.point(data.x1,0, {fill: 'red'})
    ctx.point(data.x3,0, {fill: 'red'})
}

When I drag point x1 or x3, there's nothing stopping me from dragging one point beyond the other.

That can be fixed by repeating the trick used for x2:

    var mMin = Math.min(data.x1, data.x3 - 40)
    var mMax = Math.max(data.x1 + 40, data.x3)
    var m = Math.max(Math.min(data.x2, mMax - 20), mMin + 20)
    ctx.point(m,0, {affects: ['x2']})
    ctx.point(data.x2,20, {affects: ['x2']})
    ctx.point(mMin,0, { affects: ['x1'], fill: 'red'})
    ctx.point(mMax,0, { affects: ['x3'], fill: 'red'})

Now x1 and x3 can't get closer than 40 pixels and stop when dragged into each other. Great! But then I thought: well, what would be really cool is if x1 and x3 would push each other when dragged into each other. Is there a way to do this?

The problem, as I see it, is that in order for this to work, the values of x1 and x3 would have to be mutually dependent on each other: if I drag x1 into x3, then the value x3 should depend on x1, but if I drag x3 into x1, the value of x1 should depend on x3. And for that to work I need to know which of the points is being dragged, but I don't see a way to check for that in the documentation. But maybe there's another trick and I just don't properly think in terms of constraint based programming yet?

Python port

Hi there,

I really love the g9.js demos! I think they convey how gradients work in such a nice and intuitive manner.

Just for fun I was playing with the idea of running a Torch-like library in the browser. I ported over most of the g9 code to python and ran it with AD (as opposed to finite-differences) -> https://srush.github.io/g9py/ . Not sure why this is better, but it might let you run models with tons of parameters. Let me know if this is okay.

Cheers!
Sasha

Unable to set size of draw target element?

Hi,

When I do an 'insertInto' call, the SVG which is created has its viewbox automatically set to some drawing size and offset. If I am rendering into a fixed size Div tag, how to I ensure that the resulting drawing is not arbitrarily re-scaled?

Thanks,
Forrest

License?

Hi all, thanks for this awesome library! May I ask what the license is for using it?

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.