Giter VIP home page Giter VIP logo

Comments (5)

stachlewski avatar stachlewski commented on May 27, 2024

It's not a bad library. Lacks documentation though. Trying to learn from the demos to understand what properties do what is hard. The weird thing is the "mimics" instead of some matrix based system and groups. I still don't know how to make a pack of objects with a common coordinate system, like having a line drawn relative to a box. You can mimic the start, but not the end of the line and it still requires you to set lockTo, mimic, useMimicStart, addOwnStartToMimic....

from scrawl-canvas.

KaliedaRik avatar KaliedaRik commented on May 27, 2024

It's not a bad library.

Thank you!

Lacks documentation though. Trying to learn from the demos to understand what properties do what is hard.

In addition to the Docs (annotated code) and Demos (which is the testing suite), there's a Learning to use SC section on the website with detailed information on doing things the SC way. There's also a How Do I... section which I want to build into a sort of cookbook on how to do specific things with SC.

The weird thing is the "mimics" instead of some matrix based system and groups. I still don't know how to make a pack of objects with a common coordinate system, like having a line drawn relative to a box. You can mimic the start, but not the end of the line and it still requires you to set lockTo, mimic, useMimicStart, addOwnStartToMimic....

"Mimic" has its uses, but for most positioning-by-reference needs you'll want to use "pivot" and "path" positioning. Lesson 3 covers some of the basics for pivot positioning; Lesson 12 includes a very brief introduction on how to animate text along a path.

SC doesn't use a "traditional" scene graph for layout. See this How Do I article for a broad overview of the approach I've taken.

from scrawl-canvas.

stachlewski avatar stachlewski commented on May 27, 2024

So how do I exactly draw a horizontal line (top border of the box sans the first 10px) in the example below?
I can see I have to use "offsetX" instead of "startX" in the line definition.
But what is the meaning of endX and endY in this situation, I have no idea. Perhaps I should draw my line in some other way?

What I meant when I said "lacks documentation" I meant a reference. If an object has a property or a function argument it should be documented.

let block = scrawl.makeBlock({
  name: "box",
  startX: 100,
  startY: 100,
  width: 100,
  height: 100,
  fillStyle: "#888899",
  globalAlpha: 0.8,
});

let line = scrawl.makeLine({
  name: 'path-line',
  strokeStyle: 'black',
  method: 'draw',
  offsetX: 10,
  offsetY: 0,
  endX: 100,
  endY: 0,
  handleX: 'left',
  handleY: 'top',
  lockTo: "pivot",
  pivot: "box",
});

from scrawl-canvas.

KaliedaRik avatar KaliedaRik commented on May 27, 2024

What I meant when I said "lacks documentation" I meant a reference.

Fair comment. I don't have a "formal" reference set of docs (such as is produced by JSDoc), but I do comment extensively in the code base, from which the SC documentation is generated. All attributes are defined and explained there - for instance see the Line factory docs page which includes links to the various mixin files where all of the line entity's attributes get detailed.

So how do I exactly draw a horizontal line (top border of the box sans the first 10px) in the example below?

For a static scene, we can do it with two renders:

// First render - establish the entitys
let block = scrawl.makeBlock({
  name: "box",
  startX: 100,
  startY: 100,
  width: 100,
  height: 100,
  fillStyle: "#888899",
  globalAlpha: 0.8,
});

let line = scrawl.makeLine({
  name: 'path-line',
  strokeStyle: 'black',
  method: 'draw',
  endX: 90,
});

scrawl.render();

// Second render
line.set({
  lockTo: "pivot",
  pivot: "box",
  offsetX: 10,
});

// Now when the block moves, the line will move with it
block.set({
  startX: 200,
  startY: 200,
});

scrawl.render();

... Or if you're using an animation loop:

scrawl.makeRender({

    name: "demo",
    target: canvas,

    // this hook will only run once, after the first Display cycle completes
    afterCreated: () => {

        line.set({
          lockTo: "pivot",
          pivot: "box",
          offsetX: 10,
        });
    }
});

from scrawl-canvas.

KaliedaRik avatar KaliedaRik commented on May 27, 2024

Closing this issue as the Chrome UI Fund never responded (not even to say "no")

from scrawl-canvas.

Related Issues (11)

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.