Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradient stats #20

Open
LeaVerou opened this issue Jul 15, 2020 · 3 comments
Open

Gradient stats #20

LeaVerou opened this issue Jul 15, 2020 · 3 comments
Assignees
Labels
✅ Has algorithm (1/3) An implementable algorithm for how to measure this stat has been described in the issue ✅ Has JS (2/3) JS has been written to calculate this stat ✅ Has SQL (3/3) BigQuery SQL has been written to calculate this stat. proposed stat Proposed statistic to study Section: Images

Comments

@LeaVerou
Copy link
Owner

LeaVerou commented Jul 15, 2020

  • How commonly used is each type of gradient (linear, radial, conic)?
  • How many color stops do they use on average?
  • How many use hard stops? (two color stops at the same position)
  • How frequently are they used on properties other than background-image?
  • How frequently are midpoints used?
  • How frequently are two position color stops used?
@LeaVerou LeaVerou added the proposed stat Proposed statistic to study label Jul 15, 2020
@LeaVerou LeaVerou added ⚠️ Needs SQL Needs SQL to calculate this stat ⚠️ Needs algorithm ⚠️ Needs JS Needs JS to calculate this stat labels Aug 4, 2020
@LeaVerou
Copy link
Owner Author

Most of this seems to be fairly straightforward:

  1. Traverse values of background, background-image, cursor, list-style-image, border-image, content and custom properties
  2. Extract uses of *-gradient functions, and count which properties they were found in
  3. Counting color stops needs some light parsing. Counting number of arguments is not sufficient, often the first argument is params (e.g. to bottom right), also there are midpoints which are not a color stop. In fact, we may want to count usage of midpoints, I added it to the first post.
  4. Hard stops are very nontrivial in the general case, but we want to measure intentional usage, which tends to follow specific patterns: either the positions are identical (older method), or the second position is 0 (newer method).

@LeaVerou LeaVerou added ✅ Has algorithm (1/3) An implementable algorithm for how to measure this stat has been described in the issue and removed ⚠️ Needs algorithm labels Aug 22, 2020
@LeaVerou LeaVerou self-assigned this Sep 11, 2020
LeaVerou added a commit that referenced this issue Sep 11, 2020
Rel #20
Note: The color stop stats skip gradients with var() and calc() as those require proper parsing
@LeaVerou LeaVerou added ✅ Has JS (2/3) JS has been written to calculate this stat and removed ⚠️ Needs JS Needs JS to calculate this stat labels Sep 11, 2020
@rviscomi
Copy link
Collaborator

rviscomi commented Oct 2, 2020

Regarding "How many color stops do they use on average?" it's not clear what the value of avg_stops is in the JS and how it's intended to be aggregated, eg page-level stats.

I also see hints and max_stops properties in the JS but it's not clear which of the questions it's measuring.

And it's not clear which JS property should be used for "How frequently are midpoints used?".

{
	"functions": {
		"repeating-conic-gradient": 2,
		"linear-gradient": 1
	},
	"properties": {
		"background": 3
	},
	"two_positions": 0,
	"hints": 0,
	"hard_stops": 0,
	"max_stops": null,
	"avg_stops": null
}

@LeaVerou can you clarify?

@LeaVerou
Copy link
Owner Author

LeaVerou commented Oct 5, 2020

avg_stops is average number of color stops per gradient on the page. I just added a median, and the full list of counts, in case we'd prefer to aggregate via SQL only.

I see max stops is not in the list of questions indeed. I still think it would be fun to see the distribution, or perhaps the max number of stops across the entire corpus, it's the same kind of fun statistic as max z-index or max specificity. I've just added code that tracks the gradient code as well so we can see what gradient has the most color stops. I suspect it will be generated but eh. 🤷🏽‍♀️

Hints and midpoints are the same thing; the former is CSS spec terminology and the latter Photoshop terminology.

@rviscomi rviscomi added ✅ Has SQL (3/3) BigQuery SQL has been written to calculate this stat. and removed ⚠️ Needs SQL Needs SQL to calculate this stat labels Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Has algorithm (1/3) An implementable algorithm for how to measure this stat has been described in the issue ✅ Has JS (2/3) JS has been written to calculate this stat ✅ Has SQL (3/3) BigQuery SQL has been written to calculate this stat. proposed stat Proposed statistic to study Section: Images
Projects
None yet
Development

No branches or pull requests

2 participants