give example panes a name

akkartik
Nov 23, 2023, 5:11 AM
MJ6KKFVTYJDUPLERQZ7B7TU2N6VEMIR7AOUY6R46A6VVAFTVA5VAC

Dependencies

  • [2] X7MRZ5CL some copy changes
  • [3] NV4WC3K4 new example: interactivity
  • [4] VEAVIL4X resize handler
  • [5] VUF2SX7B implement carousel buttons for inserting/switching current pane
  • [6] J6O7HP7J new example: draw and update callbacks
  • [7] 5RUFNRJO start of the visual skeleton
  • [8] VAVXKWZV aggregate global state inside a 'pane' object
  • [9] OOSUBWKX subject people to a tutorial
  • [*] ZM7NOBRM new fork: carousel shell

Change contents

  • replacement in 0078-Example_panes at line 1
    [4.1][4.2:110]()
    -- some examples
    -- each element of this array is itself an array of lines that will get loaded into a pane
    [4.1]
    [4.110]
    -- some examples that each get loaded into a pane
    -- each example has a name, so we can avoid bringing back up an example someone deleted.
  • replacement in 0078-Example_panes at line 5
    [4.131][2.27:161](),[2.161][4.264:288](),[4.264][4.264:288](),[4.288][2.162:283](),[2.283][4.407:415](),[4.407][4.407:415]()
    "-- 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'
    [4.131]
    [4.415]
    name='expr',
    lines={
    "-- Some examples; feel free to delete them and they'll never return.",
    '-- First example: you can perform simple calculations.',
    "-- (scroll down if you're on a small screen..)",
    "-- Try hitting the 'run' button above.",
    "-- When you're done, tap on the right margin to go to the next example.",
    '2+3',
    }
  • replacement in 0078-Example_panes at line 16
    [4.422][2.284:388](),[2.388][4.524:556](),[4.524][4.524:556]()
    '-- print() calls show up in the area below.',
    "-- Hit 'run' and then scroll through the results.",
    'for i=1,20 do print(i) end',
    [4.422]
    [4.556]
    name='print',
    lines={
    '-- print() calls show up in the area below.',
    "-- Hit 'run' and then scroll through the results.",
    'for i=1,20 do print(i) end',
    },
  • replacement in 0078-Example_panes at line 24
    [4.563][2.389:474](),[2.474][4.646:687](),[4.646][4.646:687]()
    '-- You can draw on the screen.',
    "-- After you hit 'run', try hitting 'hide'.",
    'love.graphics.line(100,100, 200,300)'
    [4.563]
    [4.687]
    name='draw',
    lines={
    '-- You can draw on the screen.',
    "-- After you hit 'run', try hitting 'hide'.",
    'love.graphics.line(100,100, 200,300)',
    },
  • replacement in 0078-Example_panes at line 32
    [4.694][4.694:803]()
    '-- some color',
    'love.graphics.setColor(1,0,0)',
    "love.graphics.rectangle('fill', 100,100, 200,300)",
    [4.694]
    [4.803]
    name='color',
    lines={
    '-- some color',
    'love.graphics.setColor(1,0,0)',
    "love.graphics.rectangle('fill', 100,100, 200,300)",
    },
  • replacement in 0078-Example_panes at line 40
    [4.810][2.475:570](),[2.570][4.904:1197](),[4.904][4.904:1197](),[4.1197][4.51:60]()
    '-- 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',
    [4.810]
    [4.60]
    name='pattern',
    lines={
    '-- 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',
    },
  • replacement in 0078-Example_panes at line 58
    [4.67][3.101:188](),[3.188][4.172:225](),[4.172][4.172:225](),[4.225][3.189:376](),[3.376][4.418:575](),[4.418][4.418:575](),[4.575][4.1197:1206](),[4.1197][4.1197:1206](),[4.1206][4.576:743](),[4.743][3.377:386]()
    '-- For animations, you can define various functions that will get called for you.',
    '-- LÖVE supports functions of the form love.*,',
    '-- for example, love.draw, love.update, etc.',
    "-- You can't define those directly because Carousel Shell needs to define them for its UI, but you can define your own under car.*,",
    '-- for example, car.draw, car.update, etc.',
    'Radius, dRadius = 100, 10',
    'function car.draw()',
    " love.graphics.circle('fill', 100,100, Radius)",
    'end',
    '',
    'function car.update(dt)',
    ' Radius = Radius+dRadius',
    ' if Radius > 500 then dRadius = -dRadius end',
    ' if Radius < 30 then dRadius = -dRadius end',
    'end',
    [4.67]
    [3.386]
    name='animation',
    lines={
    '-- For animations, you can define various functions that will get called for you.',
    '-- LÖVE supports functions of the form love.*,',
    '-- for example, love.draw, love.update, etc.',
    "-- You can't define those directly because Carousel Shell needs to define them for its UI, but you can define your own under car.*,",
    '-- for example, car.draw, car.update, etc.',
    'Radius, dRadius = 100, 10',
    'function car.draw()',
    " love.graphics.circle('fill', 100,100, Radius)",
    'end',
    '',
    'function car.update(dt)',
    ' Radius = Radius+dRadius',
    ' if Radius > 500 then dRadius = -dRadius end',
    ' if Radius < 30 then dRadius = -dRadius end',
    'end',
    },
  • replacement in 0078-Example_panes at line 78
    [3.393][3.393:1173](),[3.1173][4.743:752](),[4.743][4.743:752](),[4.752][3.1174:1387]()
    '-- For interactivity, LÖVE provides functions like love.keypressed, love.mousepressed, etc.',
    '-- As before, define the corresponding car.keypressed, car.mousepressed, etc.',
    "-- A pane's interactive events only activate when the editor is hidden using the 'hide' button above.",
    "-- Try running this example and then pressing and holding the mouse and pressing and releasing keys.",
    '-- Then try hiding the editor and again pressing and holding the mouse and pressing and releasing keys',
    'X, Y, dX = 100, 0, 10',
    "Log = ''",
    '',
    'function car.draw()',
    ' love.graphics.line(X,Y, X,Y+300)',
    ' love.graphics.print(Log, 50,50)',
    'end',
    '',
    'function car.update(dt)',
    ' if X > 500 then dX = -dX end',
    ' if X < 100 then dX = -dX end',
    ' X = X+dX',
    'end',
    '',
    'function car.mousepressed(x,y, button)',
    ' Y = y',
    'end',
    '',
    'function car.mousereleased(x,y, button)',
    ' Y = 0',
    'end',
    '',
    'function car.keypressed(key)',
    ' Log = Log..key',
    'end',
    [3.393]
    [4.1206]
    name='interactive',
    lines={
    '-- For interactivity, LÖVE provides functions like love.keypressed, love.mousepressed, etc.',
    '-- As before, define the corresponding car.keypressed, car.mousepressed, etc.',
    "-- A pane's interactive events only activate when the editor is hidden using the 'hide' button above.",
    "-- Try running this example and then pressing and holding the mouse and pressing and releasing keys.",
    '-- Then try hiding the editor and again pressing and holding the mouse and pressing and releasing keys',
    'X, Y, dX = 100, 0, 10',
    "Log = ''",
    '',
    'function car.draw()',
    ' love.graphics.line(X,Y, X,Y+300)',
    ' love.graphics.print(Log, 50,50)',
    'end',
    '',
    'function car.update(dt)',
    ' if X > 500 then dX = -dX end',
    ' if X < 100 then dX = -dX end',
    ' X = X+dX',
    'end',
    '',
    'function car.mousepressed(x,y, button)',
    ' Y = y',
    'end',
    '',
    'function car.mousereleased(x,y, button)',
    ' Y = 0',
    'end',
    '',
    'function car.keypressed(key)',
    ' Log = Log..key',
    'end',
    },
  • replacement in 0078-Example_panes at line 113
    [4.1213][2.571:616](),[2.616][4.1257:1466](),[4.1257][4.1257:1466](),[4.1466][2.617:659](),[2.659][4.1507:1601](),[4.1507][4.1507:1601](),[4.1601][4.753:845]()
    '-- 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)",
    '-- once you load this pane, the abbreviations here will be available in any other pane',
    [4.1213]
    [4.1601]
    name='abbreviations',
    lines={
    '-- 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)",
    '-- once you load this pane, the abbreviations here will be available in any other pane',
    },
  • replacement in 0078-Example_panes at line 127
    [4.1608][2.660:715](),[2.715][4.1660:1669](),[4.1660][4.1660:1669]()
    "-- Over to you. We hope you enjoy Carousel Shell!",
    '',
    }
    [4.1608]
    [4.1669]
    name='beginning',
    lines={
    "-- Over to you. We hope you enjoy Carousel Shell!",
    '',
    },
    },
  • replacement in 0077-example_pane at line 1
    [4.1715][4.1716:1747]()
    example_pane = function(lines)
    [4.1715]
    [4.1747]
    example_pane = function(name, lines)
  • edit in 0077-example_pane at line 3
    [4.1774]
    [4.1774]
    result.name = name
  • replacement in 0011-on.initialize at line 9
    [4.2084][4.2001:2043]()
    Panes = map(Example_panes, example_pane)
    [4.2084]
    [4.2248]
    load_example_panes()