Giter Club home page Giter Club logo

theta's Introduction

Theta

Website: http://thetamath.com

This is a simple web app that graphs an equation and allows you to pan and zoom around the coordinate grid. It was my winter 2015-2016 break project, developed here and there over two weeks. Interesting bits:

  • Custom equation editor with exponents, fractions, and other stuff
  • Live errors inline as you type, sort of like an IDE
  • GPU-powered anti-aliased equation rendering, handles equations that are impossible to solve
  • Custom text rendering using subpixel anti-aliasing and GPU quadratic curve evaluation (see the article Easy Scalable Text Rendering on the GPU for a detailed description)
  • Uses the Skew programming language and the GLSLX compiler, ends up as a few dozen kilobytes of optimized JavaScript
  • Abuses GitHub's custom 404 handler to make bookmarkable URLs without needing a hosting provider :)

Examples:

theta's People

Contributors

evanw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

theta's Issues

What's Smooth Shaders for?

Hi,

In your post, you did not mention anything on this smooth shader, can you make some simple explanation on this shader? I can not figure out why this shader can improve the smooth of the glyphs.

Thanks.

Where does these magic numbers come from

Hi, sorry for so many questions.

Where does these magic numbers come from?

const JITTER_PATTERN = [
        Vector.new(-1 / 12.0, -5 / 12.0),
        Vector.new( 1 / 12.0,  1 / 12.0),
        Vector.new( 3 / 12.0, -1 / 12.0),
        Vector.new( 5 / 12.0,  5 / 12.0),
        Vector.new( 7 / 12.0, -3 / 12.0),
        Vector.new( 9 / 12.0,  3 / 12.0),
    ]

In your post, you mentioned this:
We can easily get four samples per pixel by rendering the same set of triangles four times, each time with a slightly different offset and using a color with a different channel each time.

slightly different offset refer to these magic number above? If yes, how can I create this numbers?

Question about GPU.BufferPool

Hey @evanw, i am trying to learn from this app and I was wondering why there is only one large VertexBuffer vs. allocating a buffer for each thing. Or am i misunderstanding the code?

Is the overhead of many createBuffer/deleteBuffer big?
Doesn't this approach also mean there is a lot of space unused since a chunk is 4 * 1024 * 1024?

Description

Hello @evanw!

Thank you for the best math plotter.
Could you add a description line with keywords like math, chart, plot, graph — now it is very difficult to search for it in list of projects / stars.

Thanks!

Some questions about implementation/performance.

I have implemented Easy Scalable Text Rendering on the GPU with OpenGL without the anti-aliasing part. Great thanks to @evanw . 👍

result
msjh.ttf, character: 'D', font-size: 400

But I think there are some problems:

Every glyph will consume a drawcall. (code taken from compiled.js)

    for (var i = 0, count1 = this._usedInstances; i < count1; i = i + 1 | 0) {
      var instance = in_List.get(this._instances, i);

      if (instance.glyph.area != null) {
        for (var j = 0, count = Canvas.JITTER_PATTERN.length; j < count; j = j + 1 | 0) {
          var offset = in_List.get(Canvas.JITTER_PATTERN, j);
          this._transformB.set2(this._transformA);
          this._transformB.translate1(instance.offset);
          this._transformB.translate2(offset.x * scale, offset.y * scale);
          this._transformB.scale1(instance.scale);

          if (j % 2 == 0) {
            this._glyphMaterial.setUniformVec41(GLSLX_NAME_COLOR, j == 0 ? 1 : 0, j == 2 ? 1 : 0, j == 4 ? 1 : 0, 0);
          }

          GPU.in_Material.setUniformMat32(this._glyphMaterial, GLSLX_NAME_MATRIX3, this._transformB);
          this._context.draw(GPU.Primitive.TRIANGLES, this._glyphMaterial, instance.glyph.area);
        }
      }
    }

I haven't test it but I think the performance will be very bad when rendering many characters. So I changed a little: all glyph contours (line-segments and quadratic bezier segments) are combined into one mesh, and then rendered in the same way. The output should be the same.

But, if all glyphs are combined and rendered at the same time, we won't be able to use per-glyph color. All the text will have the same color. I don't have any idea how to solve this.

Do you have any suggestions? @evanw

Really interested in the code base

For me, this code is unreadable. But I really REALLY want to learn your Loop Blinn / antialiasing technique.

Is there any way to build the code in a readable manner for Javascript? I couldn't figure out your skew builder if it had any options to work with.

I read your article on Medium, but it's just not enough since I am new to GLSL and most articles about the topic have been taken down.

Thanks,
Craig.

Factorial

Hi @evanw!
It is not possible to use common math factorial notation x! now.
Are there plans to introduce that?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.