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


Groups > comp.programming > #5995 > unrolled thread

javascript fillrect vs beginpath - why is that so?

Started byfir <profesor.fir@gmail.com>
First post2015-11-29 05:27 -0800
Last post2015-12-07 14:20 +0000
Articles 5 — 4 participants

Back to article view | Back to comp.programming


Contents

  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

#5995 — javascript fillrect vs beginpath - why is that so?

Fromfir <profesor.fir@gmail.com>
Date2015-11-29 05:27 -0800
Subjectjavascript fillrect vs beginpath - why is that so?
Message-ID<838b34ba-88fb-48a1-964e-67d0954c7ed3@googlegroups.com>
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?

[toc] | [next] | [standalone]


#5996

FromJulio Di Egidio <julio@diegidio.name>
Date2015-11-29 12:34 -0800
Message-ID<f7d924c1-5c4d-4665-8233-2ef700e6848a@googlegroups.com>
In reply to#5995
On Sunday, November 29, 2015 at 1:28:02 PM UTC, 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?

Generally, under HTML5 styles follow the CSS model.

Julio

[toc] | [prev] | [next] | [standalone]


#6010

Fromfir <profesor.fir@gmail.com>
Date2015-12-03 07:20 -0800
Message-ID<efbeb7e3-40aa-442b-acc3-e7d7fa6ba05b@googlegroups.com>
In reply to#5996
W dniu niedziela, 29 listopada 2015 21:34:11 UTC+1 użytkownik Julio Di Egidio napisał:
> On Sunday, November 29, 2015 at 1:28:02 PM UTC, 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?
> 
> Generally, under HTML5 styles follow the CSS model.
> 
> Julio

I see i was wrong there is simple firlect in canvas too (i thought its absent and that seemd strange/interesting to me)

[toc] | [prev] | [next] | [standalone]


#6026

FromÖö Tiib <ootiib@hot.ee>
Date2015-12-06 08:08 -0800
Message-ID<be0105fb-8bac-4bbd-b9b9-b7653b15a001@googlegroups.com>
In reply to#6010
On Thursday, 3 December 2015 17:20:32 UTC+2, fir  wrote:
> W dniu niedziela, 29 listopada 2015 21:34:11 UTC+1 użytkownik Julio Di Egidio napisał:
> > On Sunday, November 29, 2015 at 1:28:02 PM UTC, 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?
> > 
> > Generally, under HTML5 styles follow the CSS model.
> > 
> > Julio
> 
> I see i was wrong there is simple firlect in canvas too (i thought its absent and that seemd strange/interesting to me)

Perhaps 'ctx.fill' is meant for filling more complex shape than 'ctx.rect'
(or for filling several shapes at once). If you need to fill just single
rect then 'ctx.fillrect' is indeed more rational to use.

[toc] | [prev] | [next] | [standalone]


#6027

FromBartC <bc@freeuk.com>
Date2015-12-07 14:20 +0000
Message-ID<n444f7$aco$1@dont-email.me>
In reply to#5995
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web