Comments (5)
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.
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.
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.
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.
Well, it is nice solution of the task =)
from libcanvas.
Related Issues (20)
- How to set direction of linear gradient HOT 1
- Typo in Source / Core / Context2D.js ln 509 HOT 1
- События мыши HOT 1
- Implementing Fire effect HOT 5
- Rotate Shape (Rectangle) HOT 1
- event.layerX and event.layerY are broken and deprecated in WebKit. HOT 3
- this.shape.hasPoint - ошибка HOT 2
- Fire callback when fifteen puzzle has been completed HOT 1
- getCellBy... не принимает массив в качестве аргумента HOT 1
- Optimizing performance HOT 3
- Optimize drawImage HOT 2
- Баг в Engines.Tile.Element HOT 1
- Line distance to - zero result
- LibCanvas.Shapes.Rectangle.hasPoint HOT 3
- style of lineCap
- [enhancement] Add missing bower.json.
- measureText не верно рассчитывает ширину текста HOT 3
- При вызове getContext('2d-libcanvas') нет возможности передать опции HOT 1
- Ошибка отрисовки в Chrome 43 в примере Dune 2 Map: thousands objects
- npm install и webpack
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libcanvas.