Vai al contenuto

Group Challenge 2014-07

Questa sfida di gruppo appare nella sfida mensile di luglio 2014


This challenge is to create an extensible ‘Paint’ program with plugins.

There are several paint type programs in Small Basic – they mostly consist of drawing on a window following a mouse when a mouse button is clicked and held down.

The idea of this challenge is:

  1. to write the main program in such a way that it is easy for people to add their plugins.
  2. to write fun plugins.

A plugin may be as simple as changing the line width or color, or more complicated like drawing stars or any other feature.

The plugins should:

  1. be a single subroutine.
  2. have a name that can be obtained from the plugin, so that it can be selected.
  3. either perform drawing actions when the mouse is moved while a mouse button is down or change some property.

Quite a bit of thought will be needed to design the program so that plugins can work well, be selectable etc.  Perhaps plugins need to also be added to a text file list of plug-ins?

Examples of plugins could be:

  1. Change brush color.
  2. Change pen thickness.
  3. Draw random colored stars as the mouse moves.
  4. Eraser.

The program itself should have only a very basic plugin example and it is up to other contributors to create their plug-ins meeting the required specification.

I recommend some discussion/collaboration of ideas before coding, perhaps start from the example in the ‘Introducing Small Basic’ guide.

GraphicsWindow.MouseMove = OnMouseMove
GraphicsWindow.MouseDown = OnMouseDown
Sub OnMouseDown
   prevX = GraphicsWindow.MouseX
   prevY = GraphicsWindow.MouseY
Sub OnMouseMove
   If(Mouse.IsLeftButtonDown) Then
      GraphicsWindow.DrawLine(prevX, prevY,  x, y)

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.