-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/uellenberg/LogiMat
- Loading branch information
Showing
10 changed files
with
169 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Domain Coloring | ||
This example plots complex functions using color. Open [main.lm](main.lm) to configure. | ||
|
||
NOTICE: This requires a post-processor to display correctly. It is recommended that you compile this using [Graphgame Studio](https://graphgame.js.org). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//Create a black background. | ||
export const b_lack = rgb(0, 0, 0); | ||
|
||
display fill = 1; | ||
display thickness = 0; | ||
display color = b_lack; | ||
polygon((-.5, -.5), (.5, -.5), (.5, .5), (-.5, .5)); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export function c_olor(x) { | ||
const h = cArg(x) * (180/pi); | ||
const s = 1/(1 + .3*log(cAbs(x) + 1)) - .4; | ||
const l = 1 - 1/(1.1 + 5*log(cAbs(x) + 1)); | ||
|
||
state = hsv(h, s, l); | ||
} | ||
|
||
inline function gColor(num) { | ||
//Loop through the image, divided by the number of splits we turn the image into (this creates a single split). | ||
state = range(1, width * height/get!(SPLITS)).map(idx => { | ||
//Get the x-position, centered at (0, 0). | ||
const x = conv_1d_2d_x(idx, width) - width/2; | ||
//Gets the y-position, centered at (0,0) and increased by the y-position of previous splits. | ||
const y = conv_1d_2d_y(idx, width) - height/2 + height*(num-1)/get!(SPLITS); | ||
|
||
const cX = x/r_es + x_off; | ||
const cY = y/r_es + y_off; | ||
const cVal = (cX, cY); | ||
|
||
const val = i_t(cVal); | ||
|
||
state = c_olor(val); | ||
}); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//This file handles displaying the fractal, and putting together the set, color handler, and renderer. | ||
|
||
//The way that splitting works is we split up out final big image into multiple smaller ones, to avoid hitting Desmos' limit. We must define the amount of splits (or number of smaller images) below, and also define the images themselves. | ||
|
||
define!(SPLIT_NUM, 1); | ||
|
||
iterate!({ | ||
display thickness = 0; | ||
export const "c_olor${get!(SPLIT_NUM)}" = gColor(get!(SPLIT_NUM)); | ||
|
||
display fill = 1; | ||
display thickness = 0; | ||
display color = "c_olor${get!(SPLIT_NUM)}"; | ||
expression => gRender(get!(SPLIT_NUM)); | ||
|
||
define!(SPLIT_NUM, SPLIT_NUM + 1); | ||
}, SPLITS); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export cPow; | ||
export cPolar; | ||
export cMul; | ||
export cSin; | ||
|
||
export const a = 0; | ||
export const p_oint = (a, a - 3); | ||
|
||
export function r_un(x) { | ||
cSin(cPow(x, p_oint)) | ||
} | ||
|
||
export function i_t(x) { | ||
state = p_oint; | ||
|
||
iterate!({ | ||
state = cSin(cPow(x, state)); | ||
}, ITERATIONS); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
inline const width = 100; | ||
inline const height = 100; | ||
|
||
export const r_es = width/2 * 1/5; | ||
|
||
export const x_off = 0; | ||
export const y_off = 0; | ||
|
||
//Defines the number of iterations to use. | ||
define!(ITERATIONS, 5); | ||
|
||
//Defines the amount of "splits" to use. For a 200x200 image, you need 4 splits (200*200 / 10,000 = 4). | ||
//This will create 4 images with 10,000 pixels each, which will be placed together to form a complete image. | ||
define!(SPLITS, 1); | ||
|
||
//Import everything. | ||
|
||
//First, add a background. | ||
import!("background.lm"); | ||
//Next, make it possible to compute the Mandelbrot set. | ||
import!("function.lm"); | ||
//After that, use the Mandelbrot set to compute the colors. | ||
import!("color.lm"); | ||
//Create an object that the colors can be applied to. | ||
import!("rendering.lm"); | ||
//Use the methods defined above to display everything. | ||
import!("display.lm"); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//This file is responsible for creating the polygons that are used for rendering. Rendering in Desmos is fairly simple: we just need to create a polygon list that fills up the square. The actual coloring of this set of polygons is up to the color handler. | ||
|
||
//Renders the image. This just creates a grid of polygons. | ||
inline function gRender(num) { | ||
//Loop through the image, divided by the number of splits we turn the image into (this creates a single split). | ||
state = range(1, width * height/get!(SPLITS)).map(idx => { | ||
//Get the x-position, centered at (0, 0). | ||
const x = conv_1d_2d_x(idx, width) - width/2; | ||
//Gets the y-position, centered at (0,0) and increased by the y-position of previous splits. | ||
const y = conv_1d_2d_y(idx, width) - height/2 + height*(num-1)/get!(SPLITS); | ||
|
||
//Create a polygon using the x and y position. | ||
//This is slightly bigger than 1x1 to remove grid lines that 1x1 creates. | ||
state = polygon((x/width, y/height) + [(-.2/width, -.2/height), (-.2/width, 1.2/height), (1.2/width, 1.2/height), (1.2/width, -.2/height)]); | ||
}); | ||
} |
This file contains 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
This file contains 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
This file contains 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