-
-
Save samestep/4344820d0cafe2c69195cfa9cb05def9 to your computer and use it in GitHub Desktop.
untitled: a trio from https://penrose.ink
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
type Axes | |
type Function | |
predicate On(Function, Axes) |
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
canvas { | |
width = 800 | |
height = 700 | |
} | |
const { | |
scalar axesSize = 350 | |
scalar arrowheadSize = 0.7 | |
scalar lineThickness = 1 | |
color gray = rgba(0.6, 0.6, 0.6, 1) | |
color lightBlue = rgba(0.2, 0.4, 0.8, 1) | |
color lightGray = rgba(252, 252, 252, 0.015) | |
color none = rgba(0, 0, 0, 0) | |
} | |
Axes A { | |
scalar axisSize = const.axesSize / 2 | |
vec2 A.origin = (0, 0) | |
vec2 o = A.origin | |
A.axisColor = const.gray | |
A.background = Rectangle { | |
center: A.origin | |
width: const.axesSize | |
height: const.axesSize | |
fillColor: const.lightGray | |
strokeColor: const.none | |
} | |
A.xAxis = Line { | |
start: (o[0] - axisSize, o[1]) | |
end: (o[0] + axisSize, o[1]) | |
strokeWidth: const.lineThickness | |
style: "solid" | |
strokeColor: A.axisColor | |
startArrowhead: true | |
endArrowhead: true | |
arrowheadSize: const.arrowheadSize * 2 | |
} | |
A.yAxis = Line { | |
start: (o[0], o[1] - axisSize) | |
end: (o[0], o[1] + axisSize) | |
strokeWidth: const.lineThickness | |
style: "solid" | |
strokeColor: A.axisColor | |
startArrowhead: true | |
endArrowhead: true | |
arrowheadSize: const.arrowheadSize * 2 | |
} | |
} | |
Function f; Axes A | |
where On(f, A) { | |
f.start = (?, ?) | |
f.end = (?, ?) | |
f.graph = Line { | |
start: f.start | |
end: f.end | |
strokeWidth: 3 | |
strokeColor: const.lightBlue | |
startArrowhead: true | |
endArrowhead: true | |
arrowheadSize: const.arrowheadSize | |
} | |
scalar axisSize = const.axesSize / 2 | |
vec2 o = A.origin | |
scalar a = 0.5 | |
ensure equal((f.start[0] + f.end[0]) / 2, 0) | |
ensure equal((f.start[1] + f.end[1]) / 2, 0) | |
ensure equal(min(f.start[0], f.start[1]), -axisSize) | |
ensure equal(max(f.end[0], f.end[1]), axisSize) | |
ensure equal((f.end[1] - f.start[1]) / (f.end[0] - f.start[0]), a) | |
} |
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
Axes A | |
Function f | |
On(f, A) |
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
{"authorship":{"madeBy":"samestep","name":"untitled","avatar":"https://avatars.githubusercontent.com/u/8246041?v=4"}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment