-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Updated readme and contributors for 2.0 branch (with attribution for image) #8557
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e7272bd
feat: add contributors png generator
skyash-dev 33aa721
ci: generate contributors.png on contributor updates
skyash-dev e5e0ee9
embed contributors.png in readme
skyash-dev ea749e8
update outdated avatar_url .all-contributorsrc
skyash-dev bc5c50a
chore: fix alt text, SVG/PNG typos, and remove unused deps
skyash-dev 6e5027c
Updated readme and contributors for 2.0 branch
ksen0 155a388
Merge branch 'dev-2.0' into readme-2.2.2
ksen0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Generate Contributors PNG | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - '.all-contributorsrc' | ||
|
|
||
| jobs: | ||
| build: | ||
| if: github.ref == 'refs/heads/main' && github.repository == 'processing/p5.js' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Install dependencies | ||
| run: npm install canvas | ||
|
|
||
| - name: Run contributors-png generator | ||
| run: node utils/contributors-png.js | ||
|
|
||
| - name: Reset all changes except contributors.png | ||
| run: | | ||
| git restore --staged . | ||
| git add contributors.png | ||
| git checkout -- . | ||
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| commit-message: "Update contributors.png from .all-contributorsrc" | ||
| branch: update-contributors-png | ||
| title: "chore: update contributors.png from .all-contributorsrc" | ||
| body: "This PR updates the contributors.png to reflect changes in .all-contributorsrc" | ||
| add-paths: contributors.png | ||
| token: ${{ secrets.ACCESS_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| const { createCanvas, loadImage } = require('canvas'); | ||
| const fs = require('fs'); | ||
|
|
||
| const data = fs.readFileSync('.all-contributorsrc', 'utf-8'); | ||
| const parsed = JSON.parse(data); | ||
| const contributors = parsed.contributors; | ||
|
|
||
| const AVATAR_SIZE = 50; | ||
| const GAP = 4; | ||
| const COLS = 40; | ||
| const ROWS = Math.ceil(contributors.length / COLS); | ||
|
|
||
| const width = COLS * AVATAR_SIZE + (COLS - 1) * GAP; | ||
| const height = ROWS * AVATAR_SIZE + (ROWS - 1) * GAP; | ||
|
|
||
| const canvas = createCanvas(width, height); | ||
| const ctx = canvas.getContext('2d'); | ||
|
|
||
| async function loadAvatar(url) { | ||
| try { | ||
| const res = await fetch(url); | ||
| if (!res.ok) throw new Error(`HTTP ${res.status}`); | ||
|
|
||
| const buffer = Buffer.from(await res.arrayBuffer()); | ||
| return await loadImage(buffer); | ||
| } catch (err) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| (async () => { | ||
| for (let i = 0; i < contributors.length; i++) { | ||
| const c = contributors[i]; | ||
|
|
||
| const col = i % COLS; | ||
| const row = Math.floor(i / COLS); | ||
|
|
||
| const x = col * (AVATAR_SIZE + GAP); | ||
| const y = row * (AVATAR_SIZE + GAP); | ||
|
|
||
| const img = await loadAvatar(c.avatar_url); | ||
|
|
||
| ctx.save(); | ||
| ctx.beginPath(); | ||
| ctx.arc( | ||
| x + AVATAR_SIZE / 2, | ||
| y + AVATAR_SIZE / 2, | ||
| AVATAR_SIZE / 2, | ||
| 0, | ||
| Math.PI * 2 | ||
| ); | ||
| ctx.clip(); | ||
|
|
||
| if (img) { | ||
| ctx.drawImage(img, x, y, AVATAR_SIZE, AVATAR_SIZE); | ||
| } | ||
| ctx.restore(); | ||
| } | ||
|
|
||
| fs.writeFileSync('contributors.png', canvas.toBuffer('image/png')); | ||
| })(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium