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

Fix typo TrianglesStrip -> TriangleStrip #2566

Merged
merged 6 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/shapes/vertices.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Draws vertices.
| Name | Type | Description |
| :--------- | :----------- | :----------------------- |
| vertices | `Point[]` | Vertices to draw |
| mode? | `VertexMode` | Can be `triangles`, `trianglesStrip` or `triangleFan`. Default is `triangles` |
| mode? | `VertexMode` | Can be `triangles`, `triangleStrip` or `triangleFan`. Default is `triangles` |
| indices? | `number[]` | Indices of the vertices that form the triangles. If not provided, the order of the vertices will be taken. Using this property enables you not to duplicate vertices. |
| textures | `Point[]`. | [Texture mapping](https://en.wikipedia.org/wiki/Texture_mapping). The texture is the shader provided by the paint. |
| colors? | `string[]` | Optional colors to be associated to each vertex |
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions package/src/renderer/__tests__/e2e/Vertices.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";

import { checkImage } from "../../../__tests__/setup";
import { Vertices } from "../../components";
import { surface, importSkia } from "../setup";

describe("Vertices", () => {
it("should draw a single triangle", async () => {
const { vec } = importSkia();
const vertices = [vec(64, 0), vec(128, 256), vec(0, 256)];
const colors = ["#61dafb", "#fb61da", "#dafb61"];
const img = await surface.draw(
<>
<Vertices vertices={vertices} colors={colors} />
</>
);
checkImage(img, "snapshots/vertices/vertices.png");
});
it("should draw a single triangle strip", async () => {
const { vec } = importSkia();
const vertices = [vec(0, 0), vec(128, 0), vec(0, 256), vec(128, 256)];
const colors = ["#61dafb", "#fb61da", "#dafb61", "cyan"];
const img = await surface.draw(
<>
<Vertices vertices={vertices} colors={colors} mode="triangleStrip" />
</>
);
checkImage(img, "snapshots/vertices/strip.png");
});
});
6 changes: 5 additions & 1 deletion package/src/skia/__tests__/Enums.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ describe("Enums", () => {
});
it("Should match VertexMode enums values with CanvasKit", () => {
const { CanvasKit } = setupSkia();
checkEnum(VertexMode, CanvasKit.VertexMode);
expect(VertexMode.TriangleFan).toBe(CanvasKit.VertexMode.TriangleFan.value);
expect(VertexMode.TriangleStrip).toBe(
CanvasKit.VertexMode.TrianglesStrip.value
);
expect(VertexMode.Triangles).toBe(CanvasKit.VertexMode.Triangles.value);
});
it("Should match Canvas enums values with CanvasKit", () => {
const { CanvasKit } = setupSkia();
Expand Down
2 changes: 1 addition & 1 deletion package/src/skia/types/Vertices/Vertices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SkJSIInstance } from "../JsiInstance";

export enum VertexMode {
Triangles,
TrianglesStrip,
TriangleStrip,
TriangleFan,
}

Expand Down
Loading