Skip to content

Commit

Permalink
Merge pull request #295 from jeffeb3/feature/shape-descriptions
Browse files Browse the repository at this point in the history
Feature/shape descriptions
  • Loading branch information
jeffeb3 authored Jun 13, 2024
2 parents 6f316a2 + eabac2f commit e65fa38
Show file tree
Hide file tree
Showing 28 changed files with 309 additions and 410 deletions.
373 changes: 7 additions & 366 deletions NOTICE

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions public/fonts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
SIL OPEN FONT LICENSE, Version 1.1 - 26 February 2007

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting — in part or in whole — any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
21 changes: 21 additions & 0 deletions src/common/eulerian_trail/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Mauricio Poppe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// adapted from https://github.com/mauriciopoppe/eulerian-trail/blob/master/lib/eulerian-trail.js
// see NOTICE for license details
// see LICENSE for license details
// commented out thrown exceptions to return non-optimal eulerian paths
export const eulerianTrail = (options) => {
var g = []
Expand Down
3 changes: 2 additions & 1 deletion src/common/noise.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Adapted from https://gitlab.ilmiont.net/ilmiont/noisejs/. See NOTICE for licensing details.
// Adapted from https://gitlab.ilmiont.net/ilmiont/noisejs/.
// See LICENSE for licensing details.

/**
* Perlin fade function.
Expand Down
2 changes: 1 addition & 1 deletion src/features/effects/effectFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import FineTuning from "./FineTuning"
import Fisheye from "./Fisheye"
import Loop from "./Loop"
import Mask from "./Mask"
import Noise from "./Noise"
import Noise from "./noise/Noise"
import Track from "./Track"
import Transformer from "./Transformer"
import Warp from "./Warp"
Expand Down
21 changes: 21 additions & 0 deletions src/features/effects/noise/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This project is no longer maintained by the contributor (deleted from GitHub), and was in turn
adapted from an older project, https://github.com/josephg/noisejs.

MIT License

Copyright (c) 2018 James Walker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Victor from "victor"
import Effect from "./Effect"
import Effect from "../Effect"
import noise from "@/common/noise"
import { subsample } from "@/common/geometry"

Expand Down
42 changes: 24 additions & 18 deletions src/features/layers/LayerEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,23 @@ const LayerEditor = () => {
}
const link = model.link
const linkText = model.linkText || "here"
const renderedLink = link ? (
<div className="mt-3">
See{" "}
<a
target="_blank"
rel="noopener noreferrer"
href={link}
>
{linkText}
</a>{" "}
for ideas.
</div>
) : undefined
const description = model.description ? model.description + " " : ""

const renderedLink =
link || description ? (
<div className="mt-3 mx-3 mb-4 bg-light p-4">
{description}
See{" "}
<a
target="_blank"
rel="noopener noreferrer"
href={link}
>
{linkText}
</a>{" "}
for more information.
</div>
) : undefined

const handleChangeType = (selected) => {
dispatch(changeModelType({ id: layer.id, type: selected.value }))
Expand Down Expand Up @@ -122,10 +126,9 @@ const LayerEditor = () => {
{renderedModelSelection}
{renderedModelOptions}
{renderOption({ optionKey: "connectionMethod" })}
{renderedLink}
</div>
<div className="px-3 py-2">
{model.canTransform(layer) && (
{model.canTransform(layer) && (
<div className="px-3 py-2">
<Row className="align-items-center mt-1 mb-1">
<Col sm={3}>Transform</Col>
<Col sm={9}>
Expand Down Expand Up @@ -206,11 +209,14 @@ const LayerEditor = () => {
)}
</Col>
</Row>
)}
</div>
</div>
)}

<div className="border-top border-secondary px-3 pt-1">
<EffectManager />
</div>

{renderedLink}
</div>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/features/shapes/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class Circle extends Shape {
if (state.shape.circleDirection === "counterclockwise") {
for (let i = 128; i >= 0; i--) {
let angle = ((Math.PI * 2.0) / 128.0) * i

points.push(
new Victor(
Math.cos(angle),
Expand All @@ -46,6 +47,7 @@ export default class Circle extends Shape {
} else {
for (let i = 0; i <= 128; i++) {
let angle = ((Math.PI * 2.0) / 128.0) * i

points.push(
new Victor(
Math.cos(angle),
Expand Down
7 changes: 6 additions & 1 deletion src/features/shapes/Epicycloid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default class Epicycloid extends Shape {
super("epicycloid")
this.label = "Clover"
this.link = "http://mathworld.wolfram.com/Epicycloid.html"
this.linkText = "Epicycloid at Wolfram Mathworld"
this.linkText = "Wolfram Mathworld"
this.description =
"The clover shape is an epicycloid. Imagine two circles, with an outer circle rolling around an inner one. The path created by a point on the outer circle as it rolls is called an epicycloid."
}

getInitialState() {
Expand All @@ -36,13 +38,16 @@ export default class Epicycloid extends Shape {
let a = parseInt(state.shape.epicycloidA)
let b = parseInt(state.shape.epicycloidB)
let reduced = reduce(a, b)

a = reduced[0]
b = reduced[1]

let rotations = Number.isInteger(a / b) ? 1 : b
let scale = 1 / (a + 2 * b)

for (let i = 0; i < 128 * rotations; i++) {
let angle = ((Math.PI * 2.0) / 128.0) * i

points.push(
new Victor(
(a + b) * Math.cos(angle) - b * Math.cos(((a + b) / b) * angle),
Expand Down
2 changes: 2 additions & 0 deletions src/features/shapes/FancyText.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export default class FancyText extends Shape {
const segment = this.shortestPathAroundLoop(start, end, points)

segment.push(new Victor(next.x, next.y))

return { segment, end, nextStart }
}

Expand Down Expand Up @@ -355,6 +356,7 @@ export default class FancyText extends Shape {
// determine, so we're hard-wiring the rules, e.g. ('i', 'j')
const samplePoint = [points[i][0].x, points[i][0].y]
let idx = childMap[i]

if (idx === undefined) {
idx = polygons.findIndex((polygon) => {
return pointInPolygon(samplePoint, polygon)
Expand Down
8 changes: 7 additions & 1 deletion src/features/shapes/Heart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export default class Heart extends Shape {
constructor() {
super("heart")
this.label = "Heart"
this.description =
"Heart curves can be defined mathematically a number of different ways. Our heart shape is a parametric equation."
this.link = "http://mathworld.wolfram.com/HeartCurve.html"
this.linkText = "Wolfram Mathworld"
}

getInitialState() {
Expand All @@ -16,12 +20,14 @@ export default class Heart extends Shape {
}
}

// heart equation from: http://mathworld.wolfram.com/HeartCurve.html
getVertices(state) {
const points = []

for (let i = 0; i < 128; i++) {
let angle = ((Math.PI * 2.0) / 128.0) * i
let scale = 0.9
// heart equation from: http://mathworld.wolfram.com/HeartCurve.html

points.push(
new Victor(
scale * 1.0 * Math.pow(Math.sin(angle), 3),
Expand Down
4 changes: 3 additions & 1 deletion src/features/shapes/Hypocycloid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default class Star extends Shape {
super("hypocycloid")
this.label = "Web"
this.link = "http://mathworld.wolfram.com/Hypocycloid.html"
this.linkText = "Hypocycloid at Wolfram Mathworld"
this.linkText = "Wolfram Mathworld"
this.description =
"The web shape is a hypocycloid. Imagine two circles, with an inner circle rolling around inside an outer one. The path created by a point on the inner circle as it rolls is called a hypocycloid."
}

getInitialState() {
Expand Down
11 changes: 11 additions & 0 deletions src/features/shapes/NoiseWave.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export default class NoiseWave extends Shape {
this.selectGroup = "Erasers"
this.usesMachine = true
this.autosize = false
this.link = "https://en.wikipedia.org/wiki/Perlin_noise"
this.linkText = "Wikipedia"
this.description =
"Perlin noise is a type of gradient noise that can be used to generate textures and terrain. Here we use it to create an appealing series of wavy lines."
}

canMove(state) {
Expand Down Expand Up @@ -78,6 +82,7 @@ export default class NoiseWave extends Shape {
noise.seed(shape.seed)

const particles = []

for (let i = 0; i < shape.numParticles; i++) {
const p1 = {
x: sizeX * rng() - sizeX / 2,
Expand All @@ -103,6 +108,7 @@ export default class NoiseWave extends Shape {
for (let iterations = 0; iterations <= 1000; iterations++) {
// This has side effects on the particle
const newVertex = this.getParticleVertex(particle, shape)

group.push(newVertex)

// Stop if we entered and then exited the machine coordinates.
Expand All @@ -112,6 +118,7 @@ export default class NoiseWave extends Shape {
}
wasInside = inside
}

return group
})

Expand All @@ -125,6 +132,7 @@ export default class NoiseWave extends Shape {
const end = curve[0]
const startPerimeter = machine.nearestPerimeterVertex(start)
const endPerimeter = machine.nearestPerimeterVertex(end)

vertices = vertices.concat(
[
startPerimeter,
Expand Down Expand Up @@ -158,12 +166,15 @@ export default class NoiseWave extends Shape {
getCurve(vertexGroups, idx) {
const pEndVertices = vertexGroups[idx]
const pStartVertices = vertexGroups[idx + 1]

return pStartVertices.reverse().concat(pEndVertices)
}

getParticleVertex(p, options) {
let periodDenominator = 600 - options.noiseLevel

if (options.noiseLevel >= 600) periodDenominator = 1

const period = 1 / periodDenominator
const v =
options.noiseType === "Simplex"
Expand Down
Loading

0 comments on commit e65fa38

Please sign in to comment.