# Set size() from calculations within the sketch

**URL:** <https://discourse.processing.org/t/set-size-from-calculations-within-the-sketch/31594>\
**Category:** Processing.py\
**Created:** [August 6, 2021, 10:46am UTC](https://discourse.processing.org/t/set-size-from-calculations-within-the-sketch/31594 "2021-08-06T10:46:28Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [August 6, 2021, 11:57am UTC](https://discourse.processing.org/t/set-size-from-calculations-within-the-sketch/31594/3 "2021-08-06T11:57:47Z")

</div>

> [@LindowMan](#):
>
> … but it seems that **size()** has to be the first thing set in a sketch…

You can call **size()** anywhere within callback **settings()**: 💡

> **[settings() / Reference](https://processing.org/reference/settings_.html)**
>
> The settings() function is new with Processing 3.0. It's not needed in most sketches. It's only useful when it's absolutely necessary to define the parameters to size() with a variable. …

Here’s a link for an example on how to it on Processing’s Python Mode: 🐍

> [@Use a list to updatePixels()](https://discourse.processing.org/t/use-a-list-to-updatepixels/16268/10):
>
> filter() already got the GRAY type: [Py.Processing.org/reference/filter.html](http://Py.Processing.org/reference/filter.html) It converts all colors to 1 of the 256 grey tones. You state you require 6 shades instead. So we just need to use POSTERIZE after GRAY in order to get the desired effect: """ Gray Posterized PImage (v1.0.1) GoToLoop (2019-Dec-09) https://Discourse.Processing.org/t/use-a-list-to-updatepixels/16268/10 """ def hex6Digits(v): return str(hex(v, 6)) def mapToHex(container): return tuple(map(hex6Digits, container)) FIL…

---

_[View the full topic](https://discourse.processing.org/t/set-size-from-calculations-within-the-sketch/31594)._
