Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #6027

Re: javascript fillrect vs beginpath - why is that so?

From BartC <bc@freeuk.com>
Newsgroups comp.programming
Subject Re: javascript fillrect vs beginpath - why is that so?
Date 2015-12-07 14:20 +0000
Organization A noiseless patient Spider
Message-ID <n444f7$aco$1@dont-email.me> (permalink)
References <838b34ba-88fb-48a1-964e-67d0954c7ed3@googlegroups.com>

Show all headers | View raw


On 29/11/2015 13:27, fir wrote:
> afail in js/canvas there is no call to fillrect, fillcircle etc method but instead something like
>
>    ctx.beginPath();
>    ctx.rect(brickX, brickY, brickWidth, brickHeight);
>    ctx.fillStyle = "#0095DD";
>    ctx.fill();
>    ctx.closePath();
>
> is used... it seems overal a bit weird decision.. dont you think so? (or maybe not?) at least it wonders me a bit, Why is that so - is there some rationale under it?

Why? It seems they decided to use a consistent approach to area fill: 
define an outline path first, then apply fill. Because in general, areas 
to be filled can be arbitrarily complex (maybe the rectangle is a hole 
within a bigger shape, or is an island within a hole).

There's nothing to stop you creating your own dedicated rectangle fill 
routine based around the above.

(Your sequence above doesn't seem quite right: you're filling the shape 
/then/ closing the path!)

-- 
Bartc

Back to comp.programming | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

javascript fillrect vs beginpath - why is that so? fir <profesor.fir@gmail.com> - 2015-11-29 05:27 -0800
  Re: javascript fillrect vs beginpath - why is that so? Julio Di Egidio <julio@diegidio.name> - 2015-11-29 12:34 -0800
    Re: javascript fillrect vs beginpath - why is that so? fir <profesor.fir@gmail.com> - 2015-12-03 07:20 -0800
      Re: javascript fillrect vs beginpath - why is that so? Öö Tiib <ootiib@hot.ee> - 2015-12-06 08:08 -0800
  Re: javascript fillrect vs beginpath - why is that so? BartC <bc@freeuk.com> - 2015-12-07 14:20 +0000

csiph-web