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:
- to write the main program in such a way that it is easy for people to add their plugins.
- 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:
- be a single subroutine.
- have a name that can be obtained from the plugin, so that it can be selected.
- 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:
- Change brush color.
- Change pen thickness.
- Draw random colored stars as the mouse moves.
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
prevX = GraphicsWindow.MouseX
prevY = GraphicsWindow.MouseY
GraphicsWindow.DrawLine(prevX, prevY, x, y)