From b92820fa9bc50b9c1f8fe1f366ea189babe62e58 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 20 Nov 2023 23:05:33 -0800 Subject: [PATCH] subject people to a tutorial --- 0011-on.initialize | 1 + 0077-example_pane | 6 +++++ 0078-Example_panes | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 0077-example_pane create mode 100644 0078-Example_panes diff --git a/0011-on.initialize b/0011-on.initialize index b35d3a7..cbf5a00 100644 --- a/0011-on.initialize +++ b/0011-on.initialize @@ -5,6 +5,7 @@ on.initialize = function() Menu_left, Menu_top, Safe_width, Safe_height = love.window.getSafeArea() Menu_height = 5 + Line_height + 5 Menu_bottom = Menu_top + Menu_height + Panes = map(Example_panes, example_pane) table.insert(Panes, new_pane()) Current_pane_index = 1 Current_pane = Panes[Current_pane_index] diff --git a/0077-example_pane b/0077-example_pane new file mode 100644 index 0000000..c1f8b11 --- /dev/null +++ b/0077-example_pane @@ -0,0 +1,6 @@ +example_pane = function(lines) + local result = new_pane() + result.editor_state.lines = load_array(lines) + Text.redraw_all(result.editor_state) + return result +end \ No newline at end of file diff --git a/0078-Example_panes b/0078-Example_panes new file mode 100644 index 0000000..038e1c0 --- /dev/null +++ b/0078-Example_panes @@ -0,0 +1,56 @@ +-- some examples +-- each element of this array is itself an array of lines that will get loaded into a pane +Example_panes = { + { + "-- some examples; feel free to delete them and they'll never return", + '-- first example: you can perform simple calculations.', + '-- (scroll down..)', + "-- Try hitting the 'run' button above", + "-- when you're done, tap on the right margin to go to the next example", + '2+3' + }, + { + '-- print() calls show up in the area below', + "-- hit 'run' and then scroll through the results", + 'for i=1,20 do print(i) end', + }, + { + '-- you can draw on the screen', + "-- after you hit 'run', try hitting 'hide'", + 'love.graphics.line(100,100, 200,300)' + }, + { + '-- some color', + 'love.graphics.setColor(1,0,0)', + "love.graphics.rectangle('fill', 100,100, 200,300)", + }, + { + '-- a checkerboard', + '-- notice Safe_width and Safe_height for the bounds of the screen', + 'n = 100', + 'for x=0,Safe_width,n do', + ' for y=0,Safe_height,n do', + ' if (x+y)/n%2 == 0 then', + ' love.graphics.setColor(0.9, 0.7, 0.7)', + ' else', + ' love.graphics.setColor(0.7, 0.7, 0.9)', + ' end', + " love.graphics.rectangle('fill', x,y, n,n)", + ' end', + 'end', + }, + { + '-- some abbreviations to reduce typing', + 'g = love.graphics', + 'points, line, rectangle, polygon, circle, arc, ellipse = g.points, g.line, g.rectangle, g.polygon, g.circle, g.arc, g.ellipse', + 'color, bgColor = g.setColor, g.setBackgroundColor', + "-- enough abbreviations, let's draw", + 'color(1,0,0) bgColor(0,1,0)', + 'line(100,100, 200,300)', + "circle('fill', 200,100, 30)", + }, + { + "-- over to you; hope you enjoy Carousel Shell!", + '', + } +} \ No newline at end of file