openframeworks / openframeworks/openFrameworks

ofSize

Open
#5,453 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

There was already a thread on ofSize, it's a few years old and the context of my throughs is a bit different.
https://github.com/openframeworks/openFrameworks/pull/1926

I noticed in my projects that I often use many variables for many projector or display sizes, mostly in pixels:

int projectorWidth = 42;
int projectorHeight = 42;
int displayWidth = 42;
int displayHeight = 42;
…

I wanted a better solution and started using ofPoint or ofVec2f. But it still doesn't feel right.
First of all you access it with .x and .y instead of .width and .height. And it uses floats instead of ints. Maybe ofSizei and ofSizef would be even useful to indicate what it's used for. I'm aware that ofSizei looks weird.

Such a type could not only be useful in projects where width and height is used but also by oF itself for example we could transform this:

void ofFbo::allocate(int width, int height, int internalformat, int numSamples)

to this:

void ofFbo::allocate(ofSize size, int internalformat, int numSamples)

I think this would make code cleaner, easier to read and understand.

ofSize projectorSize = ofSize(42, 42);
ofSize displaySize = ofSize(42, 42);

Any thoughts on this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the older ofSize discussion in pull request #1926 and the proposed ofSize/ofSizei/ofSizef API in this issue. Examine the existing ofFbo::allocate(int width, int height, int internalformat, int numSamples) entry point; done would require a decided size-type design and an agreed scope for adopting it.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.