GithubHelp home page GithubHelp logo

htor / framing Goto Github PK

View Code? Open in Web Editor NEW
17.0 5.0 0.0 5.66 MB

Online editor for live coding JS graphics with the canvas API.

License: MIT License

CSS 12.41% HTML 5.32% JavaScript 82.28%
canvas editor graphics live-coding browser 2d

framing's Introduction

framing

Online editor for live coding JS graphics with the canvas API. Try it out here!

example

To draw something on the canvas use the shorthand functions or standard canvas functions on the ctx global. Press F1 to get a list of shorthand functions.

// using shorthand
fstyle('orange')
frect(500, 500, 100, 100)
// using standard
ctx.fillStyle('orange')
ctx.fillRect(500, 500, 100, 100)

To run code for each frame, define a function draw(n). This function will be called for each frame. Current frame number is passed as n:

fps(6)
fstyle('orange')
var s = 20,
  x = 0,
  y = 0

function draw(n) {
  for (x = 0; x < w; x += s) {
    for (y = 0; y < h; y += s) {
      frect(x, y, s - 5, s - 5)
    }
  }
}

Control the number of frames per second with fps(n). Look inside the examples directory for examples and inspiration. Press F1 for more help.

usage

esc

Show/hide help window

ctrl+h

Toggle hiding code and output

ctrl+f

Toggle fullscreen mode

cmd/ctrl+enter

Save and evaluate code. If the code errors, the error is displayed on the lower left. The URL is updated with a shareable link.

cmd/ctrl+d

Duplicate current line

cmd/ctrl+k

Comment/uncomment current selection

cmd/ctrl+l

Select current line(s)

back/forward

Back and forward buttons in the browser moves through save history.

installing

Clone this repo and with npm do:

npm install
npm run dev

It should open in your browser at localhost:8080.

inspiration

Inspired by https://hydra-editor.glitch.me, the programming module at https://www.khanacademy.org/computer-programming/new/pjs and http://processingjs.org/.

license

MIT

framing's People

Contributors

htor avatar

Stargazers

 avatar  avatar Frankie Gavin avatar Milan G avatar Alvaro Obyrne avatar Zach Krall avatar Kanahathi Mohideen avatar Joohun, Maeng avatar Westin Lohne avatar  avatar J. J. Knudsen avatar Tan 'Proxy' Erdogan avatar Olivia Jack avatar Miki Oracle avatar Xiaobo avatar Matthieu Vion avatar  avatar

Watchers

James Cloos avatar  avatar Zach Krall avatar Olivia Jack avatar  avatar

framing's Issues

ideas

  • scoped/line evaluation(not really feasible with eval-solution)
  • pixel manipulation (imagedata +setting color depth 1,4,8 / tint(img, rgb, alpha)`)
  • norm(n, rstart, rend)
  • audio oscillators? maybe not the best thing to deal with @60fps..
  • modulation
  • (perlin)-noise function noise(x, y?, z?)
  • point(x,y)
  • triangle(x1,y1,x2,y2,x3,y3)
  • quad(x1,y1,x2,y2,x3,y3,x4,y4)
  • smooth() (antialiasing)automatic in canvas
  • seeding random-function?
  • log(...args) nope

editor crashes on some code

this crashes the editor:

push()
let t=ms()*.001,c
treset(1)
//tslate(abs(sin(t)*w),h/2)
//rotate(sin(t)*160)
fellips(w/2,h/2,200+sin(t)*222,200)
c=rgba(255,abs(sin(t)*255),25,1)
fstyle(c)
font('100px menlol')
ftext('L.F.O',w/2-130,h/2+30)
pop()
c

gimg: error handling

editor should handle not ok requests (status code not 200) made by gimg to avoid repeating those requests.

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.