Skip to content

Conversation

@samedii
Copy link
Contributor

@samedii samedii commented May 28, 2025

No description provided.

expect(diffCount).toBeGreaterThan(0);
});

test("verifies gradient transformations are correct", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bold claim :D

const transform = ctx.getTransform();
expect(transform).toBeDefined();
} else {
// Should throw in fallback mode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this every being run?

// Check if the context supports transforms
const supportsTransforms = typeof _context.setTransform === "function";

if (supportsTransforms) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTransform with values has been supported on every major browser for 10-15 years and should be supported in headless as well. Not worth the extra maintenance cost

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think we should remove this but I wanted to test that this actually solves the problem before spending any more time on far canvas :)


- ✅ Supports `translate()`, `rotate()`, `scale()`, `transform()`, `setTransform()`, and `resetTransform()`
- ✅ Supports `getTransform()` to retrieve the current transformation matrix
- ✅ Leverages hardware-accelerated native Canvas transforms for better performance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mention of hardware-accelerated transforms might be a bit misleading here

notImplementedYet("createImageData(imagedata)");
// ImageData. This object is not scaled by canvas transforms directly.
// If the user passes an ImageData object, it implies screen pixels.
// Or does it? If it's from another far-canvas, it might represent world data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels a bit dangerous, better to throw than to have a don't know

const transformStack = [];

// Current user transform (starts as identity)
let userTransform = createMatrix();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let userTransform = createMatrix();
let transform = createMatrix();

No need to introduce a new concept "user", transform without prefix is normally used for "current", this "level" which it is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opengl uses the name "current". currentTransform makes sense

};

// Apply matrix to a point
const transformPoint = (matrix, x, y) => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used

};

// Invert a transform matrix
const invertMatrix = (m) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used

## The solution

Far Canvas is a wrapper around the HTML5 2D canvas API that avoids precision issues at large coordinates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that only {x, y, scale} supports big values and not transform it has to be super clear and kinda early that it's the case. Not sure where to put it

function render(ctx) {
images.forEach((image, i) => {
function render(ctx, currentFocusValue, isReference = false) {
if (isReference) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't figure out why this is clear for reference

image.data.onload = function () {
function render(ctx) {
images.forEach((image, i) => {
function render(ctx, currentFocusValue, isReference = false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should include at least some of the new functionality. Really hard to know if you have missed some test unless you look with your eyes. Most weird things I have found came from just looking at the example

@samedii
Copy link
Contributor Author

samedii commented Jun 4, 2025

These are good review comments ❤️ I will merge first and check that this works, if it does then I will get back to improving this

Otherwise, far canvas doesn't seem to be needed anymore for most browsers. It's only mac with chrome that is a problem

@samedii samedii merged commit c67db86 into main Jun 4, 2025
1 check passed
@samedii samedii deleted the new-functions branch June 4, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants