Giter Club home page Giter Club logo

prototypo-canvas's Introduction

prototypo-canvas

Prototypo canvas-rendering component

prototypo-canvas's People

Contributors

franzpoize avatar louisremi avatar aldrian avatar martinbolot avatar yorunohikage avatar yannickmathey avatar

Stargazers

Chris Hart avatar  avatar Blake Bowen avatar Michael Anthony avatar

Watchers

 avatar James Cloos avatar  avatar  avatar Michael Anthony avatar  avatar  avatar  avatar

Forkers

martinbolot

prototypo-canvas's Issues

high zoom out crashes the app

console:

plumin.js:15450 >> Uncaught TypeError: Cannot read property '_transformBounds' of null
prototypo-canvas.js:463 >>> Uncaught TypeError: Cannot read property 'subtract' of null

capture d ecran 2015-07-24 a 17 10 58

Can we set a min value to zoom?

Reflection on the new canvas API

The idea is to develop a new canvas API that would be immediate and functionnal. By immediate it is meant that there would be the least amount of data retention in the canvas library. Prototypo-canvas will handle the raf itself.

The canvas library should provide a drawing API to draw curves, lines, ellipsises, rectangle and text. It should also let us declare which element are to be interacted with and it should provide a way to determine the hotness of an element (ie which element is currently under the mouse). It should also provide the mouse position on the canvas.

Here is an exemple of what a raf iteration would look like:

function rafIteration() {
    setCamera(point, zoom);
    _.each(contours, (contour) => {
        drawContour(contour.controlPoints, undefined, letterFillColor);
    });

    if (drawSkeleton) {
       contours.getSkeleton(contours.getSkeletons(), (skeleton) => {
           drawRectangleFromCenterSize(skeleton.node, skeletonSize, skeletonStrokeColor, undefined, 'skeleton');
           drawLine(skeleton.expandedTo[0], skeleton.expandedTo[1], skeletonRibStrokeColor, undefined);
       });
    }

    const hotItem = getHotInteractiveItem();
    
    switch(hotItem.type) {
        case 'skeleton':
            doSomethingDependingOnState();
            break;
    }
}

Drawing API proposal

drawContour(listOfBezier, strokeColor, fillColor, interactionType)
drawBezierCurve(bezier, strokeColor, fillColor, interactionType)
drawLine(point, point, strokeColor, fillColor, interactionType)
drawRectangleFromCenterSize(point, size, strokeColor, fillColor, interactionType)
drawCircle(point, radius, strokeColor, fillColor, interactionType)
drawText(text, point, textSize, textColor, interactionType)

Drawing API traits

The API should mostly rely on traits (meaning arguments must fullfil a non declarative interface). Here are the differents traits:
listOfBezier = Array<bezier>
bezier= Array[4]<point>
point= {x: number, y: number}
strokeColor = fillColor = textColor = string of format rgba(number, number, number, number)

Interaction API proposal

 doSomethingDependingOnState();

=======WIP=======

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.