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


Groups > comp.lang.javascript > #23948 > unrolled thread

Another weirdness on structural level?

Started byjonas.thornvall@gmail.com
First post2014-04-25 23:09 -0700
Last post2014-04-30 08:36 -0700
Articles 8 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  Another weirdness on structural level? jonas.thornvall@gmail.com - 2014-04-25 23:09 -0700
    Re: Another weirdness on structural level? jonas.thornvall@gmail.com - 2014-04-25 23:28 -0700
    Re: Another weirdness on structural level? jonas.thornvall@gmail.com - 2014-04-25 23:51 -0700
      Re: Another weirdness on structural level? jonas.thornvall@gmail.com - 2014-04-26 03:21 -0700
    Re: Another weirdness on structural level? jonas.thornvall@gmail.com - 2014-04-27 01:12 -0700
      Re: Another weirdness on structural level? jonas.thornvall@gmail.com - 2014-04-28 02:56 -0700
      Re: Another weirdness on structural level? Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-30 15:29 +0200
        Re: Another weirdness on structural level? jonas.thornvall@gmail.com - 2014-04-30 08:36 -0700

#23948 — Another weirdness on structural level?

Fromjonas.thornvall@gmail.com
Date2014-04-25 23:09 -0700
SubjectAnother weirdness on structural level?
Message-ID<74a63d4a-20fe-450e-96fa-2a256cc8720f@googlegroups.com>
My printouts A and B have different font size,type?

As i understand it font is passed as an argument, parameter or a property of object fillText?

But i do not want to toggle these things in loop?

Can i create fillText instances with different properties like fillText[i] where it uses one font size style and fillText [i+1] Another?

Maybe this already implemented but since i work by study example and have not seen any, i guess this not the case so how should one handle these thing when (Printing?) to canvas.

[toc] | [next] | [standalone]


#23951

Fromjonas.thornvall@gmail.com
Date2014-04-25 23:28 -0700
Message-ID<455e6383-5d5f-43a8-98cc-054ce386ce71@googlegroups.com>
In reply to#23948
Den lördagen den 26:e april 2014 kl. 08:09:55 UTC+2 skrev jonas.t...@gmail.com:
> My printouts A and B have different font size,type?
> 
> 
> 
> As i understand it font is passed as an argument, parameter or a property of object fillText?
> 
> 
> 
> But i do not want to toggle these things in loop?
> 
> 
> 
> Can i create fillText instances with different properties like fillText[i] where it uses one font size style and fillText [i+1] Another?
> 
> 
> 
> Maybe this already implemented but since i work by study example and have not seen any, i guess this not the case so how should one handle these thing when (Printing?) to canvas.

name.fillText
nametwo.fillText

?

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


#23952

Fromjonas.thornvall@gmail.com
Date2014-04-25 23:51 -0700
Message-ID<ebc8ff2d-3a31-447e-b5c2-5474a0f06a21@googlegroups.com>
In reply to#23948
Den lördagen den 26:e april 2014 kl. 08:09:55 UTC+2 skrev jonas.t...@gmail.com:
> My printouts A and B have different font size,type?
> 
> 
> 
> As i understand it font is passed as an argument, parameter or a property of object fillText?
> 
> 
> 
> But i do not want to toggle these things in loop?
> 
> 
> 
> Can i create fillText instances with different properties like fillText[i] where it uses one font size style and fillText [i+1] Another?
> 
> 
> 
> Maybe this already implemented but since i work by study example and have not seen any, i guess this not the case so how should one handle these thing when (Printing?) to canvas.

I can see a way to do this using var ctx=c.getContext("2d");
But it seem to encompass alot more features then those of fillText and maybe take up Resources?

So should create a different context for each font configuration, it seem a bit weird to me, but then again i really have no idea about how much context really stored?

If it doesn't allocate and slow down script completly i see no problem?

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


#23953

Fromjonas.thornvall@gmail.com
Date2014-04-26 03:21 -0700
Message-ID<f428b958-a67c-45b6-90c2-db031b12c7bf@googlegroups.com>
In reply to#23952
Den lördagen den 26:e april 2014 kl. 08:51:19 UTC+2 skrev jonas.t...@gmail.com:
> Den lördagen den 26:e april 2014 kl. 08:09:55 UTC+2 skrev jonas.t...@gmail.com:
> 
> > My printouts A and B have different font size,type?
> 
> > 
> 
> > 
> 
> > 
> 
> > As i understand it font is passed as an argument, parameter or a property of object fillText?
> 
> > 
> 
> > 
> 
> > 
> 
> > But i do not want to toggle these things in loop?
> 
> > 
> 
> > 
> 
> > 
> 
> > Can i create fillText instances with different properties like fillText[i] where it uses one font size style and fillText [i+1] Another?
> 
> > 
> 
> > 
> 
> > 
> 
> > Maybe this already implemented but since i work by study example and have not seen any, i guess this not the case so how should one handle these thing when (Printing?) to canvas.
> 
> 
> 
> I can see a way to do this using var ctx=c.getContext("2d");
> 
> But it seem to encompass alot more features then those of fillText and maybe take up Resources?
> 
> 
> 
> So should create a different context for each font configuration, it seem a bit weird to me, but then again i really have no idea about how much context really stored?
> 
> 
> 
> If it doesn't allocate and slow down script completly i see no problem?

No that did not work it seem the canvas only allow one context all printout changed font size.

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


#23969

Fromjonas.thornvall@gmail.com
Date2014-04-27 01:12 -0700
Message-ID<917842d0-d50a-457f-82de-06a04d086ab8@googlegroups.com>
In reply to#23948
Den lördagen den 26:e april 2014 kl. 08:09:55 UTC+2 skrev jonas.t...@gmail.com:
> My printouts A and B have different font size,type?
> 
> 
> 
> As i understand it font is passed as an argument, parameter or a property of object fillText?
> 
> 
> 
> But i do not want to toggle these things in loop?
> 
> 
> 
> Can i create fillText instances with different properties like fillText[i] where it uses one font size style and fillText [i+1] Another?
> 
> 
> 
> Maybe this already implemented but since i work by study example and have not seen any, i guess this not the case so how should one handle these thing when (Printing?) to canvas.

It seem reasonable to assume that fillText would be an object or multidimensioned array with attributes where you can store different layouts of size and fonts.

But it doesn't seem to be?

So how is people thinking when they create program languages. Is it really correct that i should have to toggle the context ctx.font in loop 2 million times to be able draw multiple objects with text?

Or am i totally missunderstanding context and filltext?
Or can one have attributes on fillText? font and size, but then fillText would need to be an multidimensional array or an object?

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


#23985

Fromjonas.thornvall@gmail.com
Date2014-04-28 02:56 -0700
Message-ID<88b44e40-d117-4653-865f-46297c538e37@googlegroups.com>
In reply to#23969
Den söndagen den 27:e april 2014 kl. 10:12:12 UTC+2 skrev jonas.t...@gmail.com:
> Den lördagen den 26:e april 2014 kl. 08:09:55 UTC+2 skrev jonas.t...@gmail.com:
> 
> > My printouts A and B have different font size,type?
> 
> > 
> 
> > 
> 
> > 
> 
> > As i understand it font is passed as an argument, parameter or a property of object fillText?
> 
> > 
> 
> > 
> 
> > 
> 
> > But i do not want to toggle these things in loop?
> 
> > 
> 
> > 
> 
> > 
> 
> > Can i create fillText instances with different properties like fillText[i] where it uses one font size style and fillText [i+1] Another?
> 
> > 
> 
> > 
> 
> > 
> 
> > Maybe this already implemented but since i work by study example and have not seen any, i guess this not the case so how should one handle these thing when (Printing?) to canvas.
> 
> 
> 
> It seem reasonable to assume that fillText would be an object or multidimensioned array with attributes where you can store different layouts of size and fonts.
> 
> 
> 
> But it doesn't seem to be?
> 
> 
> 
> So how is people thinking when they create program languages. Is it really correct that i should have to toggle the context ctx.font in loop 2 million times to be able draw multiple objects with text?
> 
> 
> 
> Or am i totally missunderstanding context and filltext?
> 
> Or can one have attributes on fillText? font and size, but then fillText would need to be an multidimensional array or an object?

Could someone just tell me if what i am trying to achieve is possible in javascript?

e.g pre define sets storing size and font without having to switch with set ctx.font everytime i change?

What i would like and maybe should had been implemented in the first place.
And it is never to late to change ;D
 
ctx.font[1] = v + "pt Arial";
ctx.font[2] = v + "pt Courier";

fillText.font[1]=('Hello world!', 40, 100);
fillText.font[2]=('Hello world!', 40, 100);

Here is a nice example i found on the web, but it does not quite achieve what i try to do.

function boot() {
  draw(document.getElementById('canvas').getContext('2d'));
  draw(document.getElementById('vmlcanvas').getContext('2d'));
}
function draw(ctx) {
  var w = 500, h = 800;
  var fillText = "AWawあ漢字!?@";
  ctx.fillStyle     = "blue";
  ctx.textBaseline  = "top";

  grid(ctx, w, h, 10, 5, "SkyBlue", "steelblue");

  var i, v, dim, txt,
      ary = [6,7,8,9,10,11,12,14,16,18,20,24,28,32,36,40,48,58,64,72,84];
  for (i in ary) {
    v = ary[i];
    txt = v + "pt;" + fillText;
    ctx.font = v + "pt Arial";
    ctx.fillText(txt, 10, i * 35 + 10);
  }
}
function grid(ctx, w, h, size, unit, color, color2) {
  var x, y, i, j;
  for (i = 0, x = size; x < w; ++i, x += size) {
    ctx.beginPath();
    ctx.strokeStyle = (i % unit) ? color : color2;
    ctx.moveTo(x, 0);
    ctx.lineTo(x, h);
    ctx.stroke();
    ctx.closePath();
  }
  for (j = 0, y = size; y < h; ++j, y += size) {
    ctx.beginPath();
    ctx.strokeStyle = (j % unit) ? color : color2;
    ctx.moveTo(0, y);
    ctx.lineTo(w, y);
    ctx.stroke();
    ctx.closePath();
  }
}

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


#23992

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-04-30 15:29 +0200
Message-ID<5360face$0$6720$9b4e6d93@newsspool3.arcor-online.net>
In reply to#23969
jonas.thornvall@gmail.com wrote:

> Den lördagen den 26:e april 2014 kl. 08:09:55 UTC+2 skrev
> jonas.t...@gmail.com:
>> My printouts A and B have different font size,type?
>> 
>> As i understand it font is passed as an argument, parameter or a
>> property of object fillText?

No.  font is a property and fillText() is a method of the context object
(actually, of the CanvasRenderingContext2D interface).

>> But i do not want to toggle these things in loop?

Why not?

>> Can i create fillText instances with different properties like
>> fillText[i] where it uses one font size style and fillText [i+1]
>> Another?

As fillText() is a function, and functions may have properties in
conforming ECMAScript implementations, you can set properties--however,
these will most likely simply being ignored when you call the fillText()
method.  And anyway, augmenting host objects might have unexpected effects.

>> Maybe this already implemented but since i work by study example
>> and have not seen any, i guess this not the case so how should one
>> handle these thing when (Printing?) to canvas.

You could group the fillText() calls to print all texts with the same
font first, then switch the font etc.

> It seem reasonable to assume that fillText would be an object or
> multidimensioned array with attributes where you can store different
> layouts of size and fonts.

fillText() is a method.  You might confuse it with the font property.

> But it doesn't seem to be?
> 
> So how is people thinking when they create program languages. Is it
> really correct that i should have to toggle the context ctx.font in
> loop 2 million times to be able draw multiple objects with text?

Actually, neither the HTML canvas is part of a programming language, nor
is the CanvasRenderingContext2D interface.

-- 
Christoph M. Becker

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


#23993

Fromjonas.thornvall@gmail.com
Date2014-04-30 08:36 -0700
Message-ID<0152461a-5f22-40ca-b156-2c41bb0695d5@googlegroups.com>
In reply to#23992
Den onsdagen den 30:e april 2014 kl. 15:29:54 UTC+2 skrev Christoph Michael Becker:
> jonas.thornvall@gmail.com wrote:
> 
> 
> 
> > Den l�rdagen den 26:e april 2014 kl. 08:09:55 UTC+2 skrev
> 
> > jonas.t...@gmail.com:
> 
> >> My printouts A and B have different font size,type?
> 
> >> 
> 
> >> As i understand it font is passed as an argument, parameter or a
> 
> >> property of object fillText?
> 
> 
> 
> No.  font is a property and fillText() is a method of the context object
> 
> (actually, of the CanvasRenderingContext2D interface).
> 
> 
> 
> >> But i do not want to toggle these things in loop?
> 
> 
> 
> Why not?
> 
> 
> 
> >> Can i create fillText instances with different properties like
> 
> >> fillText[i] where it uses one font size style and fillText [i+1]
> 
> >> Another?
> 
> 
> 
> As fillText() is a function, and functions may have properties in
> 
> conforming ECMAScript implementations, you can set properties--however,
> 
> these will most likely simply being ignored when you call the fillText()
> 
> method.  And anyway, augmenting host objects might have unexpected effects.
> 
> 
> 
> >> Maybe this already implemented but since i work by study example
> 
> >> and have not seen any, i guess this not the case so how should one
> 
> >> handle these thing when (Printing?) to canvas.
> 
> 
> 
> You could group the fillText() calls to print all texts with the same
> 
> font first, then switch the font etc.
> 
> 
> 
> > It seem reasonable to assume that fillText would be an object or
> 
> > multidimensioned array with attributes where you can store different
> 
> > layouts of size and fonts.
> 
> 
> 
> fillText() is a method.  You might confuse it with the font property.
> 
> 
> 
> > But it doesn't seem to be?
> 
> > 
> 
> > So how is people thinking when they create program languages. Is it
> 
> > really correct that i should have to toggle the context ctx.font in
> 
> > loop 2 million times to be able draw multiple objects with text?
> 
> 
> 
> Actually, neither the HTML canvas is part of a programming language, nor
> 
> is the CanvasRenderingContext2D interface.
> 
> 
> 
> -- 
> 
> Christoph M. Becker

So you advocate separate loops or storing the cordinates. I Think it will be storing although it seem weird. Why isn't font used to stor layouts? And why isn't those store layout passed as an argument to filltext instead of specify Changes, it seem it would be more effective.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web