Skip to content

[css-shapes] New <shape-command>: plot to draw graphs #12224

@Crissov

Description

@Crissov

If you are somewhat like me, you never quite got the grip of Bézier curves with their control points, but you have a good understanding of plots, i.e. graphs of functions, continuous ones in particular. CSS has now gained several ones for trigometry and polynomials, as well as numeric constants e and pi. Furthermore, custom functions are being specified right now.

Most shape() commands draw from the current, start point to an absolute or relative end point. The proposed plot is no different. In the degenerate case without any function specified, it equals line.

We need to define an interval from the graph, say [a, b], that is to be scaled to the length from start to end point. Although we can adjust any function with offsets and scale factors so a and b equal, say, 0 and 1 (or 0% and 100%), respectively, it seems more author-friendly to select them from the unscaled range, e.g. [−2π, +2π], although defaulting a to 0 seems sensible.

Within the function, there needs to be something new: a variable that runs from a to b and does not use var(), intuitively this would simply be called x. I'm pretty sure that authors would find many creative uses if all kinds of relative units were available within this formula. (Personally, I would be fine without.)

While the direction and scale of the x axis is given by a and b, there needs to be a convention where up and down, i.e. positive and negative y axis are.

Example

shape( plot to x-end with sin(x) from 0 to 2*pi )

Preliminary grammar

<shape-command> =| <plot-command>

<plot-command> = plot <command-end-point>
        [ with <expression> [ [ from <number> ]? to <number> ]? ]?

<expression> = <math-function-name>( <calc-sum> | <expression> )

<calc-keyword> =| x

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions