Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Our business is run on trust. We trust you will pay in advance.


devel / comp.lang.javascript / non linear clamp

SubjectAuthor
* non linear clampAndrew Poulos
`* Re: non linear clampJulio Di Egidio
 +- Re: non linear clampJulio Di Egidio
 `- Re: non linear clampAndrew Poulos

1
non linear clamp

<y4SdnaAiEJtqka78nZ2dnUU7-efNnZ2d@westnet.com.au>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17248&group=comp.lang.javascript#17248

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!nntp.westnet.com.au!news.westnet.com.au.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 04 Sep 2021 01:06:47 -0500
From: ap_prog@hotmail.com (Andrew Poulos)
Subject: non linear clamp
Newsgroups: comp.lang.javascript
X-Mozilla-News-Host: news://news.iinet.net.au
Date: Sat, 4 Sep 2021 16:06:45 +1000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-AU
Content-Transfer-Encoding: 7bit
Message-ID: <y4SdnaAiEJtqka78nZ2dnUU7-efNnZ2d@westnet.com.au>
Lines: 20
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 203.219.129.187
X-Trace: sv3-R65ZsDMmYHkqM3hJcOleXkv+t8+Al+uTBsFdB1T1ns8gn92d9tA84zwXpBlv5Zn7BmtihFdosN+Gwbi!0o+nybb/XFJuoHCD8WEiQtvw28O06t5bsiDEt6IxbTuvV8ge034Kle2P7g/0lRCEgZlMyQJGxZ8A!wdnJ/OMvkAgR+afN24+3/EQ=
X-Complaints-To: abuse@westnet.com.au
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1863
 by: Andrew Poulos - Sat, 4 Sep 2021 06:06 UTC

I'm using CSS clamp to set the font size of an element. The rule gets
added dynamically and in the CSS it looks like this

--font-size: calc(100wh / ${ratio});
font-size: clamp(10px, var(--font-size), 64px);

'ratio' is from the preset/initial window width divided by 16 (pixels, 1em).

As I change the window size the font size changes in a linear manner.

I would like it to grow faster (ie in a non-linear manner) while still
keeping the initial font size as 16 pixels? It seems to me that as the
window grows 'ratio' should smoothly get smaller but I'm unsure how to
do that:

--ratio: ?
--font-size: calc(100wh / var(--ratio));
font-size: clamp(10px, var(--font-size), 64px);

Andrew Poulos

Re: non linear clamp

<4bf34f13-0373-4b55-a1c7-76a817187f2fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17249&group=comp.lang.javascript#17249

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:ac8:4156:: with SMTP id e22mr3466369qtm.195.1630764319063;
Sat, 04 Sep 2021 07:05:19 -0700 (PDT)
X-Received: by 2002:a05:6830:83a:: with SMTP id t26mr3380743ots.383.1630764318710;
Sat, 04 Sep 2021 07:05:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Sat, 4 Sep 2021 07:05:18 -0700 (PDT)
In-Reply-To: <y4SdnaAiEJtqka78nZ2dnUU7-efNnZ2d@westnet.com.au>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.166; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.166
References: <y4SdnaAiEJtqka78nZ2dnUU7-efNnZ2d@westnet.com.au>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4bf34f13-0373-4b55-a1c7-76a817187f2fn@googlegroups.com>
Subject: Re: non linear clamp
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Sat, 04 Sep 2021 14:05:19 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 45
 by: Julio Di Egidio - Sat, 4 Sep 2021 14:05 UTC

On Saturday, 4 September 2021 at 08:06:59 UTC+2, Andrew Poulos wrote:
> I'm using CSS clamp to set the font size of an element. The rule gets
> added dynamically and in the CSS it looks like this
>
> --font-size: calc(100wh / ${ratio});

What's "wh"? I can only guess but I cannot find it documented anywhere, and I cannot guess how it actually works since windows aren't just square...

> font-size: clamp(10px, var(--font-size), 64px);
>
> 'ratio' is from the preset/initial window width divided by 16 (pixels, 1em).
>
> As I change the window size the font size changes in a linear manner.
>
> I would like it to grow faster (ie in a non-linear manner) while still
> keeping the initial font size as 16 pixels? It seems to me that as the
> window grows 'ratio' should smoothly get smaller but I'm unsure how to
> do that:
>
> --ratio: ?
> --font-size: calc(100wh / var(--ratio));
> font-size: clamp(10px, var(--font-size), 64px);

Your font-size formula at present looks like:

fs(t) := fs_0 * wh(t) / wh_0

with wh(0) = wh_0, hence fs(0) = fs_0. In fact, fs(t) = fs_0 for all t such that wh(t) = wh_0, i.e. the "base" font size is the 16 pixels.

Now you want it non-linear, to grow/shrink ever faster when the window is resized (if I got you correctly).

I think the easiest approach (in general, to make it non-linear) is to choose an appropriate non-linear function to be applied to the linear result. Say 'nl' is the nonlinear function, chosen such that nl(0) = 0, then the new formula looks like:

fs'(t) := nl( fs(t) - fs_0 ) + fs_0

Now, to get the effect you desire, e.g. take the cubic nl(x) = a * x^3, with 'a' a positive scaling factor, whence:

fs_cubic(t) := a * (fs(t) - fs_0)^3 + fs_0.

That has still the property that fs_cubic(t) = fs_0 for all t such that wh(t) = wh_0, i.e. the "base" font size remains 16 pixels.

Since you want it to grow/shrink ever faster, if not (odd) polynomials then exponentials...

HTH and that I have not made any (serious) mistakes, I haven't tried any of it.

Julio

Re: non linear clamp

<28ed2673-40a5-4e94-91a1-265d64b91d34n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17250&group=comp.lang.javascript#17250

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a0c:aa8d:: with SMTP id f13mr4065136qvb.31.1630764798857;
Sat, 04 Sep 2021 07:13:18 -0700 (PDT)
X-Received: by 2002:a05:6808:a82:: with SMTP id q2mr2765102oij.100.1630764798618;
Sat, 04 Sep 2021 07:13:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Sat, 4 Sep 2021 07:13:18 -0700 (PDT)
In-Reply-To: <4bf34f13-0373-4b55-a1c7-76a817187f2fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.166; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.166
References: <y4SdnaAiEJtqka78nZ2dnUU7-efNnZ2d@westnet.com.au> <4bf34f13-0373-4b55-a1c7-76a817187f2fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <28ed2673-40a5-4e94-91a1-265d64b91d34n@googlegroups.com>
Subject: Re: non linear clamp
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Sat, 04 Sep 2021 14:13:18 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 49
 by: Julio Di Egidio - Sat, 4 Sep 2021 14:13 UTC

On Saturday, 4 September 2021 at 16:05:23 UTC+2, Julio Di Egidio wrote:
> On Saturday, 4 September 2021 at 08:06:59 UTC+2, Andrew Poulos wrote:
> > I'm using CSS clamp to set the font size of an element. The rule gets
> > added dynamically and in the CSS it looks like this
> >
> > --font-size: calc(100wh / ${ratio});
> What's "wh"? I can only guess but I cannot find it documented anywhere, and I cannot guess how it actually works since windows aren't just square...
> > font-size: clamp(10px, var(--font-size), 64px);
> >
> > 'ratio' is from the preset/initial window width divided by 16 (pixels, 1em).
> >
> > As I change the window size the font size changes in a linear manner.
> >
> > I would like it to grow faster (ie in a non-linear manner) while still
> > keeping the initial font size as 16 pixels? It seems to me that as the
> > window grows 'ratio' should smoothly get smaller but I'm unsure how to
> > do that:
> >
> > --ratio: ?
> > --font-size: calc(100wh / var(--ratio));
> > font-size: clamp(10px, var(--font-size), 64px);
> Your font-size formula at present looks like:
>
> fs(t) := fs_0 * wh(t) / wh_0
>
> with wh(0) = wh_0, hence fs(0) = fs_0. In fact, fs(t) = fs_0 for all t such that wh(t) = wh_0, i.e. the "base" font size is the 16 pixels.
>
> Now you want it non-linear, to grow/shrink ever faster when the window is resized (if I got you correctly).
>
> I think the easiest approach (in general, to make it non-linear) is to choose an appropriate non-linear function to be applied to the linear result. Say 'nl' is the nonlinear function, chosen such that nl(0) = 0, then the new formula looks like:
>
> fs'(t) := nl( fs(t) - fs_0 ) + fs_0
>
> Now, to get the effect you desire, e.g. take the cubic nl(x) = a * x^3, with 'a' a positive scaling factor, whence:
>
> fs_cubic(t) := a * (fs(t) - fs_0)^3 + fs_0.
>
> That has still the property that fs_cubic(t) = fs_0 for all t such that wh(t) = wh_0, i.e. the "base" font size remains 16 pixels.

In fact, that property already holds for the fs'(t) above.

> Since you want it to grow/shrink ever faster, if not (odd) polynomials then exponentials...
>
> HTH and that I have not made any (serious) mistakes, I haven't tried any of it.

BTW, to test these "transformations", something like <https://www.desmos.com/calculator> may be your friend.

Have fun,

Julio

Re: non linear clamp

<Qo6dnVJhBtCEmKn8nZ2dnUU7-U_NnZ2d@westnet.com.au>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17251&group=comp.lang.javascript#17251

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!nntp.westnet.com.au!news.westnet.com.au.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 04 Sep 2021 18:45:29 -0500
Subject: Re: non linear clamp
Newsgroups: comp.lang.javascript
References: <y4SdnaAiEJtqka78nZ2dnUU7-efNnZ2d@westnet.com.au>
<4bf34f13-0373-4b55-a1c7-76a817187f2fn@googlegroups.com>
From: ap_prog@hotmail.com (Andrew Poulos)
Date: Sun, 5 Sep 2021 09:45:27 +1000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <4bf34f13-0373-4b55-a1c7-76a817187f2fn@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-AU
Content-Transfer-Encoding: 7bit
Message-ID: <Qo6dnVJhBtCEmKn8nZ2dnUU7-U_NnZ2d@westnet.com.au>
Lines: 52
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 203.219.129.187
X-Trace: sv3-modv0bOz9+qmpOB4iU27/Qiwr7dCEEUtCkGryeHn8hIcjpI1mbQJUgYOPN03mWRalAPYSlvvRsl0+2j!4nOuERCXcK4y8OKfsL37+hIyZc5VLPGcXBH4HmHUFut/kD6Az1ehr+oH2lKM4OgiRJl/aC5FyvDf!2DnDppi3Nlyb9q7v21zIspA=
X-Complaints-To: abuse@westnet.com.au
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 3613
 by: Andrew Poulos - Sat, 4 Sep 2021 23:45 UTC

On 5/09/2021 12:05 am, Julio Di Egidio wrote:
> On Saturday, 4 September 2021 at 08:06:59 UTC+2, Andrew Poulos wrote:
>> I'm using CSS clamp to set the font size of an element. The rule gets
>> added dynamically and in the CSS it looks like this
>>
>> --font-size: calc(100wh / ${ratio});
>
> What's "wh"? I can only guess but I cannot find it documented anywhere, and I cannot guess how it actually works since windows aren't just square...

Dang, it's a typo. It should've been vw.

>> font-size: clamp(10px, var(--font-size), 64px);
>>
>> 'ratio' is from the preset/initial window width divided by 16 (pixels, 1em).
>>
>> As I change the window size the font size changes in a linear manner.
>>
>> I would like it to grow faster (ie in a non-linear manner) while still
>> keeping the initial font size as 16 pixels? It seems to me that as the
>> window grows 'ratio' should smoothly get smaller but I'm unsure how to
>> do that:
>>
>> --ratio: ?
>> --font-size: calc(100wh / var(--ratio));
>> font-size: clamp(10px, var(--font-size), 64px);
>
> Your font-size formula at present looks like:
>
> fs(t) := fs_0 * wh(t) / wh_0
>
> with wh(0) = wh_0, hence fs(0) = fs_0. In fact, fs(t) = fs_0 for all t such that wh(t) = wh_0, i.e. the "base" font size is the 16 pixels.
>
> Now you want it non-linear, to grow/shrink ever faster when the window is resized (if I got you correctly).
>
> I think the easiest approach (in general, to make it non-linear) is to choose an appropriate non-linear function to be applied to the linear result. Say 'nl' is the nonlinear function, chosen such that nl(0) = 0, then the new formula looks like:
>
> fs'(t) := nl( fs(t) - fs_0 ) + fs_0
>
> Now, to get the effect you desire, e.g. take the cubic nl(x) = a * x^3, with 'a' a positive scaling factor, whence:
>
> fs_cubic(t) := a * (fs(t) - fs_0)^3 + fs_0.
>
> That has still the property that fs_cubic(t) = fs_0 for all t such that wh(t) = wh_0, i.e. the "base" font size remains 16 pixels.
>
> Since you want it to grow/shrink ever faster, if not (odd) polynomials then exponentials...
>
> HTH and that I have not made any (serious) mistakes, I haven't tried any of it.

Thanks, it's a great start for me. I think I can do it from here.

Andrew Poulos


devel / comp.lang.javascript / non linear clamp

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor