Skip to content

Instantly share code, notes, and snippets.

@thatrandomperson5
Last active October 25, 2024 23:58
Show Gist options
  • Save thatrandomperson5/275c0e87620fa3971d9877746c343aff to your computer and use it in GitHub Desktop.
Save thatrandomperson5/275c0e87620fa3971d9877746c343aff to your computer and use it in GitHub Desktop.
Developers docs for Desmosoft Paint

Known Bugs

  • Click-freeze: If you click any of lines drawn, desmos will freeze. Sometimes you can recover your drawing but most of the time it is cleared.

Report more in the comments

Desmos Paint Variable And Function Docs

Desmos Paint versions:

Global Constants / Variables

  • w: number, alias for Desmos constant width
  • h: number, alias for Desmos constant height
  • P_en: bool, whether the pen is down or not (down is true)
  • W_o: color, White color. (Was the white-out color for the white out system) (Deprecated)
  • H: number, actual numerical height (relative to the graph). Normal height is in pixels and is relative to the screen.
  • H_p: number, height percentile. UI elements that adjust with the screen will use this.

Line and Draw Utilities

  • L(a: cord, b: cord): function, draws a line between a and b (using slope-intercept and X limits)
  • L_y(a: cord, b: cord): function, draws a vertical line between a and b if they are vertical. used as x = L_y(a, b)
  • D(P: list[cord]): function, draws a line between all points in P.
  • D_y(P: list[cord]): function, draws a line between all the straight up point pairs in P.

Controls

  • C_1: cord, current mouse coordinate
  • C_2: cord, previous mouse coordinate
  • Note: Large 0 opacity drag-able image serves as the mouse cursor

Class: Double Click D_c

  • D_c: number[time], double-click timer
  • D_cf(): function[action], general click function. Adds time to the double click timer, adds a break in the art, flips the pen variable. (Calls B_r())
  • D_cc: function[action], double click click. The click function. If double click, call clear C_l(). Otherwise, call D_cf()

Core

  • U(): function[action], update line data. Adds the current mouse coordinates to the art list. Also adds current color and full opacity to their respective lists.
  • R(): functions[action], call U() if not C_2 = C_1
  • M(): function[action], main function called on each clock cycle. If pen is down call R(). Otherwise, update previous coordinates to current coordinates. (Legacy)
  • M_t(): function[action], main function with account for FPS, delay, and time. Was implemented once I stopped relating on the builtin ticker timing. Calls M()

Line

  • A: list[cord], the “art” list. Contains coordinates who make the line that is your drawing.
  • A_w: list[number], contains opacity numbers for each segment specified in A. Deprecated Version: list[cord], contains the whiteout line.
  • C_l(): function[action], clears the canvas. Resets all canvas-state variables. Does not reset the color pallet and cursor position like R_eset() does.
  • B_r(): function[action], creates a break in the current line structure by inserting opacity.

Class GUI G

  • Note: Background rounded rectangle, uses equation max(0,|x-x1|-scaled_width)^2 + max(0, |y-y1|-scaled-height)^2 = (corner_radius)^2
  • G_diff: number, space between color circles
  • G_iw: number, width of a color circle and it’s margin
  • G_df(i: number): function, calculates the position of a the i’th circle.
  • G_r: number, radius of the color circles.
  • G_cn: number, color circle count. Adjusted by 4 to leave space for custom color area.

Class Colors C

  • C_c: number, current color index of color list C
  • C_s: list[number], color selected. Can be applied to the border opacity value of the circles and produces a “selected” effect.
  • C_b: list[color], base colors, applied to the pallet on reset.
  • C_A: list[color], colors for the A line list. This enables changing of colors.
  • C: list[color], the current color pallet. Length is 15

Extras

  • D_t: number[time], the difference time between ticks in milliseconds.
  • F_ps: number, the current FPS of the program. Displayed in the bottom left.

Class Color Picker C_capital

  • C_setCurrent(): function[action], updates the color pallet at the current selection to the custom color C_C
  • C_C: color, the current custom color.
  • C_Lf: number, length/width of the color selection bars.
  • C_Xi: number, the X initial for the color selection bars.
  • C_D(h_1: number): function, draws a dot bar at dynamic height h_1 (relative to H_p)
  • C_I: list[color], an index array for dot bars.
  • C_H, C_S, C_V: number, parts of the custom HSV color value. All are adjustable with sliders.
  • C_Hc, C_Sc: color, the partial HSV values at each stage for preview.
  • C_Hac, C_Sac, C_Vac: respective and dynamic color/gradient list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment