Skip to content

Commit

Permalink
Bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
acamposuribe committed Jan 19, 2024
1 parent bf34262 commit 1b7fedd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Alternatively, you can link to a `p5.brush.js` file hosted online. All versions

```html
<!-- Online version of p5.brush -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/p5.brush.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/p5.brush.js"></script>
```

### Install with NPM and other modular-based apps
Expand Down
2 changes: 1 addition & 1 deletion dist/p5.brush.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<title>p5.brush.js Example</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/p5.brush.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/p5.brush.js"></script>
<link rel="stylesheet" href="./style.css">
</head>
<body>
Expand Down
5 changes: 5 additions & 0 deletions example/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ function setup () {
}
*/



brush.noStroke()

brush.gravity(0,height)

brush.fill("black", 60)

brush.bleed(0.3)
brush.beginShape(0.5)
brush.vertex(50,50)
Expand All @@ -125,6 +128,7 @@ function setup () {

function draw() {

/*
//background("#e2e7dc")
translate(-width/2,-height/2)
strokeWeight(2)
Expand All @@ -140,6 +144,7 @@ function draw() {
brush.endShape(CLOSE)
noLoop()
*/
}

function mouseDragged() {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p5.brush",
"version": "1.1.0",
"version": "1.1.1",
"description": "Unlock custom brushes, natural fill effects and intuitive hatching in p5.js",
"main": "src/index.js",
"module": "src/index.js",
Expand Down Expand Up @@ -37,5 +37,8 @@
},
"peerDependencies": {
"p5": "^1.9.0"
},
"dependencies": {
"esm-seedrandom": "^3.0.5"
}
}
15 changes: 12 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @license
* MIT License
*
* Copyright (c) 2023 Alejandro Campos Uribe
* Copyright (c) 2023-2024 Alejandro Campos Uribe
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -149,13 +149,15 @@
* and angle calculation.
*/

import { prng_alea } from 'esm-seedrandom';

/**
* The basic source of randomness, can be seeded for determinism.
* @returns {number} A random number between 0 and 1.
*/
let rng = new Math.seedrandom(Math.random())
let rng = new prng_alea(Math.random())
export function seed (s) {
rng = new Math.seedrandom(s)
rng = new prng_alea(s)
}

/**
Expand Down Expand Up @@ -2387,6 +2389,13 @@
}
}

function _rotate(cx, cy, x, y, angle) {
let cos = R.cos(angle), sin = R.sin(angle),
nx = (cos * (x - cx)) + (sin * (y - cy)) + cx,
ny = (cos * (y - cy)) - (sin * (x - cx)) + cy;
return { x: nx, y: ny };
}

/**
* The FillPolygon class is used to create and manage the properties of the polygons that produces
* the watercolor effect. It includes methods to grow (expand) the polygon and apply layers
Expand Down

0 comments on commit 1b7fedd

Please sign in to comment.