Giter Club home page Giter Club logo

Comments (5)

theshock avatar theshock commented on August 15, 2024

But we must close that path, because it can be mistakly continued by next element. But you always can create your own behavior own using processPath. Something like that:

renderTo: function (ctx) {
    // we should set "true" as second parameter, if we want no wrap
    this.path.processPath( ctx, true );
    // path is not closed, we can continue it
    ctx.lineTo(500, 500);
    ctx.closePath();
    ctx.fill( 'red' );
}

Do you like that way?

from libcanvas.

stevozilik avatar stevozilik commented on August 15, 2024

Why do you say 'must'? Do you suggest mistake by user, not closing paths properly and getting unexpected results, or some kind of inconsistencies across browsers? As far as I know not closing path works perfectly, across different browsers, and provides me what I need. Just to give you an example, I'm rendering a racing track, consisting of 3 different sectors, each in different color. Have a look here (track picture) http://liveracers.com/#/Views/LiveTiming/Simracing.cz/SR5%20-%20Mini,%20sk.%201 . That's what I need to replicate.

from libcanvas.

theshock avatar theshock commented on August 15, 2024

I mean first - "mistake by user".
If we are using createShaper - we can't control closing path & we dont know, who will be really use it next time.
Shaper was created for easy and inside (without interactions with other objects) vector operations and I recommend to create your own drawable object (maybe, based on Shaper) if you want some specific behavior.
Unfortunately, I cant watch your game based on Silverlite, because I am using Linux. Can you send me an screenshot?

from libcanvas.

stevozilik avatar stevozilik commented on August 15, 2024

There are many ways how to mess up your code, I think this would be a nice feature. Anyways I've done it by inheriting from path:

var Sector = atom.Class(
/** @Lends {LibCanvas.Shapes.Path.prototype} */
{
Extends: LibCanvas.Shapes.Path,
processPath: function (ctx, noWrap) {
if (!noWrap) ctx.beginPath();
this.each(function (method, args) {
ctx[method].apply(ctx, args);
});
return ctx;
}
});

and replacing

path = path.snapToPixel().build();

with

path = new Sector(path.snapToPixel());

works fine

this is what I'm after:

http://www.2shared.com/photo/f4vUyaZf/track.html

there are 4 paths - green (not closed), red (not closed), blue (not closed) and gray(closed)

from libcanvas.

theshock avatar theshock commented on August 15, 2024

Well, it is nice solution of the task =)

from libcanvas.

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.