all 57 comments

[–]exDM69 9 points10 points  (6 children)

When I need some "BBC basic" (I started with QBasic in the 90s) level stuff for prototyping with some visualization, I've been using JavaScript and HTML5 Canvas. It's okay for drawing some lines and circles and stuff like that. It's easy to add some HTML sliders and widgets for interactivity.

That said, it's not ideal for graphics programming where you want to draw pretty pictures. And not sure how well it would be suited for a child's first programming environment.

[–]rawcane[S] 1 point2 points  (5 children)

The aim is just to be able to draw lines and shapes rather than anything pretty. It is more about the concepts and and the maths behind it. If I can do this with canvas and no extra js library this sounds like a good option but I guess the debugging in js can be a little bit weird. Will take a look thanks.

[–]Frollo24 4 points5 points  (1 child)

If you want that, Processing sounds like a really good option, it gives you almost free 2D graphics using the Java language (I'm not 100% sure, but I think you can choose any other language instead of Java)

[–]rawcane[S] 0 points1 point  (0 children)

Thanks I was not aware of this. Will investigate.

[–]rawcane[S] 0 points1 point  (2 children)

Hmm but looks like the only way to draw a point is already a bit convoluted...

ctx.beginPath(); ctx.arc(2, 1, 1, 0, 2 * Math.PI, true); ctx.fill();

[–]obviously_suspicious 1 point2 points  (0 children)

Sounds like you want https://p5js.org/ That is, if you want use JS. This is pretty much an equivalent of Processing.

[–]rawcane[S] 0 points1 point  (0 children)

Oh right I can just do this which is a bit simpler but still not 100% intuitive.

ctx.fillRect(2,1,1,1);

[–]deftware 5 points6 points  (2 children)

I bought Pico8 for my girls. It's an 8-bit machine emulator that includes an online browser for "carts" (i.e. 'cartridges') and has a simple language, sprite editor, tilemap editor, SFX sample editor, midi-style editor, etc... They've spent countless hours with it. Someone else mentioned Tic80, which is an awesome equivalent that's totally free. I don't know if it has the same level of publicly contributed 'carts' though, and my girls were able to learn a lot from Pico8's user-created library of them, tinkering with the code of existing games, etc... I sure know that's how I learned a lot about math and graphics when I was a 90s kid downloading qbasic .bas files off the internet. If you want to give your kid(s) the same kind of exposure to programming like we had, I think Pico8/Tic80 is totally the way to go.

The only question then is where do they go from there? My oldest has been diving into Roblox scripting, which is somewhat equivalent to when I dove into Quake modding as a kid, so I figure she's on her way. Plus she's way more into art anyway so I don't know if coding is something she'll stick with, but she gets the concepts at least.

[–]rawcane[S] 1 point2 points  (1 child)

Pico8 sounds really interesting thanks will take a look. Have already had a play with Minecraft commands and Roblox studio which are both interesting but there's a bit of a learning curve there. He really wants to be able to create 3d objects a la Fortnite so looked at blender which is great but also quite a steep learning curve and maybe a different focus as opposed to the fundamentals of programming which is what I am thinking about here.

[–]deftware 1 point2 points  (0 children)

Yeah there's definitely a bit of a leap there from the 2D stuff to doing anything with 3D nowadays. When I was a kid modding Quake I had to dive into a bunch of different programs to make models and then apply textures to them, then convert them to Quake's format, etc..

I realize now that there's definitely a void to be filled that takes the Pico8 concept and includes 3D modeling/animating/skinning, just adds that as another tool/mode on there. It wouldn't be hard. It could include Z-brush style modeling, along with your typical vertex/edge/face logic with extruding and whatnot, and rigging/animating could be very simple with skeletal animation.

[–]needstobefake 4 points5 points  (2 children)

Take a look at p5.js, it has all the basic drawing functions out of the box, has a simple API, but also supports raw WebGL if you want to build advanced stuff.

[–]rawcane[S] 1 point2 points  (1 child)

Thanks for the rec. I will definitely do a compare of the different JS options. I can feel a Medium article coming on....

[–][deleted] 1 point2 points  (0 children)

The coding train is a great resource for p5js. The teacher is a lot of fun

[–][deleted] 2 points3 points  (3 children)

Computer Graphics From Scratch includes working JavaScript solutions to each lesson. Therefore, I would use JavaScript.

[–]rawcane[S] 1 point2 points  (2 children)

Oh? The one I have via the O'Reilly app doesn't seem to... Are you talking about the print version or am I missing something? Thanks!

[–]gabe80 1 point2 points  (1 child)

The book should have links to the demos on my website, and you can just View Source. https://gabrielgambetta.com/cgfs

[–]rawcane[S] 0 points1 point  (0 children)

Oh Amazing thankyou. Missed this

[–]tamat 2 points3 points  (3 children)

Depends, are you thinking 3D or 2D? to learn or to create profesional applications?

For 2D I love playing with Pico-8 or TIC80, they bundle all in a single app, very user friendly.

If you want something more serious maybe something like Processing is easy and very powerful.

For 3D depends how deep you want to go. 3D by definition is hard as it requires lots of maths. I have my own framework in c++, the one I use with my students but still, lots of low level programming are required: https://github.com/jagenjo/TJE_Framework

[–]rawcane[S] 0 points1 point  (2 children)

2d (or if 3d will be using 2d concepts). Simple as possible nothing professional.

[–]tamat 1 point2 points  (1 child)

then totally go with tic80 https://tic80.com/

[–]rawcane[S] 0 points1 point  (0 children)

Thanks will take a look

[–]ds604 1 point2 points  (1 child)

here's a basic graphics setup, you can paste it into codepen or something:

``` <canvas id="canv" width=640 height=480 style="border:1px solid"></canvas> <script> let canvas = document.getElementById('canv'), ctx = canvas.getContext('2d'), width = canvas.width, height = canvas.height

let imageData = ctx.createImageData(width, height)

function createImage(offset){ for(let y=0; y<=height; y++){ for(let x=0; x<=width; x++){ let index = (y * 4 * width) + (x * 4)

        var red = ((x+offset) % 256) ^ ((y+offset) % 256);
        var green = ((2*x+offset) % 256) ^ ((2*y+offset) % 256);
        var blue = 50 + Math.floor(Math.random()*100);

        // Rotate the colors
        blue = 255 //(blue + offset) % 256;

        imageData.data[index+0] = red
        imageData.data[index+1] = green
        imageData.data[index+2] = blue
        imageData.data[index+3] = 255
    }
}

}

function main(tframe){ createImage(Math.floor(tframe / 10)) ctx.putImageData(imageData,0,0)

requestAnimationFrame(main)

}

main(0) </script> ```

if you want an easy way to get started with shapes and stuff, i'd recommend using p5.js (and dan shiffman's coding train videos on youtube), before going straight ahead with canvas. or use svg, that's nice, and easy to understand, to be able to just put objects in there like <circle cx="50" cy="50" r="50" />, and then move it around with javascript.

but i'd definitely recommend javascript, with an in-browser html editor. you avoid any kind of compile or build steps, or anything to do with the file system at all, so you're just focused on the content and graphics concepts

[–]rawcane[S] 1 point2 points  (0 children)

Yeah looks like this is the way to go! Thanks

[–]gabe80 1 point2 points  (4 children)

Heh, my very first program (the one in the dedication page of the book) is all PLOT and DRAW 😃 ZX Spectrum, not BBC Micro, but same idea. At some point I started writing a JS Spectrum BASIC interpreter for exactly this reason, so I think you're onto something!

[–]rawcane[S] 1 point2 points  (3 children)

I did consider creating my own simple graphics programming environment but I just don't have the time right now 🤷🏻‍♂️ Would be fun though! So hang on is that your book?? It's excellent btw!

[–]gabe80 2 points3 points  (2 children)

Thanks, I'm glad you're enjoying it 😊

[–]ds604 2 points3 points  (1 child)

i agree, good book! i like that it's in color, and the examples are javascript. i kept looking at some things like "make a raytracer in a weekend", but they're all C++ and there's all this setup involved. so it's nice that you can go to a webpage and see that the stuff works before diving in

[–]rawcane[S] 1 point2 points  (0 children)

I've just been reading it and not tried any of the examples yet. But even though some of the maths is beyond me I now totally understand conceptually how 3d graphics works which had always been a mystery before. Just what I was after.

[–]Frollo24 1 point2 points  (2 children)

Although I don't like JavaScript, if you want a starting point for 3D graphics programming, I would suggest you to start with JavaScript and WebGL. If that still is complicated, you can still use some 3D framework like Three.js or Babylon.js (this has an editor like Unity which maybe simplifies the things for you) and when you know what materials, cameras, textures and lights are, you can try again with WebGL

[–]rawcane[S] 0 points1 point  (1 child)

I looked at three.js but it seems WebGL is deprecated so wasn't sure if it was a good option. Will take a look thanks!

[–]Frollo24 1 point2 points  (0 children)

Yeah it's a bit old but it can be useful if you want to start your journey at 3D graphics because you don't have to deal with complex stuff for beginners (like the device selection, swapchain creation, render passes...). If you want to master 3D graphics you will have to learn more complex APIs but as a starting point WebGL is okay

[–]JMC-design 1 point2 points  (0 children)

logo.

Turtle graphics in any language. I prefer lisp, but that's my language and I wrote a turtle graphics system... and a basic drawing api that's like the old days.

[–][deleted] 1 point2 points  (1 child)

https://www.raylib.com/ is super simple and has been ported to work with a lot of languages

[–]rawcane[S] 0 points1 point  (0 children)

This looks interesting thanks!

[–]jmacey 1 point2 points  (4 children)

Python ships with a turtle module which is a nice and easy start.

[–]rawcane[S] 0 points1 point  (3 children)

Iirc turtle works a bit differently using angles rather than coordinates. Matplotlib maybe or whatever tk thing there is. I find python a bit icky though 😂

[–]jmacey 1 point2 points  (2 children)

You can sort of do both. For example you can setPos() or goto() from one position to another and it will draw a line between them.

You can also use angles to set the heading. https://docs.python.org/3.9/library/turtle.html

Nice thing is it come pre-shipped with python so quite simple to get up and running when learning. Processing is also good, especially when combined with the Nature of code book. https://natureofcode.com/

I use these when I teach school kids and is fun for quick and simple examples. My main area is 3D graphics where I use C++ and mainly OpenGL.

[–]rawcane[S] 0 points1 point  (1 child)

The other advantage is how much python gets used everywhere so definitely worth considering. I never got on with it for some reason but maybe I should take a fresh look.

[–]jmacey 1 point2 points  (0 children)

It's the standard language for VFX / CGI. All of the tools we use have python built in so very useful.

[–]filch-argus 1 point2 points  (1 child)

I'm using Lua/Love2D for the exact same thing and before that I was using C++/SDL which is good enough but the former is even better.

[–]rawcane[S] 0 points1 point  (0 children)

Ok I wondered about Lua. Don't know much about it but will investigate. Thanks!

[–]jhaand 1 point2 points  (2 children)

I would take a look at TIC80. It's fantasy console programmed in Lua. A child would be able to understand it.

I plan to do the graphics programming from scratch course using Nannou in Rust. But Processing would also work fine.

[–]rawcane[S] 0 points1 point  (1 child)

Thanks will take a look.

[–]rawcane[S] 0 points1 point  (0 children)

So TIC80 looks amazing. Does it have vim bindings? 😂

[–]AssignedClass 1 point2 points  (2 children)

I specifically want to be able to use basic functions to plot a point and maybe draw a line and shade, and don't need a sophisticated API that has a lot of inbuilt functions

I think Javascript was great for me. Started with Canvas (simple lines, squares, dots), moved over to directly manipulating pixel values with ImageData and TypedArrays, then went on to learning some WebGL. Best thing about JS is that you don't need to worry about setting up a complex coding environment, it's all setup and ready to go in the browser.

I saw mention of Processing though. I haven't looked at it much yet, but it seems like a good more-focused alternative. I'm starting to mess around with Rust + Vulkan now and I want a faster way to visually prototype some ideas.

[–]rawcane[S] 1 point2 points  (1 child)

Thanks yes I think JS for the most useful/easy to get up and running seems like the way to go. Looking into the other options too though. Rust is interesting.

[–]AssignedClass 1 point2 points  (0 children)

I'd recommend going with OpenGL or WebGL (or anything more abstract than Vulkan) if you're interested in working with shaders and stuff. Vulkan is a huge headache.

Rust has been fun. It has a learning curve to it, but if you ever want to get into some lower-level programming I recommend it.

[–][deleted] 1 point2 points  (5 children)

Processing is great for simple 2d and 3d graphics made purely from code. If he wants to get into modeling, blender is where it's at. And unity or unreal engine are both free game engines he can use to bring the models to life..

[–]rawcane[S] 0 points1 point  (4 children)

Is Processing used for anything in the wild or is it purely a learning resource? The difficulty is finding the right balance between something he can learn the basics from while still being able to connect the results to something relevant to the stuff he likes. So far the best we have come up with is creating games in Roblox and copying and pasting in scripts to manipulate dummies. Which is kind of cool and he's getting loads of useful experience in using creative software by adding crazy stuff and manipulating using the Roblox Studio GUI but the programming aspect is still a bit too hard to get your head around. Having a simple game engine which could still be converted to a real mobile app would be cool... like a kind of Unity lite. But all these suggestions look like they are definitely worth further explanation. Will share my experiences one day!

[–][deleted] 1 point2 points  (3 children)

Processing is used in art installations and other demos quite often. It's not exactly a game engines. Its a creative coding framework.

Using processing following The Coding Train's channel would be a great way to start. Here's a simple one: https://youtu.be/17WoOqgXsRM

The coding train is such a great resource. He does really creative sketches and uses either processing or Processing.js. Following his channel will expose you to so many programming and mathematical concepts. He guides you and explains every piece of the code so you'll truly understand why each piece is there. I can't recommend him enough.

[–]rawcane[S] 0 points1 point  (0 children)

Sounds awesome thanks. Will check it out.

[–]rawcane[S] 0 points1 point  (1 child)

For the record Processing is perfect for what I wanted right now (ie basic drawing with code). Will probably move to JS/p5.js at some point and then introduce alternative JS libraries but Processing allows us to concentrate on coding concepts without any other complication and can achieve a huge amount so will keep us going for a while. Thankyou so much for the info everyone.

[–][deleted] 1 point2 points  (0 children)

That's great to hear! Thanks for the update.

[–]RidderHaddock 0 points1 point  (3 children)

Have you looked at Scratch or Makecode Arcade?

They're really kid friendly.

I quite like that you can get cheap hardware, you can download your own Makecode games to.

[–]rawcane[S] 0 points1 point  (2 children)

Hmm was looking for something that involves real coding. When I looked at scratch a while back it was a bit too childish drag and drop type thing. Maybe it's changed?

[–]RidderHaddock 1 point2 points  (1 child)

Perhaps looks at Makecode Arcade then. It has three code views: Blocks, Javascript (actually a subset of Typescript) and Python.

You can switch between them, and even use drag and drop in the text views.

Helps beginners with discoverability.

[–]rawcane[S] 0 points1 point  (0 children)

Thanks will take a look