<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="sv">
	<id>https://docs.moodle.org/4x/sv/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Robodesign</id>
	<title>MoodleDocs - Användarbidrag [sv]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/4x/sv/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Robodesign"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/Special:Bidrag/Robodesign"/>
	<updated>2026-05-10T22:55:44Z</updated>
	<subtitle>Användarbidrag</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=66620</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=66620"/>
		<updated>2009-12-24T19:30:58Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Summary */ making the project status more obvious, linking to the paint tool integration wiki page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Project status:&#039;&#039;&#039; Completed. ([[Development:Paint_tool_integration|see results]])&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;October 12, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=134995 PaintWeb for 1.9.x].&lt;br /&gt;
* &#039;&#039;&#039;October 9, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=134819 PaintWeb integration ready for merge].&lt;br /&gt;
* &#039;&#039;&#039;October 7, 2009:&#039;&#039;&#039; Wiki page: [http://code.google.com/p/paintweb/wiki/MoodleIntegration Moodle integration technical details].&lt;br /&gt;
* &#039;&#039;&#039;September 7, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-and-paintweb-test-site Moodle 2.0 and PaintWeb test site].&lt;br /&gt;
* &#039;&#039;&#039;August 31, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-presentation-at-lvle-2009 PaintWeb presentation at LVLE 2009].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Forum discussion: [http://dev.moodle.org/mod/forum/discuss.php?d=667 GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=64928</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=64928"/>
		<updated>2009-11-05T14:03:13Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to a forum discussion thread by Martin: PaintWeb for 1.9.x&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;October 12, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=134995 PaintWeb for 1.9.x].&lt;br /&gt;
* &#039;&#039;&#039;October 9, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=134819 PaintWeb integration ready for merge].&lt;br /&gt;
* &#039;&#039;&#039;October 7, 2009:&#039;&#039;&#039; Wiki page: [http://code.google.com/p/paintweb/wiki/MoodleIntegration Moodle integration technical details].&lt;br /&gt;
* &#039;&#039;&#039;September 7, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-and-paintweb-test-site Moodle 2.0 and PaintWeb test site].&lt;br /&gt;
* &#039;&#039;&#039;August 31, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-presentation-at-lvle-2009 PaintWeb presentation at LVLE 2009].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Forum discussion: [http://dev.moodle.org/mod/forum/discuss.php?d=667 GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=64137</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=64137"/>
		<updated>2009-10-09T10:18:51Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to forum discussion: PaintWeb integration ready for merge&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;October 9, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=134819 PaintWeb integration ready for merge].&lt;br /&gt;
* &#039;&#039;&#039;October 7, 2009:&#039;&#039;&#039; Wiki page: [http://code.google.com/p/paintweb/wiki/MoodleIntegration Moodle integration technical details].&lt;br /&gt;
* &#039;&#039;&#039;September 7, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-and-paintweb-test-site Moodle 2.0 and PaintWeb test site].&lt;br /&gt;
* &#039;&#039;&#039;August 31, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-presentation-at-lvle-2009 PaintWeb presentation at LVLE 2009].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Forum discussion: [http://dev.moodle.org/mod/forum/discuss.php?d=667 GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=64038</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=64038"/>
		<updated>2009-10-07T19:05:36Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to a new wiki page about paintweb integration into moodle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;October 7, 2009:&#039;&#039;&#039; Wiki page: [http://code.google.com/p/paintweb/wiki/MoodleIntegration Moodle integration technical details].&lt;br /&gt;
* &#039;&#039;&#039;September 7, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-and-paintweb-test-site Moodle 2.0 and PaintWeb test site].&lt;br /&gt;
* &#039;&#039;&#039;August 31, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-presentation-at-lvle-2009 PaintWeb presentation at LVLE 2009].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Forum discussion: [http://dev.moodle.org/mod/forum/discuss.php?d=667 GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=64037</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=64037"/>
		<updated>2009-10-07T18:54:38Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: including a link to further details about paintweb integration into moodle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;image&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;br /&gt;
&lt;br /&gt;
= Image load/save in PaintWeb =&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Data_URI_scheme data URI scheme] allows Web developers to include raw binary content inside HTML, CSS and JavaScript documents. This scheme holds the binary data using base64 encoding which makes it ideal most of the time for small binary files. PaintWeb builds use image data URLs inside CSS to avoid loading tens of separate PNG icons. Almost anywhere you can provide an URL, say inside an &amp;lt;img src&amp;gt; tag, you can use a data URL instead. &lt;br /&gt;
&lt;br /&gt;
Loading an image inside PaintWeb is a matter of only having a reference to a DOM image element in the page. The browser can immediately render the image element inside the Canvas, such that PaintWeb can edit the pixels. It&#039;s only simple code like &#039;&#039;&#039;canvas2dcontext.drawImage(imageElement, x, y)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Saving an image from PaintWeb is similarly easy: &#039;&#039;&#039;canvasElement.toDataURL()&#039;&#039;&#039;. This tells the browser to return the image in PNG format, base64-encoded. The value can be POSTed via a simple HTML form or via an XMLHttpRequest. Note: this value is NOT a file! This is a typical JavaScript string, and the server-side scripts recognize it like any other string. It is up to the server-side script to base64-decode the value and save it as a file. From PHP doing this is trivial:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
file_put_contents(&#039;image.png&#039;, base64_decode($base64_value));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Images from different servers than those of the page running the scripts can be rendered inside Canvas, but when they are rendered, they mark the Canvas element as &amp;quot;dirty&amp;quot; due to security concerns. Once this happens, browsers no longer allow methods like &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039; - or any other method which provides access to read the pixels.&lt;br /&gt;
&lt;br /&gt;
Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) consider as &amp;quot;external resource&amp;quot; any image element which uses a data URL as a value of the src attribute. This pretty much means that images with data URLs cannot be directly edited and saved by PaintWeb, unless workarounds are used for these browsers. The work around consists of taking the image data URL, POSTing it using an XMLHttpRequest to a server-side script which saves the image file as a binary (base64-decoded), and returns the URL pointing to the file on the server. Only after that PaintWeb can use the image element. Luckily Firefox 3.5 (Gecko 1.9.1) fixes this issue.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 1.9 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 1.9, the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] and [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branches over at [http://repo.or.cz repo.or.cz]. The mdl19-tinymce3 branch builds upon the [http://moodle.org/mod/forum/discuss.php?d=107550 TinyMCE 3 patches] published by Martin Langhoff in october 2008. I took his work and updated it to the latest Moodle 1.9 stable branch, updated TinyMCE 3 to the latest version and made some additional fixes needed for PaintWeb. The commit change logs provide detailed information on what I did.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] branch starts from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce.js.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$CFG-&amp;gt;tinymcePaintWeb&#039;&#039;&#039; is set to true.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have three scripts in &#039;&#039;&#039;lib/paintweb/ext/moodle&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_moodlelang.php&#039;&#039;&#039; generates the Moodle language files (PHP) from PaintWeb language files (JSON). This updates &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039; - depending on the JSON language files included in the PaintWeb packages.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_paintweblang.php&#039;&#039;&#039; generates the PaintWeb language files (JSON) from Moodle language files (PHP). This can be used when a translator updates some &#039;&#039;&#039;paintweb.php&#039;&#039;&#039; language file to regenerate the PaintWeb JSON file.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lang.json.php&#039;&#039;&#039; is used by PaintWeb inside Moodle when it loads. This PHP script is similar to that of TinyMCE. It outputs a JSON language file, dynamically generated using the Moodle API, with the configured language, from the Moodle PHP language files.&lt;br /&gt;
&lt;br /&gt;
All in all, the localization integration seems fine for me. I am only bothered that each time lang.json.php loads, it generates the JSON dynamically, which uses server-side resources for something quite static (language files seldom change). It does have HTTP caching headers and that certainly helps.&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb hides the textarea icons added by Moodle (those two icons below the textarea), when PaintWeb is shown, and it implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented in two ways:&lt;br /&gt;
&lt;br /&gt;
* images are saved using [http://en.wikipedia.org/wiki/Data_URI_scheme data URLs]. This means that instead of using files on the server, the whole image is saved inside the HTML generated by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* images are saved using files inside the Moodle data directory, without using any data URLs (only transiently). &lt;br /&gt;
&lt;br /&gt;
To change between the two file save methods, you only need to edit &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039; (search for &#039;&#039;&#039;moodleSaveMethod&#039;&#039;&#039;). Each save method has its own advantages and disadvantages presented below.&lt;br /&gt;
&lt;br /&gt;
Martin Langhoff, my mentor, has posted a relevant thread about [http://moodle.org/mod/forum/discuss.php?d=129634 storing images as attachements to text fields]. It&#039;s worth reading!&lt;br /&gt;
&lt;br /&gt;
=== Data URLs ===&lt;br /&gt;
&lt;br /&gt;
Saving the images using data URLs has the important advantage of being very easy to implement: just install the PaintWeb plugin inside TinyMCE. This requires no additional file security measures, storage, etc.&lt;br /&gt;
&lt;br /&gt;
The disadvantages are:&lt;br /&gt;
&lt;br /&gt;
* Data URLs do not work in IE 6 / 7 and thus require ugly work-arounds.&lt;br /&gt;
&lt;br /&gt;
* Loading PaintWeb to edit an image with a data URL always requires that the image data URL is sent to the server, saved on disk temporarily, and served back as a binary. As explained above, this is required only for Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) due to security constrains. The script used for saving the image on disk is &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039;. The file saved inside the Moodle data dir. The script which serves the images from the Moodle data dir is &#039;&#039;&#039;lib/paintweb/ext/moodle/imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Vanilla TinyMCE 3 builds mangle/corrupt data URLs, so they need to be patched. The patch is trivial and we will most likely get it into official builds really soon.&lt;br /&gt;
&lt;br /&gt;
* Users with images disabled still load the data URLs.&lt;br /&gt;
&lt;br /&gt;
* Page size increases from a few KB to almost MB or several megabytes. The small image I have in my TinyMCE demo uses 800kb for the data URL. I imagine usage scenarios from kids who have digital cameras which save much bigger images (like over 1280x1024), and they want to edit these images in Moodle.&lt;br /&gt;
&lt;br /&gt;
* Images do not cache at all, affecting the perceived performance of Moodle, and it especially affects users of slow connections (OLPC XO wireless is typically slow).&lt;br /&gt;
&lt;br /&gt;
* I presume images with data URLs use more memory.&lt;br /&gt;
&lt;br /&gt;
* Moodle server-side scripts and the database structure does not allow textarea content to hold so much raw data. The default image included in my TinyMCE does not fit in a typical Moodle textarea (only about quarter of it). For proper support of images with data URLs Moodle needs to be patched to allow much bigger textarea content (at least 5-10 MB).&lt;br /&gt;
&lt;br /&gt;
* Images with data URLs require about 37% more storage (due to the use of base64 encoding).&lt;br /&gt;
&lt;br /&gt;
* TinyMCE does some amount of raw HTML processing (with regex at times) which is slowed down quite much when images with data URLs are used. On my Athlon XP 1800+ I usually get the &amp;quot;a script is running slow, do you want to stop script execution&amp;quot; message from Firefox. Similarly, I think server-side HTML filters in Moodle are slowed down when image data URLs are used.&lt;br /&gt;
&lt;br /&gt;
=== File storage ===&lt;br /&gt;
&lt;br /&gt;
When PaintWeb is configured to save images using the Moodle file storage, any save operation consists of retrieving the image from the browser, in the form of a data URL: &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039;. The value is POSTed using an XMLHttpRequest to the server-side script &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039; which saves the image inside the Moodle data dir configured by the value of &#039;&#039;&#039;$CFG-&amp;gt;paintwebImagesFolder&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the image being edited by the user comes from a course then the image file is directly updated and no new file is created. If the security checks fail, then a new image is created.&lt;br /&gt;
&lt;br /&gt;
When new images are created their file names represent the unique sha1 of their content.&lt;br /&gt;
&lt;br /&gt;
The client-side scripts typically expect that the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script returns the new image URL, when an image is saved. Since the images are saved in the Moodle data dir, a new server-side script was required which is able to serve the desired image. This script is &#039;&#039;&#039;imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Advantages:&#039;&#039;&#039; the current file storage does not require a rewrite of any database structure. Textarea content always points to URL on the Moodle server, no data URLs are used. Image saving and loading is quick, and the image files are cached by the browser - the user experience is very good.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Disadvantages:&#039;&#039;&#039; there&#039;s a concern related to security. Who edits what? Who views what? Currently only course images are edited in-place, otherwise all images are considered &amp;quot;new&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the use of hashes for the image file names is for security purposes. Nobody can overwrite any of the existing images, since their file name is a unique hash of the content. Additionally, nobody can really guess the address of an image of another user - unless, obviously, you are given the address (and the hash) to it. Thus you are also given the right to view the image.&lt;br /&gt;
&lt;br /&gt;
Another important concern is that the Moodle data directory ends-up having far too many image files which need to be deleted, because they are unused. The matter of tracking which image is used/unused is not trivial. We are currently trying to determine the best approach to solving these issues. Any ideas are welcome.&lt;br /&gt;
&lt;br /&gt;
Then there&#039;s the problem of backing-up and restoring courses...&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Personally I prefer that PaintWeb uses files to save the images, since it&#039;s faster and cleaner. User interaction is also much better.&lt;br /&gt;
&lt;br /&gt;
I would like Moodle developers to check the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script and provide their feedback and suggestions for improvements.&lt;br /&gt;
&lt;br /&gt;
Further integration work can be done for Moodleforms and I could also create a script with some API to allow developers to include the paint tool stand-alone in any page they want. This depends on what Martin Langhoff, my mentor, decides.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 2.0 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 2.0 (CVS HEAD), the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl20-paintweb mdl20-paintweb] branch over at [http://repo.or.cz repo.or.cz].&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl20-paintweb mdl20-paintweb] branch starts from the Moodle 2.0 CVS HEAD branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/editor_tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce/lib.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$options[&#039;maxfiles&#039;]&#039;&#039;&#039; is not 0. Additionally, developers can disable PaintWeb by setting &#039;&#039;&#039;$options[&#039;plugin/paintweb&#039;]&#039;&#039;&#039; to false.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have the same scripts, as for the Moodle 1.9 integration. See the details about the [[Development:Paint_tool_integration#Localization_2|Moodle 1.9 localization integration]].&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
You can [http://code.google.com/p/paintweb/wiki/MoodleIntegration read more about how PaintWeb glues into Moodle].&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented using the [[Development:Using_the_File_API|new File API]]. The idea is that textareas have draft file areas which holds files attached to them. The &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave20.php&#039;&#039;&#039; script saves the image in the draft file area of the textarea where the user edits the article. The client-side PaintWeb scripts determine the context ID and the draft item ID associated to the textarea. When the image save action is invoked, the script receives them, and uses them to save the image. The URL of the draft file is generated by the Moodle File API, and returned to the client-side code, which updates the image URL.&lt;br /&gt;
&lt;br /&gt;
Moodle should handle the garbage collection (automatic deletion of obsolete files). Once the user submits the form containing the textarea, all the image URLs are updated to point to a permanent file area - they are moved out of the temporary/draft file area. Again, this does no longer depends on PaintWeb.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
I am very happy to see the numerous improvements made for Moodle 2, especially the new File API. Now PaintWeb saves images properly inside Moodle. These new files are backed-up, restored, cached and nicely usable in general.&lt;br /&gt;
&lt;br /&gt;
A further integration point could be Moodleforms, but I am not sure. Heard of plans for rewrites.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=62644</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=62644"/>
		<updated>2009-09-07T16:37:49Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to the latest blog post: Moodle 2.0 and PaintWeb test site&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;September 7, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-and-paintweb-test-site Moodle 2.0 and PaintWeb test site].&lt;br /&gt;
* &#039;&#039;&#039;August 31, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-presentation-at-lvle-2009 PaintWeb presentation at LVLE 2009].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Forum discussion: [http://dev.moodle.org/mod/forum/discuss.php?d=667 GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=62257</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=62257"/>
		<updated>2009-08-31T17:20:02Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to the latest blog post: PaintWeb presentation at LVLE 2009.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 31, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-presentation-at-lvle-2009 PaintWeb presentation at LVLE 2009].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Forum discussion: [http://dev.moodle.org/mod/forum/discuss.php?d=667 GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61906</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61906"/>
		<updated>2009-08-21T12:05:44Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to the latest forum discussion: GSOC conclusions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Forum discussion: [http://dev.moodle.org/mod/forum/discuss.php?d=667 GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61905</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61905"/>
		<updated>2009-08-21T11:45:48Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to the latest blog post: GSOC conclusions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 21, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/gsoc-conclusions GSOC conclusions].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61745</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61745"/>
		<updated>2009-08-19T09:27:39Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Summary */ link to the new tracker issue MDL-20124&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issues:&#039;&#039;&#039; CONTRIB-1456, MDL-20124;&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion:&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog:&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog Mihai&#039;s blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61586</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61586"/>
		<updated>2009-08-14T16:16:58Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ include link to the latest forum discussion where I ask for feedback from developers for my Moodle 2 integration work.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/CONTRIB-1456]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=130337 Feedback wanted: Paint tool integration into Moodle 2].&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61582</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=61582"/>
		<updated>2009-08-14T11:46:55Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to the latest blog post: Moodle 2.0 integration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/CONTRIB-1456]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/moodle-2-0-integration Moodle 2.0 integration]. I also updated the [[Development:Paint_tool_integration|Paint tool integration]] wiki page, to include technical details about my work on Moodle 2.&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [[Development:Paint_tool_integration|Paint tool integration planning]].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=61581</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=61581"/>
		<updated>2009-08-14T11:29:55Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Image load and save */ link to the thread posted by Martin Langhoff about storing images as attachements to text fields in Moodle 1.9&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;image&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;br /&gt;
&lt;br /&gt;
= Image load/save in PaintWeb =&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Data_URI_scheme data URI scheme] allows Web developers to include raw binary content inside HTML, CSS and JavaScript documents. This scheme holds the binary data using base64 encoding which makes it ideal most of the time for small binary files. PaintWeb builds use image data URLs inside CSS to avoid loading tens of separate PNG icons. Almost anywhere you can provide an URL, say inside an &amp;lt;img src&amp;gt; tag, you can use a data URL instead. &lt;br /&gt;
&lt;br /&gt;
Loading an image inside PaintWeb is a matter of only having a reference to a DOM image element in the page. The browser can immediately render the image element inside the Canvas, such that PaintWeb can edit the pixels. It&#039;s only simple code like &#039;&#039;&#039;canvas2dcontext.drawImage(imageElement, x, y)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Saving an image from PaintWeb is similarly easy: &#039;&#039;&#039;canvasElement.toDataURL()&#039;&#039;&#039;. This tells the browser to return the image in PNG format, base64-encoded. The value can be POSTed via a simple HTML form or via an XMLHttpRequest. Note: this value is NOT a file! This is a typical JavaScript string, and the server-side scripts recognize it like any other string. It is up to the server-side script to base64-decode the value and save it as a file. From PHP doing this is trivial:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
file_put_contents(&#039;image.png&#039;, base64_decode($base64_value));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Images from different servers than those of the page running the scripts can be rendered inside Canvas, but when they are rendered, they mark the Canvas element as &amp;quot;dirty&amp;quot; due to security concerns. Once this happens, browsers no longer allow methods like &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039; - or any other method which provides access to read the pixels.&lt;br /&gt;
&lt;br /&gt;
Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) consider as &amp;quot;external resource&amp;quot; any image element which uses a data URL as a value of the src attribute. This pretty much means that images with data URLs cannot be directly edited and saved by PaintWeb, unless workarounds are used for these browsers. The work around consists of taking the image data URL, POSTing it using an XMLHttpRequest to a server-side script which saves the image file as a binary (base64-decoded), and returns the URL pointing to the file on the server. Only after that PaintWeb can use the image element. Luckily Firefox 3.5 (Gecko 1.9.1) fixes this issue.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 1.9 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 1.9, the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] and [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branches over at [http://repo.or.cz repo.or.cz]. The mdl19-tinymce3 branch builds upon the [http://moodle.org/mod/forum/discuss.php?d=107550 TinyMCE 3 patches] published by Martin Langhoff in october 2008. I took his work and updated it to the latest Moodle 1.9 stable branch, updated TinyMCE 3 to the latest version and made some additional fixes needed for PaintWeb. The commit change logs provide detailed information on what I did.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] branch starts from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce.js.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$CFG-&amp;gt;tinymcePaintWeb&#039;&#039;&#039; is set to true.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have three scripts in &#039;&#039;&#039;lib/paintweb/ext/moodle&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_moodlelang.php&#039;&#039;&#039; generates the Moodle language files (PHP) from PaintWeb language files (JSON). This updates &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039; - depending on the JSON language files included in the PaintWeb packages.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_paintweblang.php&#039;&#039;&#039; generates the PaintWeb language files (JSON) from Moodle language files (PHP). This can be used when a translator updates some &#039;&#039;&#039;paintweb.php&#039;&#039;&#039; language file to regenerate the PaintWeb JSON file.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lang.json.php&#039;&#039;&#039; is used by PaintWeb inside Moodle when it loads. This PHP script is similar to that of TinyMCE. It outputs a JSON language file, dynamically generated using the Moodle API, with the configured language, from the Moodle PHP language files.&lt;br /&gt;
&lt;br /&gt;
All in all, the localization integration seems fine for me. I am only bothered that each time lang.json.php loads, it generates the JSON dynamically, which uses server-side resources for something quite static (language files seldom change). It does have HTTP caching headers and that certainly helps.&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb hides the textarea icons added by Moodle (those two icons below the textarea), when PaintWeb is shown, and it implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented in two ways:&lt;br /&gt;
&lt;br /&gt;
* images are saved using [http://en.wikipedia.org/wiki/Data_URI_scheme data URLs]. This means that instead of using files on the server, the whole image is saved inside the HTML generated by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* images are saved using files inside the Moodle data directory, without using any data URLs (only transiently). &lt;br /&gt;
&lt;br /&gt;
To change between the two file save methods, you only need to edit &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039; (search for &#039;&#039;&#039;moodleSaveMethod&#039;&#039;&#039;). Each save method has its own advantages and disadvantages presented below.&lt;br /&gt;
&lt;br /&gt;
Martin Langhoff, my mentor, has posted a relevant thread about [http://moodle.org/mod/forum/discuss.php?d=129634 storing images as attachements to text fields]. It&#039;s worth reading!&lt;br /&gt;
&lt;br /&gt;
=== Data URLs ===&lt;br /&gt;
&lt;br /&gt;
Saving the images using data URLs has the important advantage of being very easy to implement: just install the PaintWeb plugin inside TinyMCE. This requires no additional file security measures, storage, etc.&lt;br /&gt;
&lt;br /&gt;
The disadvantages are:&lt;br /&gt;
&lt;br /&gt;
* Data URLs do not work in IE 6 / 7 and thus require ugly work-arounds.&lt;br /&gt;
&lt;br /&gt;
* Loading PaintWeb to edit an image with a data URL always requires that the image data URL is sent to the server, saved on disk temporarily, and served back as a binary. As explained above, this is required only for Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) due to security constrains. The script used for saving the image on disk is &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039;. The file saved inside the Moodle data dir. The script which serves the images from the Moodle data dir is &#039;&#039;&#039;lib/paintweb/ext/moodle/imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Vanilla TinyMCE 3 builds mangle/corrupt data URLs, so they need to be patched. The patch is trivial and we will most likely get it into official builds really soon.&lt;br /&gt;
&lt;br /&gt;
* Users with images disabled still load the data URLs.&lt;br /&gt;
&lt;br /&gt;
* Page size increases from a few KB to almost MB or several megabytes. The small image I have in my TinyMCE demo uses 800kb for the data URL. I imagine usage scenarios from kids who have digital cameras which save much bigger images (like over 1280x1024), and they want to edit these images in Moodle.&lt;br /&gt;
&lt;br /&gt;
* Images do not cache at all, affecting the perceived performance of Moodle, and it especially affects users of slow connections (OLPC XO wireless is typically slow).&lt;br /&gt;
&lt;br /&gt;
* I presume images with data URLs use more memory.&lt;br /&gt;
&lt;br /&gt;
* Moodle server-side scripts and the database structure does not allow textarea content to hold so much raw data. The default image included in my TinyMCE does not fit in a typical Moodle textarea (only about quarter of it). For proper support of images with data URLs Moodle needs to be patched to allow much bigger textarea content (at least 5-10 MB).&lt;br /&gt;
&lt;br /&gt;
* Images with data URLs require about 37% more storage (due to the use of base64 encoding).&lt;br /&gt;
&lt;br /&gt;
* TinyMCE does some amount of raw HTML processing (with regex at times) which is slowed down quite much when images with data URLs are used. On my Athlon XP 1800+ I usually get the &amp;quot;a script is running slow, do you want to stop script execution&amp;quot; message from Firefox. Similarly, I think server-side HTML filters in Moodle are slowed down when image data URLs are used.&lt;br /&gt;
&lt;br /&gt;
=== File storage ===&lt;br /&gt;
&lt;br /&gt;
When PaintWeb is configured to save images using the Moodle file storage, any save operation consists of retrieving the image from the browser, in the form of a data URL: &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039;. The value is POSTed using an XMLHttpRequest to the server-side script &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039; which saves the image inside the Moodle data dir configured by the value of &#039;&#039;&#039;$CFG-&amp;gt;paintwebImagesFolder&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the image being edited by the user comes from a course then the image file is directly updated and no new file is created. If the security checks fail, then a new image is created.&lt;br /&gt;
&lt;br /&gt;
When new images are created their file names represent the unique sha1 of their content.&lt;br /&gt;
&lt;br /&gt;
The client-side scripts typically expect that the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script returns the new image URL, when an image is saved. Since the images are saved in the Moodle data dir, a new server-side script was required which is able to serve the desired image. This script is &#039;&#039;&#039;imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Advantages:&#039;&#039;&#039; the current file storage does not require a rewrite of any database structure. Textarea content always points to URL on the Moodle server, no data URLs are used. Image saving and loading is quick, and the image files are cached by the browser - the user experience is very good.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Disadvantages:&#039;&#039;&#039; there&#039;s a concern related to security. Who edits what? Who views what? Currently only course images are edited in-place, otherwise all images are considered &amp;quot;new&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the use of hashes for the image file names is for security purposes. Nobody can overwrite any of the existing images, since their file name is a unique hash of the content. Additionally, nobody can really guess the address of an image of another user - unless, obviously, you are given the address (and the hash) to it. Thus you are also given the right to view the image.&lt;br /&gt;
&lt;br /&gt;
Another important concern is that the Moodle data directory ends-up having far too many image files which need to be deleted, because they are unused. The matter of tracking which image is used/unused is not trivial. We are currently trying to determine the best approach to solving these issues. Any ideas are welcome.&lt;br /&gt;
&lt;br /&gt;
Then there&#039;s the problem of backing-up and restoring courses...&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Personally I prefer that PaintWeb uses files to save the images, since it&#039;s faster and cleaner. User interaction is also much better.&lt;br /&gt;
&lt;br /&gt;
I would like Moodle developers to check the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script and provide their feedback and suggestions for improvements.&lt;br /&gt;
&lt;br /&gt;
Further integration work can be done for Moodleforms and I could also create a script with some API to allow developers to include the paint tool stand-alone in any page they want. This depends on what Martin Langhoff, my mentor, decides.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 2.0 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 2.0 (CVS HEAD), the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl20-paintweb mdl20-paintweb] branch over at [http://repo.or.cz repo.or.cz].&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl20-paintweb mdl20-paintweb] branch starts from the Moodle 2.0 CVS HEAD branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/editor_tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce/lib.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$options[&#039;maxfiles&#039;]&#039;&#039;&#039; is not 0. Additionally, developers can disable PaintWeb by setting &#039;&#039;&#039;$options[&#039;plugin/paintweb&#039;]&#039;&#039;&#039; to false.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have the same scripts, as for the Moodle 1.9 integration. See the details about the [[Development:Paint_tool_integration#Localization_2|Moodle 1.9 localization integration]].&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented using the [[Development:Using_the_File_API|new File API]]. The idea is that textareas have draft file areas which holds files attached to them. The &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave20.php&#039;&#039;&#039; script saves the image in the draft file area of the textarea where the user edits the article. The client-side PaintWeb scripts determine the context ID and the draft item ID associated to the textarea. When the image save action is invoked, the script receives them, and uses them to save the image. The URL of the draft file is generated by the Moodle File API, and returned to the client-side code, which updates the image URL.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
I am very happy to see the numerous improvements made for Moodle 2, especially the new File API. Now PaintWeb saves images properly inside Moodle. These new files are backed-up, restored, cached and nicely usable in general.&lt;br /&gt;
&lt;br /&gt;
A further integration point could be Moodleforms, but I am not sure. Heard of plans for rewrites.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=61580</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=61580"/>
		<updated>2009-08-14T11:26:51Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: details about the Moodle 2.0 integration of PaintWeb&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;image&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;br /&gt;
&lt;br /&gt;
= Image load/save in PaintWeb =&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Data_URI_scheme data URI scheme] allows Web developers to include raw binary content inside HTML, CSS and JavaScript documents. This scheme holds the binary data using base64 encoding which makes it ideal most of the time for small binary files. PaintWeb builds use image data URLs inside CSS to avoid loading tens of separate PNG icons. Almost anywhere you can provide an URL, say inside an &amp;lt;img src&amp;gt; tag, you can use a data URL instead. &lt;br /&gt;
&lt;br /&gt;
Loading an image inside PaintWeb is a matter of only having a reference to a DOM image element in the page. The browser can immediately render the image element inside the Canvas, such that PaintWeb can edit the pixels. It&#039;s only simple code like &#039;&#039;&#039;canvas2dcontext.drawImage(imageElement, x, y)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Saving an image from PaintWeb is similarly easy: &#039;&#039;&#039;canvasElement.toDataURL()&#039;&#039;&#039;. This tells the browser to return the image in PNG format, base64-encoded. The value can be POSTed via a simple HTML form or via an XMLHttpRequest. Note: this value is NOT a file! This is a typical JavaScript string, and the server-side scripts recognize it like any other string. It is up to the server-side script to base64-decode the value and save it as a file. From PHP doing this is trivial:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
file_put_contents(&#039;image.png&#039;, base64_decode($base64_value));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Images from different servers than those of the page running the scripts can be rendered inside Canvas, but when they are rendered, they mark the Canvas element as &amp;quot;dirty&amp;quot; due to security concerns. Once this happens, browsers no longer allow methods like &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039; - or any other method which provides access to read the pixels.&lt;br /&gt;
&lt;br /&gt;
Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) consider as &amp;quot;external resource&amp;quot; any image element which uses a data URL as a value of the src attribute. This pretty much means that images with data URLs cannot be directly edited and saved by PaintWeb, unless workarounds are used for these browsers. The work around consists of taking the image data URL, POSTing it using an XMLHttpRequest to a server-side script which saves the image file as a binary (base64-decoded), and returns the URL pointing to the file on the server. Only after that PaintWeb can use the image element. Luckily Firefox 3.5 (Gecko 1.9.1) fixes this issue.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 1.9 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 1.9, the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] and [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branches over at [http://repo.or.cz repo.or.cz]. The mdl19-tinymce3 branch builds upon the [http://moodle.org/mod/forum/discuss.php?d=107550 TinyMCE 3 patches] published by Martin Langhoff in october 2008. I took his work and updated it to the latest Moodle 1.9 stable branch, updated TinyMCE 3 to the latest version and made some additional fixes needed for PaintWeb. The commit change logs provide detailed information on what I did.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] branch starts from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce.js.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$CFG-&amp;gt;tinymcePaintWeb&#039;&#039;&#039; is set to true.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have three scripts in &#039;&#039;&#039;lib/paintweb/ext/moodle&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_moodlelang.php&#039;&#039;&#039; generates the Moodle language files (PHP) from PaintWeb language files (JSON). This updates &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039; - depending on the JSON language files included in the PaintWeb packages.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_paintweblang.php&#039;&#039;&#039; generates the PaintWeb language files (JSON) from Moodle language files (PHP). This can be used when a translator updates some &#039;&#039;&#039;paintweb.php&#039;&#039;&#039; language file to regenerate the PaintWeb JSON file.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lang.json.php&#039;&#039;&#039; is used by PaintWeb inside Moodle when it loads. This PHP script is similar to that of TinyMCE. It outputs a JSON language file, dynamically generated using the Moodle API, with the configured language, from the Moodle PHP language files.&lt;br /&gt;
&lt;br /&gt;
All in all, the localization integration seems fine for me. I am only bothered that each time lang.json.php loads, it generates the JSON dynamically, which uses server-side resources for something quite static (language files seldom change). It does have HTTP caching headers and that certainly helps.&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb hides the textarea icons added by Moodle (those two icons below the textarea), when PaintWeb is shown, and it implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented in two ways:&lt;br /&gt;
&lt;br /&gt;
* images are saved using [http://en.wikipedia.org/wiki/Data_URI_scheme data URLs]. This means that instead of using files on the server, the whole image is saved inside the HTML generated by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* images are saved using files inside the Moodle data directory, without using any data URLs (only transiently). &lt;br /&gt;
&lt;br /&gt;
To change between the two file save methods, you only need to edit &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039; (search for &#039;&#039;&#039;moodleSaveMethod&#039;&#039;&#039;). Each save method has its own advantages and disadvantages presented below.&lt;br /&gt;
&lt;br /&gt;
=== Data URLs ===&lt;br /&gt;
&lt;br /&gt;
Saving the images using data URLs has the important advantage of being very easy to implement: just install the PaintWeb plugin inside TinyMCE. This requires no additional file security measures, storage, etc.&lt;br /&gt;
&lt;br /&gt;
The disadvantages are:&lt;br /&gt;
&lt;br /&gt;
* Data URLs do not work in IE 6 / 7 and thus require ugly work-arounds.&lt;br /&gt;
&lt;br /&gt;
* Loading PaintWeb to edit an image with a data URL always requires that the image data URL is sent to the server, saved on disk temporarily, and served back as a binary. As explained above, this is required only for Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) due to security constrains. The script used for saving the image on disk is &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039;. The file saved inside the Moodle data dir. The script which serves the images from the Moodle data dir is &#039;&#039;&#039;lib/paintweb/ext/moodle/imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Vanilla TinyMCE 3 builds mangle/corrupt data URLs, so they need to be patched. The patch is trivial and we will most likely get it into official builds really soon.&lt;br /&gt;
&lt;br /&gt;
* Users with images disabled still load the data URLs.&lt;br /&gt;
&lt;br /&gt;
* Page size increases from a few KB to almost MB or several megabytes. The small image I have in my TinyMCE demo uses 800kb for the data URL. I imagine usage scenarios from kids who have digital cameras which save much bigger images (like over 1280x1024), and they want to edit these images in Moodle.&lt;br /&gt;
&lt;br /&gt;
* Images do not cache at all, affecting the perceived performance of Moodle, and it especially affects users of slow connections (OLPC XO wireless is typically slow).&lt;br /&gt;
&lt;br /&gt;
* I presume images with data URLs use more memory.&lt;br /&gt;
&lt;br /&gt;
* Moodle server-side scripts and the database structure does not allow textarea content to hold so much raw data. The default image included in my TinyMCE does not fit in a typical Moodle textarea (only about quarter of it). For proper support of images with data URLs Moodle needs to be patched to allow much bigger textarea content (at least 5-10 MB).&lt;br /&gt;
&lt;br /&gt;
* Images with data URLs require about 37% more storage (due to the use of base64 encoding).&lt;br /&gt;
&lt;br /&gt;
* TinyMCE does some amount of raw HTML processing (with regex at times) which is slowed down quite much when images with data URLs are used. On my Athlon XP 1800+ I usually get the &amp;quot;a script is running slow, do you want to stop script execution&amp;quot; message from Firefox. Similarly, I think server-side HTML filters in Moodle are slowed down when image data URLs are used.&lt;br /&gt;
&lt;br /&gt;
=== File storage ===&lt;br /&gt;
&lt;br /&gt;
When PaintWeb is configured to save images using the Moodle file storage, any save operation consists of retrieving the image from the browser, in the form of a data URL: &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039;. The value is POSTed using an XMLHttpRequest to the server-side script &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039; which saves the image inside the Moodle data dir configured by the value of &#039;&#039;&#039;$CFG-&amp;gt;paintwebImagesFolder&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the image being edited by the user comes from a course then the image file is directly updated and no new file is created. If the security checks fail, then a new image is created.&lt;br /&gt;
&lt;br /&gt;
When new images are created their file names represent the unique sha1 of their content.&lt;br /&gt;
&lt;br /&gt;
The client-side scripts typically expect that the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script returns the new image URL, when an image is saved. Since the images are saved in the Moodle data dir, a new server-side script was required which is able to serve the desired image. This script is &#039;&#039;&#039;imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Advantages:&#039;&#039;&#039; the current file storage does not require a rewrite of any database structure. Textarea content always points to URL on the Moodle server, no data URLs are used. Image saving and loading is quick, and the image files are cached by the browser - the user experience is very good.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Disadvantages:&#039;&#039;&#039; there&#039;s a concern related to security. Who edits what? Who views what? Currently only course images are edited in-place, otherwise all images are considered &amp;quot;new&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the use of hashes for the image file names is for security purposes. Nobody can overwrite any of the existing images, since their file name is a unique hash of the content. Additionally, nobody can really guess the address of an image of another user - unless, obviously, you are given the address (and the hash) to it. Thus you are also given the right to view the image.&lt;br /&gt;
&lt;br /&gt;
Another important concern is that the Moodle data directory ends-up having far too many image files which need to be deleted, because they are unused. The matter of tracking which image is used/unused is not trivial. We are currently trying to determine the best approach to solving these issues. Any ideas are welcome.&lt;br /&gt;
&lt;br /&gt;
Then there&#039;s the problem of backing-up and restoring courses...&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Personally I prefer that PaintWeb uses files to save the images, since it&#039;s faster and cleaner. User interaction is also much better.&lt;br /&gt;
&lt;br /&gt;
I would like Moodle developers to check the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script and provide their feedback and suggestions for improvements.&lt;br /&gt;
&lt;br /&gt;
Further integration work can be done for Moodleforms and I could also create a script with some API to allow developers to include the paint tool stand-alone in any page they want. This depends on what Martin Langhoff, my mentor, decides.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 2.0 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 2.0 (CVS HEAD), the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl20-paintweb mdl20-paintweb] branch over at [http://repo.or.cz repo.or.cz].&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl20-paintweb mdl20-paintweb] branch starts from the Moodle 2.0 CVS HEAD branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/editor_tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce/lib.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$options[&#039;maxfiles&#039;]&#039;&#039;&#039; is not 0. Additionally, developers can disable PaintWeb by setting &#039;&#039;&#039;$options[&#039;plugin/paintweb&#039;]&#039;&#039;&#039; to false.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have the same scripts, as for the Moodle 1.9 integration. See the details about the [[Development:Paint_tool_integration#Localization_2|Moodle 1.9 localization integration]].&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented using the [[Development:Using_the_File_API|new File API]]. The idea is that textareas have draft file areas which holds files attached to them. The &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave20.php&#039;&#039;&#039; script saves the image in the draft file area of the textarea where the user edits the article. The client-side PaintWeb scripts determine the context ID and the draft item ID associated to the textarea. When the image save action is invoked, the script receives them, and uses them to save the image. The URL of the draft file is generated by the Moodle File API, and returned to the client-side code, which updates the image URL.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
I am very happy to see the numerous improvements made for Moodle 2, especially the new File API. Now PaintWeb saves images properly inside Moodle. These new files are backed-up, restored, cached and nicely usable in general.&lt;br /&gt;
&lt;br /&gt;
A further integration point could be Moodleforms, but I am not sure. Heard of plans for rewrites.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60892</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60892"/>
		<updated>2009-08-04T20:11:16Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to the latest forum post of Martin: Storing image &amp;quot;attachements&amp;quot; with text fields&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/CONTRIB-1456]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=129634 Storing image &amp;quot;attachements&amp;quot; with text fields] (posted by my mentor in the [http://moodle.org/mod/forum/view.php?id=55 General developer forums]).&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60885</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60885"/>
		<updated>2009-08-04T12:21:52Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to the latest blog post: PaintWeb integration progress&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/CONTRIB-1456]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;August 4, 2009:&#039;&#039;&#039; Blog post [http://www.robodesign.ro/mihai/blog/paintweb-integration-progress PaintWeb integration progress].&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60884</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60884"/>
		<updated>2009-08-04T11:37:46Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* File storage */ included further thoughts on the issues of using file storage&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;image&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;br /&gt;
&lt;br /&gt;
= Image load/save in PaintWeb =&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Data_URI_scheme data URI scheme] allows Web developers to include raw binary content inside HTML, CSS and JavaScript documents. This scheme holds the binary data using base64 encoding which makes it ideal most of the time for small binary files. PaintWeb builds use image data URLs inside CSS to avoid loading tens of separate PNG icons. Almost anywhere you can provide an URL, say inside an &amp;lt;img src&amp;gt; tag, you can use a data URL instead. &lt;br /&gt;
&lt;br /&gt;
Loading an image inside PaintWeb is a matter of only having a reference to a DOM image element in the page. The browser can immediately render the image element inside the Canvas, such that PaintWeb can edit the pixels. It&#039;s only simple code like &#039;&#039;&#039;canvas2dcontext.drawImage(imageElement, x, y)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Saving an image from PaintWeb is similarly easy: &#039;&#039;&#039;canvasElement.toDataURL()&#039;&#039;&#039;. This tells the browser to return the image in PNG format, base64-encoded. The value can be POSTed via a simple HTML form or via an XMLHttpRequest. Note: this value is NOT a file! This is a typical JavaScript string, and the server-side scripts recognize it like any other string. It is up to the server-side script to base64-decode the value and save it as a file. From PHP doing this is trivial:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
file_put_contents(&#039;image.png&#039;, base64_decode($base64_value));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Images from different servers than those of the page running the scripts can be rendered inside Canvas, but when they are rendered, they mark the Canvas element as &amp;quot;dirty&amp;quot; due to security concerns. Once this happens, browsers no longer allow methods like &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039; - or any other method which provides access to read the pixels.&lt;br /&gt;
&lt;br /&gt;
Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) consider as &amp;quot;external resource&amp;quot; any image element which uses a data URL as a value of the src attribute. This pretty much means that images with data URLs cannot be directly edited and saved by PaintWeb, unless workarounds are used for these browsers. The work around consists of taking the image data URL, POSTing it using an XMLHttpRequest to a server-side script which saves the image file as a binary (base64-decoded), and returns the URL pointing to the file on the server. Only after that PaintWeb can use the image element. Luckily Firefox 3.5 (Gecko 1.9.1) fixes this issue.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 1.9 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 1.9, the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] and [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branches over at [http://repo.or.cz repo.or.cz]. The mdl19-tinymce3 branch builds upon the [http://moodle.org/mod/forum/discuss.php?d=107550 TinyMCE 3 patches] published by Martin Langhoff in october 2008. I took his work and updated it to the latest Moodle 1.9 stable branch, updated TinyMCE 3 to the latest version and made some additional fixes needed for PaintWeb. The commit change logs provide detailed information on what I did.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] branch starts from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce.js.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$CFG-&amp;gt;tinymcePaintWeb&#039;&#039;&#039; is set to true.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have three scripts in &#039;&#039;&#039;lib/paintweb/ext/moodle&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_moodlelang.php&#039;&#039;&#039; generates the Moodle language files (PHP) from PaintWeb language files (JSON). This updates &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039; - depending on the JSON language files included in the PaintWeb packages.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_paintweblang.php&#039;&#039;&#039; generates the PaintWeb language files (JSON) from Moodle language files (PHP). This can be used when a translator updates some &#039;&#039;&#039;paintweb.php&#039;&#039;&#039; language file to regenerate the PaintWeb JSON file.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lang.json.php&#039;&#039;&#039; is used by PaintWeb inside Moodle when it loads. This PHP script is similar to that of TinyMCE. It outputs a JSON language file, dynamically generated using the Moodle API, with the configured language, from the Moodle PHP language files.&lt;br /&gt;
&lt;br /&gt;
All in all, the localization integration seems fine for me. I am only bothered that each time lang.json.php loads, it generates the JSON dynamically, which uses server-side resources for something quite static (language files seldom change). It does have HTTP caching headers and that certainly helps.&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb hides the textarea icons added by Moodle (those two icons below the textarea), when PaintWeb is shown, and it implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented in two ways:&lt;br /&gt;
&lt;br /&gt;
* images are saved using [http://en.wikipedia.org/wiki/Data_URI_scheme data URLs]. This means that instead of using files on the server, the whole image is saved inside the HTML generated by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* images are saved using files inside the Moodle data directory, without using any data URLs (only transiently). &lt;br /&gt;
&lt;br /&gt;
To change between the two file save methods, you only need to edit &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039; (search for &#039;&#039;&#039;moodleSaveMethod&#039;&#039;&#039;). Each save method has its own advantages and disadvantages presented below.&lt;br /&gt;
&lt;br /&gt;
=== Data URLs ===&lt;br /&gt;
&lt;br /&gt;
Saving the images using data URLs has the important advantage of being very easy to implement: just install the PaintWeb plugin inside TinyMCE. This requires no additional file security measures, storage, etc.&lt;br /&gt;
&lt;br /&gt;
The disadvantages are:&lt;br /&gt;
&lt;br /&gt;
* Data URLs do not work in IE 6 / 7 and thus require ugly work-arounds.&lt;br /&gt;
&lt;br /&gt;
* Loading PaintWeb to edit an image with a data URL always requires that the image data URL is sent to the server, saved on disk temporarily, and served back as a binary. As explained above, this is required only for Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) due to security constrains. The script used for saving the image on disk is &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039;. The file saved inside the Moodle data dir. The script which serves the images from the Moodle data dir is &#039;&#039;&#039;lib/paintweb/ext/moodle/imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Vanilla TinyMCE 3 builds mangle/corrupt data URLs, so they need to be patched. The patch is trivial and we will most likely get it into official builds really soon.&lt;br /&gt;
&lt;br /&gt;
* Users with images disabled still load the data URLs.&lt;br /&gt;
&lt;br /&gt;
* Page size increases from a few KB to almost MB or several megabytes. The small image I have in my TinyMCE demo uses 800kb for the data URL. I imagine usage scenarios from kids who have digital cameras which save much bigger images (like over 1280x1024), and they want to edit these images in Moodle.&lt;br /&gt;
&lt;br /&gt;
* Images do not cache at all, affecting the perceived performance of Moodle, and it especially affects users of slow connections (OLPC XO wireless is typically slow).&lt;br /&gt;
&lt;br /&gt;
* I presume images with data URLs use more memory.&lt;br /&gt;
&lt;br /&gt;
* Moodle server-side scripts and the database structure does not allow textarea content to hold so much raw data. The default image included in my TinyMCE does not fit in a typical Moodle textarea (only about quarter of it). For proper support of images with data URLs Moodle needs to be patched to allow much bigger textarea content (at least 5-10 MB).&lt;br /&gt;
&lt;br /&gt;
* Images with data URLs require about 37% more storage (due to the use of base64 encoding).&lt;br /&gt;
&lt;br /&gt;
* TinyMCE does some amount of raw HTML processing (with regex at times) which is slowed down quite much when images with data URLs are used. On my Athlon XP 1800+ I usually get the &amp;quot;a script is running slow, do you want to stop script execution&amp;quot; message from Firefox. Similarly, I think server-side HTML filters in Moodle are slowed down when image data URLs are used.&lt;br /&gt;
&lt;br /&gt;
=== File storage ===&lt;br /&gt;
&lt;br /&gt;
When PaintWeb is configured to save images using the Moodle file storage, any save operation consists of retrieving the image from the browser, in the form of a data URL: &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039;. The value is POSTed using an XMLHttpRequest to the server-side script &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039; which saves the image inside the Moodle data dir configured by the value of &#039;&#039;&#039;$CFG-&amp;gt;paintwebImagesFolder&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the image being edited by the user comes from a course then the image file is directly updated and no new file is created. If the security checks fail, then a new image is created.&lt;br /&gt;
&lt;br /&gt;
When new images are created their file names represent the unique sha1 of their content.&lt;br /&gt;
&lt;br /&gt;
The client-side scripts typically expect that the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script returns the new image URL, when an image is saved. Since the images are saved in the Moodle data dir, a new server-side script was required which is able to serve the desired image. This script is &#039;&#039;&#039;imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Advantages:&#039;&#039;&#039; the current file storage does not require a rewrite of any database structure. Textarea content always points to URL on the Moodle server, no data URLs are used. Image saving and loading is quick, and the image files are cached by the browser - the user experience is very good.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Disadvantages:&#039;&#039;&#039; there&#039;s a concern related to security. Who edits what? Who views what? Currently only course images are edited in-place, otherwise all images are considered &amp;quot;new&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the use of hashes for the image file names is for security purposes. Nobody can overwrite any of the existing images, since their file name is a unique hash of the content. Additionally, nobody can really guess the address of an image of another user - unless, obviously, you are given the address (and the hash) to it. Thus you are also given the right to view the image.&lt;br /&gt;
&lt;br /&gt;
Another important concern is that the Moodle data directory ends-up having far too many image files which need to be deleted, because they are unused. The matter of tracking which image is used/unused is not trivial. We are currently trying to determine the best approach to solving these issues. Any ideas are welcome.&lt;br /&gt;
&lt;br /&gt;
Then there&#039;s the problem of backing-up and restoring courses...&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Personally I prefer that PaintWeb uses files to save the images, since it&#039;s faster and cleaner. User interaction is also much better.&lt;br /&gt;
&lt;br /&gt;
I would like Moodle developers to check the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script and provide their feedback and suggestions for improvements.&lt;br /&gt;
&lt;br /&gt;
Further integration work can be done for Moodleforms and I could also create a script with some API to allow developers to include the paint tool stand-alone in any page they want. This depends on what Martin Langhoff, my mentor, decides.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60830</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60830"/>
		<updated>2009-08-02T08:53:41Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: updated the illustrative example for moodleforms integration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;image&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;br /&gt;
&lt;br /&gt;
= Image load/save in PaintWeb =&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Data_URI_scheme data URI scheme] allows Web developers to include raw binary content inside HTML, CSS and JavaScript documents. This scheme holds the binary data using base64 encoding which makes it ideal most of the time for small binary files. PaintWeb builds use image data URLs inside CSS to avoid loading tens of separate PNG icons. Almost anywhere you can provide an URL, say inside an &amp;lt;img src&amp;gt; tag, you can use a data URL instead. &lt;br /&gt;
&lt;br /&gt;
Loading an image inside PaintWeb is a matter of only having a reference to a DOM image element in the page. The browser can immediately render the image element inside the Canvas, such that PaintWeb can edit the pixels. It&#039;s only simple code like &#039;&#039;&#039;canvas2dcontext.drawImage(imageElement, x, y)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Saving an image from PaintWeb is similarly easy: &#039;&#039;&#039;canvasElement.toDataURL()&#039;&#039;&#039;. This tells the browser to return the image in PNG format, base64-encoded. The value can be POSTed via a simple HTML form or via an XMLHttpRequest. Note: this value is NOT a file! This is a typical JavaScript string, and the server-side scripts recognize it like any other string. It is up to the server-side script to base64-decode the value and save it as a file. From PHP doing this is trivial:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
file_put_contents(&#039;image.png&#039;, base64_decode($base64_value));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Images from different servers than those of the page running the scripts can be rendered inside Canvas, but when they are rendered, they mark the Canvas element as &amp;quot;dirty&amp;quot; due to security concerns. Once this happens, browsers no longer allow methods like &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039; - or any other method which provides access to read the pixels.&lt;br /&gt;
&lt;br /&gt;
Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) consider as &amp;quot;external resource&amp;quot; any image element which uses a data URL as a value of the src attribute. This pretty much means that images with data URLs cannot be directly edited and saved by PaintWeb, unless workarounds are used for these browsers. The work around consists of taking the image data URL, POSTing it using an XMLHttpRequest to a server-side script which saves the image file as a binary (base64-decoded), and returns the URL pointing to the file on the server. Only after that PaintWeb can use the image element. Luckily Firefox 3.5 (Gecko 1.9.1) fixes this issue.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 1.9 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 1.9, the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] and [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branches over at [http://repo.or.cz repo.or.cz]. The mdl19-tinymce3 branch builds upon the [http://moodle.org/mod/forum/discuss.php?d=107550 TinyMCE 3 patches] published by Martin Langhoff in october 2008. I took his work and updated it to the latest Moodle 1.9 stable branch, updated TinyMCE 3 to the latest version and made some additional fixes needed for PaintWeb. The commit change logs provide detailed information on what I did.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] branch starts from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce.js.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$CFG-&amp;gt;tinymcePaintWeb&#039;&#039;&#039; is set to true.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have three scripts in &#039;&#039;&#039;lib/paintweb/ext/moodle&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_moodlelang.php&#039;&#039;&#039; generates the Moodle language files (PHP) from PaintWeb language files (JSON). This updates &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039; - depending on the JSON language files included in the PaintWeb packages.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_paintweblang.php&#039;&#039;&#039; generates the PaintWeb language files (JSON) from Moodle language files (PHP). This can be used when a translator updates some &#039;&#039;&#039;paintweb.php&#039;&#039;&#039; language file to regenerate the PaintWeb JSON file.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lang.json.php&#039;&#039;&#039; is used by PaintWeb inside Moodle when it loads. This PHP script is similar to that of TinyMCE. It outputs a JSON language file, dynamically generated using the Moodle API, with the configured language, from the Moodle PHP language files.&lt;br /&gt;
&lt;br /&gt;
All in all, the localization integration seems fine for me. I am only bothered that each time lang.json.php loads, it generates the JSON dynamically, which uses server-side resources for something quite static (language files seldom change). It does have HTTP caching headers and that certainly helps.&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb hides the textarea icons added by Moodle (those two icons below the textarea), when PaintWeb is shown, and it implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented in two ways:&lt;br /&gt;
&lt;br /&gt;
* images are saved using [http://en.wikipedia.org/wiki/Data_URI_scheme data URLs]. This means that instead of using files on the server, the whole image is saved inside the HTML generated by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* images are saved using files inside the Moodle data directory, without using any data URLs (only transiently). &lt;br /&gt;
&lt;br /&gt;
To change between the two file save methods, you only need to edit &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039; (search for &#039;&#039;&#039;moodleSaveMethod&#039;&#039;&#039;). Each save method has its own advantages and disadvantages presented below.&lt;br /&gt;
&lt;br /&gt;
=== Data URLs ===&lt;br /&gt;
&lt;br /&gt;
Saving the images using data URLs has the important advantage of being very easy to implement: just install the PaintWeb plugin inside TinyMCE. This requires no additional file security measures, storage, etc.&lt;br /&gt;
&lt;br /&gt;
The disadvantages are:&lt;br /&gt;
&lt;br /&gt;
* Data URLs do not work in IE 6 / 7 and thus require ugly work-arounds.&lt;br /&gt;
&lt;br /&gt;
* Loading PaintWeb to edit an image with a data URL always requires that the image data URL is sent to the server, saved on disk temporarily, and served back as a binary. As explained above, this is required only for Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) due to security constrains. The script used for saving the image on disk is &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039;. The file saved inside the Moodle data dir. The script which serves the images from the Moodle data dir is &#039;&#039;&#039;lib/paintweb/ext/moodle/imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Vanilla TinyMCE 3 builds mangle/corrupt data URLs, so they need to be patched. The patch is trivial and we will most likely get it into official builds really soon.&lt;br /&gt;
&lt;br /&gt;
* Users with images disabled still load the data URLs.&lt;br /&gt;
&lt;br /&gt;
* Page size increases from a few KB to almost MB or several megabytes. The small image I have in my TinyMCE demo uses 800kb for the data URL. I imagine usage scenarios from kids who have digital cameras which save much bigger images (like over 1280x1024), and they want to edit these images in Moodle.&lt;br /&gt;
&lt;br /&gt;
* Images do not cache at all, affecting the perceived performance of Moodle, and it especially affects users of slow connections (OLPC XO wireless is typically slow).&lt;br /&gt;
&lt;br /&gt;
* I presume images with data URLs use more memory.&lt;br /&gt;
&lt;br /&gt;
* Moodle server-side scripts and the database structure does not allow textarea content to hold so much raw data. The default image included in my TinyMCE does not fit in a typical Moodle textarea (only about quarter of it). For proper support of images with data URLs Moodle needs to be patched to allow much bigger textarea content (at least 5-10 MB).&lt;br /&gt;
&lt;br /&gt;
* Images with data URLs require about 37% more storage (due to the use of base64 encoding).&lt;br /&gt;
&lt;br /&gt;
* TinyMCE does some amount of raw HTML processing (with regex at times) which is slowed down quite much when images with data URLs are used. On my Athlon XP 1800+ I usually get the &amp;quot;a script is running slow, do you want to stop script execution&amp;quot; message from Firefox. Similarly, I think server-side HTML filters in Moodle are slowed down when image data URLs are used.&lt;br /&gt;
&lt;br /&gt;
=== File storage ===&lt;br /&gt;
&lt;br /&gt;
When PaintWeb is configured to save images using the Moodle file storage, any save operation consists of retrieving the image from the browser, in the form of a data URL: &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039;. The value is POSTed using an XMLHttpRequest to the server-side script &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039; which saves the image inside the Moodle data dir configured by the value of &#039;&#039;&#039;$CFG-&amp;gt;paintwebImagesFolder&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the image being edited by the user comes from a course then the image file is directly updated and no new file is created. If the security checks fail, then a new image is created.&lt;br /&gt;
&lt;br /&gt;
When new images are created their file names represent the unique sha1 of their content.&lt;br /&gt;
&lt;br /&gt;
The client-side scripts typically expect that the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script returns the new image URL, when an image is saved. Since the images are saved in the Moodle data dir, a new server-side script was required which is able to serve the desired image. This script is &#039;&#039;&#039;imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Advantages: the current file storage does not require a rewrite of any database structure. Textarea content always points to URL on the Moodle server, no data URLs are used. Image saving and loading is quick, and the image files are cached by the browser.&lt;br /&gt;
&lt;br /&gt;
Disadvantages: there&#039;s a concern related to security. Who edits what? Who views what? Currently only course images are edited in-place, otherwise all images are considered &amp;quot;new&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Personally I prefer that PaintWeb uses files to save the images, since it&#039;s faster and cleaner. User interaction is also much better.&lt;br /&gt;
&lt;br /&gt;
I would like Moodle developers to check the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script and provide their feedback and suggestions for improvements.&lt;br /&gt;
&lt;br /&gt;
Further integration work can be done for Moodleforms and I could also create a script with some API to allow developers to include the paint tool stand-alone in any page they want. This depends on what Martin Langhoff, my mentor, decides.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Broken/Paint_tool_integration&amp;diff=60829</id>
		<title>Broken/Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Broken/Paint_tool_integration&amp;diff=60829"/>
		<updated>2009-08-02T08:52:21Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: reply to tim hunt about moodleforms integration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Re: &#039;&#039;An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;paintweb&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Just a little point about API. I think that &#039;paintweb&#039; is an implementation detail. It would be better to call the element something like &#039;sketch&#039;. Also, the details of the API should try not to assume that the drawing app used is paintweb. Presumbaly, from a programmer&#039;s point of view, it should be just like a file upload control where the use can choose a single image file to upload (although the UI will be very different.--[[User:Tim Hunt|Tim Hunt]] 02:23, 2 August 2009 (UTC)&lt;br /&gt;
: Thanks for your comment! Agreed, it&#039;s something only for illustrative purposes. However, in Moodle 1.9, there&#039;s not very much point in being too &amp;quot;generalistic&amp;quot;, since it&#039;s going to be a contrib patch for Moodle 1.9 which adds only PaintWeb, and there won&#039;t be any official release based on it, with the possibility of addition of multiple image editors (or not that I foresee any, hehe). Nonetheless, what I had in mind was something like &#039;&#039;&#039;$mform-addElement(&#039;image&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;. I should also aim to make the API for using PaintWeb as similar as possible between Moodle 1.9 and 2.0. Still, I presume there will be important differences: at least the new file API and the new editors embedding API have an important influence on the way PaintWeb is going to be integrated. [[User:Mihai Sucan|Mihai Sucan]] 08:52, 2 August 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60806</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60806"/>
		<updated>2009-07-31T16:23:10Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: further details on Moodle 1.9 integration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;paintweb&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;br /&gt;
&lt;br /&gt;
= Image load/save in PaintWeb =&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Data_URI_scheme data URI scheme] allows Web developers to include raw binary content inside HTML, CSS and JavaScript documents. This scheme holds the binary data using base64 encoding which makes it ideal most of the time for small binary files. PaintWeb builds use image data URLs inside CSS to avoid loading tens of separate PNG icons. Almost anywhere you can provide an URL, say inside an &amp;lt;img src&amp;gt; tag, you can use a data URL instead. &lt;br /&gt;
&lt;br /&gt;
Loading an image inside PaintWeb is a matter of only having a reference to a DOM image element in the page. The browser can immediately render the image element inside the Canvas, such that PaintWeb can edit the pixels. It&#039;s only simple code like &#039;&#039;&#039;canvas2dcontext.drawImage(imageElement, x, y)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Saving an image from PaintWeb is similarly easy: &#039;&#039;&#039;canvasElement.toDataURL()&#039;&#039;&#039;. This tells the browser to return the image in PNG format, base64-encoded. The value can be POSTed via a simple HTML form or via an XMLHttpRequest. Note: this value is NOT a file! This is a typical JavaScript string, and the server-side scripts recognize it like any other string. It is up to the server-side script to base64-decode the value and save it as a file. From PHP doing this is trivial:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
file_put_contents(&#039;image.png&#039;, base64_decode($base64_value));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Images from different servers than those of the page running the scripts can be rendered inside Canvas, but when they are rendered, they mark the Canvas element as &amp;quot;dirty&amp;quot; due to security concerns. Once this happens, browsers no longer allow methods like &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039; - or any other method which provides access to read the pixels.&lt;br /&gt;
&lt;br /&gt;
Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) consider as &amp;quot;external resource&amp;quot; any image element which uses a data URL as a value of the src attribute. This pretty much means that images with data URLs cannot be directly edited and saved by PaintWeb, unless workarounds are used for these browsers. The work around consists of taking the image data URL, POSTing it using an XMLHttpRequest to a server-side script which saves the image file as a binary (base64-decoded), and returns the URL pointing to the file on the server. Only after that PaintWeb can use the image element. Luckily Firefox 3.5 (Gecko 1.9.1) fixes this issue.&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 1.9 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 1.9, the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] and [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branches over at [http://repo.or.cz repo.or.cz]. The mdl19-tinymce3 branch builds upon the [http://moodle.org/mod/forum/discuss.php?d=107550 TinyMCE 3 patches] published by Martin Langhoff in october 2008. I took his work and updated it to the latest Moodle 1.9 stable branch, updated TinyMCE 3 to the latest version and made some additional fixes needed for PaintWeb. The commit change logs provide detailed information on what I did.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] branch starts from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce.js.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$CFG-&amp;gt;tinymcePaintWeb&#039;&#039;&#039; is set to true.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have three scripts in &#039;&#039;&#039;lib/paintweb/ext/moodle&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_moodlelang.php&#039;&#039;&#039; generates the Moodle language files (PHP) from PaintWeb language files (JSON). This updates &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039; - depending on the JSON language files included in the PaintWeb packages.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_paintweblang.php&#039;&#039;&#039; generates the PaintWeb language files (JSON) from Moodle language files (PHP). This can be used when a translator updates some &#039;&#039;&#039;paintweb.php&#039;&#039;&#039; language file to regenerate the PaintWeb JSON file.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lang.json.php&#039;&#039;&#039; is used by PaintWeb inside Moodle when it loads. This PHP script is similar to that of TinyMCE. It outputs a JSON language file, dynamically generated using the Moodle API, with the configured language, from the Moodle PHP language files.&lt;br /&gt;
&lt;br /&gt;
All in all, the localization integration seems fine for me. I am only bothered that each time lang.json.php loads, it generates the JSON dynamically, which uses server-side resources for something quite static (language files seldom change). It does have HTTP caching headers and that certainly helps.&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb hides the textarea icons added by Moodle (those two icons below the textarea), when PaintWeb is shown, and it implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image load and save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented in two ways:&lt;br /&gt;
&lt;br /&gt;
* images are saved using [http://en.wikipedia.org/wiki/Data_URI_scheme data URLs]. This means that instead of using files on the server, the whole image is saved inside the HTML generated by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* images are saved using files inside the Moodle data directory, without using any data URLs (only transiently). &lt;br /&gt;
&lt;br /&gt;
To change between the two file save methods, you only need to edit &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039; (search for &#039;&#039;&#039;moodleSaveMethod&#039;&#039;&#039;). Each save method has its own advantages and disadvantages presented below.&lt;br /&gt;
&lt;br /&gt;
=== Data URLs ===&lt;br /&gt;
&lt;br /&gt;
Saving the images using data URLs has the important advantage of being very easy to implement: just install the PaintWeb plugin inside TinyMCE. This requires no additional file security measures, storage, etc.&lt;br /&gt;
&lt;br /&gt;
The disadvantages are:&lt;br /&gt;
&lt;br /&gt;
* Data URLs do not work in IE 6 / 7 and thus require ugly work-arounds.&lt;br /&gt;
&lt;br /&gt;
* Loading PaintWeb to edit an image with a data URL always requires that the image data URL is sent to the server, saved on disk temporarily, and served back as a binary. As explained above, this is required only for Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit) due to security constrains. The script used for saving the image on disk is &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039;. The file saved inside the Moodle data dir. The script which serves the images from the Moodle data dir is &#039;&#039;&#039;lib/paintweb/ext/moodle/imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Vanilla TinyMCE 3 builds mangle/corrupt data URLs, so they need to be patched. The patch is trivial and we will most likely get it into official builds really soon.&lt;br /&gt;
&lt;br /&gt;
* Users with images disabled still load the data URLs.&lt;br /&gt;
&lt;br /&gt;
* Page size increases from a few KB to almost MB or several megabytes. The small image I have in my TinyMCE demo uses 800kb for the data URL. I imagine usage scenarios from kids who have digital cameras which save much bigger images (like over 1280x1024), and they want to edit these images in Moodle.&lt;br /&gt;
&lt;br /&gt;
* Images do not cache at all, affecting the perceived performance of Moodle, and it especially affects users of slow connections (OLPC XO wireless is typically slow).&lt;br /&gt;
&lt;br /&gt;
* I presume images with data URLs use more memory.&lt;br /&gt;
&lt;br /&gt;
* Moodle server-side scripts and the database structure does not allow textarea content to hold so much raw data. The default image included in my TinyMCE does not fit in a typical Moodle textarea (only about quarter of it). For proper support of images with data URLs Moodle needs to be patched to allow much bigger textarea content (at least 5-10 MB).&lt;br /&gt;
&lt;br /&gt;
* Images with data URLs require about 37% more storage (due to the use of base64 encoding).&lt;br /&gt;
&lt;br /&gt;
* TinyMCE does some amount of raw HTML processing (with regex at times) which is slowed down quite much when images with data URLs are used. On my Athlon XP 1800+ I usually get the &amp;quot;a script is running slow, do you want to stop script execution&amp;quot; message from Firefox. Similarly, I think server-side HTML filters in Moodle are slowed down when image data URLs are used.&lt;br /&gt;
&lt;br /&gt;
=== File storage ===&lt;br /&gt;
&lt;br /&gt;
When PaintWeb is configured to save images using the Moodle file storage, any save operation consists of retrieving the image from the browser, in the form of a data URL: &#039;&#039;&#039;canvas.toDataURL()&#039;&#039;&#039;. The value is POSTed using an XMLHttpRequest to the server-side script &#039;&#039;&#039;lib/paintweb/ext/moodle/imagesave.php&#039;&#039;&#039; which saves the image inside the Moodle data dir configured by the value of &#039;&#039;&#039;$CFG-&amp;gt;paintwebImagesFolder&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If the image being edited by the user comes from a course then the image file is directly updated and no new file is created. If the security checks fail, then a new image is created.&lt;br /&gt;
&lt;br /&gt;
When new images are created their file names represent the unique sha1 of their content.&lt;br /&gt;
&lt;br /&gt;
The client-side scripts typically expect that the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script returns the new image URL, when an image is saved. Since the images are saved in the Moodle data dir, a new server-side script was required which is able to serve the desired image. This script is &#039;&#039;&#039;imageview.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Advantages: the current file storage does not require a rewrite of any database structure. Textarea content always points to URL on the Moodle server, no data URLs are used. Image saving and loading is quick, and the image files are cached by the browser.&lt;br /&gt;
&lt;br /&gt;
Disadvantages: there&#039;s a concern related to security. Who edits what? Who views what? Currently only course images are edited in-place, otherwise all images are considered &amp;quot;new&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
Personally I prefer that PaintWeb uses files to save the images, since it&#039;s faster and cleaner. User interaction is also much better.&lt;br /&gt;
&lt;br /&gt;
I would like Moodle developers to check the &#039;&#039;&#039;imagesave.php&#039;&#039;&#039; script and provide their feedback and suggestions for improvements.&lt;br /&gt;
&lt;br /&gt;
Further integration work can be done for Moodleforms and I could also create a script with some API to allow developers to include the paint tool stand-alone in any page they want. This depends on what Martin Langhoff, my mentor, decides.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60804</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=60804"/>
		<updated>2009-07-31T12:54:13Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: detailing my work on Moodle 1.9 integration (to be continued)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An additional vector of PaintWeb integration is Moodleforms, something like &#039;&#039;&#039;$mform-&amp;gt;addElement(&#039;paintweb&#039;, &#039;targetInputElement&#039;, options)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle 2.0 file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;br /&gt;
&lt;br /&gt;
= Results: Moodle 1.9 integration =&lt;br /&gt;
&lt;br /&gt;
I have published a Git repository which holds my work with Moodle 1.9, the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] and [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branches over at [http://repo.or.cz repo.or.cz]. The mdl19-tinymce3 branch builds upon the [http://moodle.org/mod/forum/discuss.php?d=107550 TinyMCE 3 patches] published by Martin Langhoff in october 2008. I took his work and updated it to the latest Moodle 1.9 stable branch, updated TinyMCE 3 to the latest version and made some additional fixes needed for PaintWeb. The commit change logs provide detailed information on what I did.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb integration code from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-paintweb mdl19-paintweb] branch starts from the [http://repo.or.cz/w/moodle/mihaisucan.git?a=shortlog;h=refs/heads/mdl19-tinymce3 mdl19-tinymce3] branch.&lt;br /&gt;
&lt;br /&gt;
What I did:&lt;br /&gt;
&lt;br /&gt;
* included all the PaintWeb code base inside &#039;&#039;&#039;lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* added a new &#039;&#039;&#039;lang/en_utf8/paintweb.php&#039;&#039;&#039; file which holds all the PaintWeb language strings, in Moodle format (PHP).&lt;br /&gt;
&lt;br /&gt;
* added my TinyMCE plugin at &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* updated the &#039;&#039;&#039;lang/en_utf8/tinymce.php&#039;&#039;&#039; file to include the new language strings from my plugin for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;lib/editor/tinymce.js.php&#039;&#039;&#039; file. This file initializes TinyMCE in all pages. My patch adds my PaintWeb plugin for TinyMCE to the list of loaded plugins. PaintWeb is only loaded when &#039;&#039;&#039;$CFG-&amp;gt;tinymcePaintWeb&#039;&#039;&#039; is set to true.&lt;br /&gt;
&lt;br /&gt;
* patched the &#039;&#039;&#039;theme/standard/styles_layout.css&#039;&#039;&#039; file to not affect the rendering of the PaintWeb user interface (minor fix).&lt;br /&gt;
&lt;br /&gt;
More details below.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
For localization integration I have three scripts in &#039;&#039;&#039;lib/paintweb/ext/moodle&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_moodlelang.php&#039;&#039;&#039; generates the Moodle language files (PHP) from PaintWeb language files (JSON). This updates &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039; - depending on the JSON language files included in the PaintWeb packages.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gen_paintweblang.php&#039;&#039;&#039; generates the PaintWeb language files (JSON) from Moodle language files (PHP). This can be used when a translator updates some &#039;&#039;&#039;paintweb.php&#039;&#039;&#039; language file to regenerate the PaintWeb JSON file.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lang.json.php&#039;&#039;&#039; is used by PaintWeb inside Moodle when it loads. This PHP script is similar to that of TinyMCE. It outputs a JSON language file, dynamically generated using the Moodle API, with the configured language, from the Moodle PHP language files.&lt;br /&gt;
&lt;br /&gt;
All in all, the localization integration seems fine for me. I am only bothered that each time lang.json.php loads, it generates the JSON dynamically, which uses server-side resources for something quite static (language files seldom change). It does have HTTP caching headers and that certainly helps.&lt;br /&gt;
&lt;br /&gt;
== PaintWeb inside Moodle ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb in Moodle uses its own configuration file: &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039;. This tells the paint tool to load a Moodle extension script I wrote. The [http://code.google.com/p/paintweb/source/browse/trunk/src/extensions/moodle.js Moodle extension] for PaintWeb hides the textarea icons added by Moodle (those two icons below the textarea), when PaintWeb is shown, and it implements the image saving operation.&lt;br /&gt;
&lt;br /&gt;
== Image save ==&lt;br /&gt;
&lt;br /&gt;
The image save operation is implemented in two ways:&lt;br /&gt;
&lt;br /&gt;
* images are saved using [http://en.wikipedia.org/wiki/Data_URI_scheme data URLs]. This means that instead of using files on the server, the whole image is saved inside the HTML generated by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* images are saved using files inside the Moodle data directory, without using any data URLs (only transiently). &lt;br /&gt;
&lt;br /&gt;
To change between the two file save methods, you only need to edit &#039;&#039;&#039;lib/paintweb/ext/moodle/config.json&#039;&#039;&#039; (search for &#039;&#039;moodleSaveMethod&#039;&#039;). Each save method has its own advantages and disadvantages presented below.&lt;br /&gt;
&lt;br /&gt;
=== Data URLs ===&lt;br /&gt;
&lt;br /&gt;
Saving the images using data URLs has the important advantage of being very easy to implement: just install the PaintWeb plugin inside TinyMCE. This requires no additional file security measures, storage, etc.&lt;br /&gt;
&lt;br /&gt;
The disadvantages are:&lt;br /&gt;
&lt;br /&gt;
* data URLs do not work in IE 6 / 7 and thus require ugly work-arounds.&lt;br /&gt;
&lt;br /&gt;
* there are some technical difficulties with using them inside Firefox 3.0 (Gecko 1.9.0) and Safari/Chrome (Webkit). More specifically, once an image with a data URL is drawn inside a Canvas element, the Canvas element is marked as &amp;quot;dirty&amp;quot; (security violation). The image resource is wrongly considered an external resource. Once this happens, PaintWeb can no longer save the image changes. To work around this issue, now I have to first do a POST XMLHttpRequest to the Moodle server to save the image data URL, and receive back a temporary binary image file, one that I can render inside PaintWeb. This is an important waste of resources: send image, save, receive, then edit in PaintWeb.&lt;br /&gt;
&lt;br /&gt;
... to be continued&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60762</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60762"/>
		<updated>2009-07-30T17:40:26Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Summary */ tracker issue update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/CONTRIB-1456]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60509</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60509"/>
		<updated>2009-07-24T13:03:42Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to the latest blog post: PaintWeb and Moodle Git repository&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 24, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-and-moodle-git-repository PaintWeb and Moodle Git repository].&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Firebug&amp;diff=60167</id>
		<title>Firebug</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Firebug&amp;diff=60167"/>
		<updated>2009-07-18T19:46:59Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Is Firebug only for Firefox? */ mention devtools for Chrome, Opera and Safari&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== What is Firebug? ==&lt;br /&gt;
&lt;br /&gt;
Firebug is an add-on for the [[Firefox]] web browser. Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page...&lt;br /&gt;
&lt;br /&gt;
== Is Firebug only for Firefox? ==&lt;br /&gt;
&lt;br /&gt;
The add-on will only work in Firefox, but there is also a JavaScript based [http://getfirebug.com/lite.html Firebug Lite] version for use with Internet Explorer (IE), Opera, and Safari.&lt;br /&gt;
&lt;br /&gt;
Alternatives with similar functionality for other Web browsers:&lt;br /&gt;
* The [http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&amp;amp;displaylang=en Internet Explorer Developer Toolbar] for Microsoft IE.&lt;br /&gt;
* [http://www.opera.com/dragonfly/ Dragonfly] for Opera.&lt;br /&gt;
* The commonly named &amp;quot;JavaScript console&amp;quot; menu item in Google Chrome.&lt;br /&gt;
* The Web Inspector menu item in Safari.&lt;br /&gt;
&lt;br /&gt;
== Where can I get Firebug? ==&lt;br /&gt;
&lt;br /&gt;
* http://getfirebug.com&lt;br /&gt;
* https://addons.mozilla.org/en-US/firefox/addon/1843&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
* [http://www.webmonkey.com/tutorial/Build_Better_Pages_With_Firebug Build Better Pages With Firebug]&lt;br /&gt;
&lt;br /&gt;
* [http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i Firebug Tutorial - Logging, Profiling and CommandLine (Part 1)]&lt;br /&gt;
&lt;br /&gt;
* And for those of us who prefer viewing to reading, there&#039;s a bunch of tutorial videos on [http://www.youtube.com/watch?v=FsX6qwQqGgQ YouTube].&lt;br /&gt;
&lt;br /&gt;
== Further enhancements ==&lt;br /&gt;
There are some enhancements to make Firebug even more powerful.&lt;br /&gt;
* See the complete list of [https://addons.mozilla.org/en-US/firefox/search?q=firebug&amp;amp;cat=all Firebug related add-ons].&lt;br /&gt;
* [http://www.drweb.de/magazin/mehr-power-fur-firebug/ Mehr Power für Firebug] is an article written in German, but you can just follow the links to the Firefox add-on page. &lt;br /&gt;
&lt;br /&gt;
Here are some of those enhancements.&amp;lt;br /&amp;gt; &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Some of these enhancements are experimental. Caution should be used when installing experimental add-ons, as they have not been tested by an editor and may harm your computer configuration.&lt;br /&gt;
&lt;br /&gt;
=== FirePHP ===&lt;br /&gt;
[http://www.firephp.org/ FirePHP] enables you to log to your Firebug Console using a simple PHP method call. &amp;lt;br /&amp;gt;&lt;br /&gt;
There&#039;s a [http://moodle.org/mod/forum/discuss.php?d=119961 FirePHP plugin for Moodle] in the works.&lt;br /&gt;
&lt;br /&gt;
=== FireRainbow ===&lt;br /&gt;
[https://addons.mozilla.org/en-US/firefox/addon/9603 FireRainbow] (formerly &#039;&#039;Rainbow for Firebug&#039;&#039;) - Provides &#039;&#039;&#039;JavaScript syntax highlighting&#039;&#039;&#039; for Firebug 1.3.&lt;br /&gt;
&lt;br /&gt;
=== CodeBurner ===&lt;br /&gt;
[https://addons.mozilla.org/en-US/firefox/addon/10273 CodeBurner] - A Firefox add-on that integrates with Firebug, to extend it with reference material for CSS, HTML, and JavaScript from [http://reference.sitepoint.com SitePoint].&lt;br /&gt;
&lt;br /&gt;
=== YSlow ===&lt;br /&gt;
[https://addons.mozilla.org/en-US/firefox/addon/5369 YSlow] - YSlow analyzes web pages and tells you why they&#039;re slow based on Yahoo&#039;s rules for high performance web sites. &lt;br /&gt;
&lt;br /&gt;
=== Firefinder ===&lt;br /&gt;
[https://addons.mozilla.org/en-US/firefox/addon/11905 Firefinder] - Finds HTML elements matching chosen CSS selector(s) or XPath expression. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{CategoryDeveloper}}&lt;br /&gt;
[[Category:Developer tools|Firebug]]&lt;br /&gt;
[[Category:Firefox extensions|Firebug]]&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60105</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=60105"/>
		<updated>2009-07-17T11:56:17Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to the latest blog post: Updated TinyMCE 3 in Moodle 1.9&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 17, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/updated-tinymce-3-in-moodle-1-9 Updated TinyMCE 3 in Moodle 1.9].&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59821</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59821"/>
		<updated>2009-07-14T16:23:48Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Latest updates */ link to my forum post reply about the updated Moodle 1.9 + TinyMCE 3 patches&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 14, 2009:&#039;&#039;&#039; Forum post reply: [http://moodle.org/mod/forum/discuss.php?d=107550#p561247 Updated Moodle 1.9 + TinyMCE 3 patches].&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59675</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59675"/>
		<updated>2009-07-10T15:25:58Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: updates regarding localization and API changes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot;&lt;br /&gt;
id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id,&lt;br /&gt;
    &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
    &#039;itemid&#039;=&amp;gt; 0,&lt;br /&gt;
    &#039;filepath&#039;=&amp;gt; &#039;/&#039;,&lt;br /&gt;
    &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
    &#039;timecreated&#039; =&amp;gt; time(),&lt;br /&gt;
    &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, $config = array()) {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;,&lt;br /&gt;
      array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I have [http://code.google.com/p/paintweb/source/browse/trunk/ext/moodle two scripts] which convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;br /&gt;
&lt;br /&gt;
I presume that Moodle translators will want to work with the Moodle PHP language files. This means that they (or someone else) can update the PaintWeb JSON language files using the convertor script.&lt;br /&gt;
&lt;br /&gt;
Should PaintWeb load static JSON files or should it load a script which automatically generates the JSON using the strings stored in the &#039;&#039;&#039;moodle/lang/*/paintweb.php&#039;&#039;&#039; files?&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59516</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59516"/>
		<updated>2009-07-08T14:18:33Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to the latest blog post: PaintWeb documentation and TinyMCE plugin&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-documentation-and-tinymce-plugin PaintWeb documentation and TinyMCE plugin] and more.&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59510</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59510"/>
		<updated>2009-07-08T12:24:25Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to the &amp;quot;Paint tool integration&amp;quot; wiki page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 8, 2009:&#039;&#039;&#039; Wiki page: [https://docs.moodle.org/en/Development:Paint_tool_integration Paint tool integration planning].&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59509</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59509"/>
		<updated>2009-07-08T12:21:47Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: code correction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot; id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id, &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
         &#039;itemid&#039;=&amp;gt;0, &#039;filepath&#039;=&amp;gt;&#039;/&#039;, &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
         &#039;timecreated&#039; =&amp;gt; time(), &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, array $config = array()) {&lt;br /&gt;
  global $CFG, $PAGE;&lt;br /&gt;
&lt;br /&gt;
  // tell PaintWeb where it the codebase lives in&lt;br /&gt;
  $config[&#039;baseFolder&#039;] = $CFG-&amp;gt;wwwroot . &#039;/lib/paintweb/build/&#039;;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;, array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // The Moodle config file.&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  // Use the configuration provided by the Moodle&lt;br /&gt;
  // server-side script.&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I can write a script to convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59481</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59481"/>
		<updated>2009-07-07T20:35:25Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: more updates&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array());&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot; id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &#039;&#039;&amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;br /&gt;
&lt;br /&gt;
= The Moodle file manager =&lt;br /&gt;
&lt;br /&gt;
As explained above, the Moodle file manager should provide an API for registering file handlers, file processing tools, etc.&lt;br /&gt;
&lt;br /&gt;
In the file manager the user might want to edit HTML files with TinyMCE, edit images with PaintWeb, or select multiple files to apply some batch process - like image resize.&lt;br /&gt;
&lt;br /&gt;
It should be taken into consideration that some file operations can be performed on the server or client-side. Meaning, image resize can be performed server-side, but image editing needs to be performed client-side. When registering file handlers, one should be able to define the kind of operation: does the action need to load and invoke a client-side JavaScript method from a library? or is the action supposed to be performed by a server-side script from some Moodle library?&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb extension =&lt;br /&gt;
&lt;br /&gt;
The whole PaintWeb package should live in &#039;&#039;&#039;/lib/paintweb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In the overview I pointed out a PaintWeb extension needs to be developed to properly integrate into Moodle. Sample code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
pwlib.extensions.moodle = function (app) {&lt;br /&gt;
  this.extensionRegister = function () {&lt;br /&gt;
    // add an event listener for the imageSave event.&lt;br /&gt;
    app.events.add(&#039;imageSave&#039;, this.imageSave);&lt;br /&gt;
&lt;br /&gt;
    // add a hidden form in the document&lt;br /&gt;
    // used for submitting the image to the server&lt;br /&gt;
    // ...&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
  this.imageSave = function (ev) {&lt;br /&gt;
    ev.preventDefault();&lt;br /&gt;
&lt;br /&gt;
    // a hidden form we can submit to the server&lt;br /&gt;
    form.imageFile.value = ev.dataURI;&lt;br /&gt;
    form.submit();&lt;br /&gt;
  };&lt;br /&gt;
  // ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the user decides to save, the browser outputs the image data as a data URI, base64 encoded. We can submit this to the server.&lt;br /&gt;
&lt;br /&gt;
= The PaintWeb lib code =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;/lib/paintweb/ext/moodle/lib.php&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
On the server side, all the requests for file save need to be handled using the new File API:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// reference to the temporary imageFile uploaded by php&lt;br /&gt;
$imgfile = $_FILES[&#039;imageFile&#039;][&#039;tmp_name&#039;];&lt;br /&gt;
$filename = $_FILES[&#039;imageFile&#039;][&#039;name&#039;];&lt;br /&gt;
$fs = get_file_storage();&lt;br /&gt;
$file_record = array(&#039;contextid&#039; =&amp;gt; $context-&amp;gt;id, &#039;filearea&#039; =&amp;gt; $filearea,&lt;br /&gt;
         &#039;itemid&#039;=&amp;gt;0, &#039;filepath&#039;=&amp;gt;&#039;/&#039;, &#039;filename&#039; =&amp;gt; $filename,&lt;br /&gt;
         &#039;timecreated&#039; =&amp;gt; time(), &#039;timemodified&#039; =&amp;gt; time());&lt;br /&gt;
$fs-&amp;gt;create_file_from_pathname($file_record, $imgfile);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
&lt;br /&gt;
* What context should be used? A different context depending where PaintWeb is used? Or a single context for all the files saved by PaintWeb? If different contexts need to be used, how should we pass the context to PaintWeb? Maybe the script which integrates PaintWeb also needs to pass the context?&lt;br /&gt;
&lt;br /&gt;
* How about the file area? Same question as above.&lt;br /&gt;
&lt;br /&gt;
The PaintWeb library code must also provide API for using PaintWeb standalone in any page desired by the developer. Here&#039;s an idea:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function paintweb_setup () {&lt;br /&gt;
  global $PAGE;&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/build/paintweb.js&#039;);&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js(&#039;/lib/paintweb/ext/moodle/lib.js&#039;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
function paintweb_insert ($elementId, array $config = array()) {&lt;br /&gt;
  global $CFG, $PAGE;&lt;br /&gt;
&lt;br /&gt;
  // tell PaintWeb where it the codebase lives in&lt;br /&gt;
  $config[&#039;baseFolder&#039;] = $CFG-&amp;gt;wwwroot . &#039;/lib/paintweb/build/&#039;;&lt;br /&gt;
&lt;br /&gt;
  $PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;paintweb_moodle_init&#039;, array($elementId, $config));&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ext/moodle/lib.js&#039;&#039;&#039; can initialize PaintWeb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;&lt;br /&gt;
function paintweb_moodle_init (elemId, config) {&lt;br /&gt;
  var pw = new PaintWeb();&lt;br /&gt;
  pw.config.guiPlaceholder = document.getElementById(elemId);&lt;br /&gt;
&lt;br /&gt;
  // need to point to the PaintWeb folder, inside the Moodle folder&lt;br /&gt;
  pw.config.baseFolder = config.baseFolder;&lt;br /&gt;
&lt;br /&gt;
  // the Moodle config&lt;br /&gt;
  pw.config.configFile = &#039;config-moodle.json&#039;;&lt;br /&gt;
&lt;br /&gt;
  if (config) {&lt;br /&gt;
    for (var prop in config) {&lt;br /&gt;
      pw.config[prop] = config[prop];&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  pw.init();&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Localization =&lt;br /&gt;
&lt;br /&gt;
The TinyMCE integration has a script which generates Moodle language files from the original files provided by TinyMCE.&lt;br /&gt;
&lt;br /&gt;
I can write a script to convert the PaintWeb JSON language files into Moodle PHP languages files, and back.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59466</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59466"/>
		<updated>2009-07-07T16:34:18Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: thoughts on the moodle api which allows html editor usage&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor ([http://tinymce.moxiecode.com TinyMCE] mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweblib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= The Moodle editors API =&lt;br /&gt;
&lt;br /&gt;
Currently, developers who want to have a textarea element in their page with TinyMCE can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// setup the page requirements (JS files needed to be loaded)&lt;br /&gt;
editors_head_setup();&lt;br /&gt;
&lt;br /&gt;
// get an instance of the editor&lt;br /&gt;
$editor = get_preferred_texteditor(FORMAT_HTML);&lt;br /&gt;
&lt;br /&gt;
// use the editor: textarea element ID, and options.&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;, array(&#039;noclean&#039;=&amp;gt;true));&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;textarea rows=&amp;quot;20&amp;quot; cols=&amp;quot;10&amp;quot; id=&amp;quot;elementId&amp;quot;&amp;gt;some HTML&amp;lt;/textarea&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Petr Škoda, the developer of the API, the API still needs lots of work. Personally I consider the API only needs ... further work. Here&#039;s how I&#039;d like to do things:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$editor-&amp;gt;use_editor(&#039;elementId&#039;,&lt;br /&gt;
  array(&#039;imageEditing&#039; =&amp;gt; true,&lt;br /&gt;
        &#039;mathEditing&#039; =&amp;gt; true&lt;br /&gt;
  )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, I don&#039;t think there&#039;s something inherently &amp;quot;bad&amp;quot; about the current API. I only want to tell the editor instance &amp;quot;hey, I&#039;d like image editing, math editing, etc, if possible&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
I&#039;d say try to keep things abstracted. So, if I say in the options array I want image editing, then TinyMCE can load the PaintWeb plugin. If I want math editing, then load &#039;&#039;&#039;dragmath&#039;&#039;&#039; and anything related.&lt;br /&gt;
&lt;br /&gt;
The way each editor implements these features should be left up to the editor itself.&lt;br /&gt;
&lt;br /&gt;
Obviously, based on such options, even the editor GUI can be altered: say if the PaintWeb plugin is desired, then the &#039;&#039;paintwebEdit&#039;&#039; button can be included in the theme toolbar.&lt;br /&gt;
&lt;br /&gt;
Additionally, we should have options for configuring the GUI - but not something tied to the TinyMCE config. I don&#039;t think the API should go down the road of allowing the direct input of TinyMCE configuration options. If that&#039;s desired, then do not have multiple editors. Switch to a single editor: TinyMCE and have all the API tailored to this editor.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59458</id>
		<title>Paint tool integration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_integration&amp;diff=59458"/>
		<updated>2009-07-07T15:15:37Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: initial submit, more to come&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://code.google.com/p/paintweb PaintWeb] is the paint tool which is going to be integrated into Moodle. For more information about PaintWeb please read [https://docs.moodle.org/en/Development:Paint_tool the project specification].&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
PaintWeb is currently a strictly client-side project, a Web application. It provides an API for developers who wish to extend its functionality, via new drawing tools, new extensions and new commands.&lt;br /&gt;
&lt;br /&gt;
The plan is to integrate PaintWeb in Moodle in the appropriate places. Meaning, in some cases, users would like to be able to edit images, in place, in the HTML editor (TinyMCE mostly). Another place of integration would be [https://docs.moodle.org/en/Development:Editor_file_management the file manager] - there users should be allowed to pick images files and edit them. Another use-case for PaintWeb is separate loading, stand-alone usage - for example a page which only allows the user to draw on the Canvas and save the result.&lt;br /&gt;
&lt;br /&gt;
PaintWeb already includes a TinyMCE plugin which allows users to start editing any image in the HTML document. The plugin allows users to start editing an image by clicking an &#039;&#039;&#039;Edit&#039;&#039;&#039; button which shows overlayed on top of images when they are selected. Additionally, users can right-click an image to pick the &#039;&#039;&#039;Edit in PaintWeb&#039;&#039;&#039;. Lastly, when the advanced theme is used, the &#039;&#039;paintwebEdit&#039;&#039; button is also available.&lt;br /&gt;
&lt;br /&gt;
Things to take into consideration:&lt;br /&gt;
&lt;br /&gt;
* PaintWeb can only edit images from the same domain, due to security restrictions. This means that any image from a different domain is either denied from editing, or we can use a server-side script which downloads the image locally on the server. The latter option is more cumbersome, and I believe it implies some security risks: the user can point to arbitrary malicious files which the server downloads and sends back to the browser. The TinyMCE plugin I have does not allow the users to edit of any image from a different domain.&lt;br /&gt;
&lt;br /&gt;
* The TinyMCE plugin needs to be loaded dynamically. The PaintWeb image editor should not show up in &#039;&#039;&#039;all&#039;&#039;&#039; cases where TinyMCE is used. Thus, Moodle needs an API which other developers can use to show the HTML editor and configure it: &#039;&#039;&amp;quot;hey, I want PaintWeb as well!&amp;quot;&#039;&#039; or not.&lt;br /&gt;
&lt;br /&gt;
* There&#039;s an important difference between the use of PaintWeb inside TinyMCE and standalone use. Inside TinyMCE the user already has a dialog for inserting images - thus in PaintWeb we do not need an option to load another image. In PaintWeb-TinyMCE we only need the options to save and cancel the changes. In a standalone instance of PaintWeb we might want to allow the user to load and save images at will. The file manager use-case is the same as in TinyMCE: the file manager handles the files itself, PaintWeb should be strictly the image editor (with save/cancel).&lt;br /&gt;
&lt;br /&gt;
Given the above, here is what I consider needs to be done:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has an API for inserting the HTML editor (TinyMCE) anywhere desired. This API needs to be extended such that the developer can tell which plugins need to be loaded - in this case PaintWeb.&lt;br /&gt;
&lt;br /&gt;
* Moodle 2 has a [https://docs.moodle.org/en/Development:Using_the_File_API File API] which needs to be used by PaintWeb when the file save/load operations are performed. On the client-side of things this can be done by writing an [http://code.google.com/p/paintweb/wiki/ExtendingPaintWeb extension for PaintWeb] which handles events like [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/symbols/pwlib.appEvent.imageSave.html imageSave]. PaintWeb in Moodle needs some &amp;quot;common backend&amp;quot; which handles image save/load in all use-cases.&lt;br /&gt;
&lt;br /&gt;
* It should be noted that having a PaintWeb extensions specific for Moodle would replace the need of having custom patches applied to PaintWeb - like Moodle does for TinyMCE.&lt;br /&gt;
&lt;br /&gt;
* The PaintWeb script needs to communicate with the server to perform file load/save. So, on the server-side these operations can be handled by a piece of common code, e.g. &#039;&#039;&#039;/lib/paintweblib.php&#039;&#039;&#039;. Suggestions for a different file name / place are welcome. This PHP script needs to use the File API to perform the desired operations. An API needs to be exposed by this file, an API others can use to integrate PaintWeb in a standalone page. For example &#039;&#039;&#039;paintweb_setup()&#039;&#039;&#039; which sets-up the required JS file in the page, for the current page. Then &#039;&#039;&#039;paintweb_insert(options)&#039;&#039;&#039; to insert the PaintWeb initialization code, with user-defined options.&lt;br /&gt;
&lt;br /&gt;
* The upcoming  [https://docs.moodle.org/en/Development:Editor_file_management file manager] needs an API for adding &amp;quot;file handlers&amp;quot;. For example, PaintWeb can be a file handler for images. Thus, a button, or some context menu item for images could be displayed &#039;&#039;&#039;Edit this image in PaintWeb&#039;&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59281</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59281"/>
		<updated>2009-07-03T20:44:24Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to the wiki pages i just created - documentation for developers.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 3, 2009:&#039;&#039;&#039; More [http://code.google.com/p/paintweb/w/list PaintWeb documentation] is now available.&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59270</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=59270"/>
		<updated>2009-07-03T08:37:09Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: added links to the API reference and to the latest blog post&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; API reference documentation published [http://www.robodesign.ro/paintweb/trunk/docs/api-ref/].&lt;br /&gt;
* &#039;&#039;&#039;July 2, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/api-reference-and-packaging-for-paintweb API reference and packaging for PaintWeb].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=58745</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=58745"/>
		<updated>2009-06-23T20:37:55Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to new blog post: Canvas text rendering&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/canvas-text-rendering Canvas text rendering].&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance].&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more].&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring].&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=58744</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=58744"/>
		<updated>2009-06-23T19:50:40Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to the newest forum discussion thread: PaintWeb demo - please test&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;June 23, 2009:&#039;&#039;&#039; Forum discussion: [http://moodle.org/mod/forum/discuss.php?d=126528 PaintWeb demo - please test] in the Moodle K12 forums.&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance]&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring]&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=58605</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=58605"/>
		<updated>2009-06-22T09:17:57Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: link to new blog post: PaintWeb has a new user interface&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;June 22, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-has-a-new-user-interface PaintWeb has a new user interface].&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance]&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring]&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Anv%C3%A4ndare:Mihai_Sucan&amp;diff=56952</id>
		<title>Användare:Mihai Sucan</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Anv%C3%A4ndare:Mihai_Sucan&amp;diff=56952"/>
		<updated>2009-05-31T13:54:37Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: add link to paintweb as well&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello!&lt;br /&gt;
&lt;br /&gt;
I am [http://www.robodesign.ro Mihai Şucan], a student from Romania.&lt;br /&gt;
&lt;br /&gt;
I am integrating a paint tool into [http://www.moodle.org Moodle], as part of the [http://code.google.com/soc/ Google Summer of Code 2009] program.&lt;br /&gt;
&lt;br /&gt;
For more information please check:&lt;br /&gt;
&lt;br /&gt;
* [http://www.robodesign.ro my site]&lt;br /&gt;
* [https://docs.moodle.org/en/Development:Paint_tool the GSOC project specification]&lt;br /&gt;
* [http://code.google.com/p/paintweb the PaintWeb project]&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=56951</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=56951"/>
		<updated>2009-05-31T13:53:18Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: add link to the OLPC wiki page about HTML Canvas performance&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;May 31, 2009:&#039;&#039;&#039; OLPC Wiki: [http://wiki.laptop.org/go/HTML_canvas_performance HTML Canvas performance]&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring]&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Anv%C3%A4ndare:Mihai_Sucan&amp;diff=56950</id>
		<title>Användare:Mihai Sucan</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Anv%C3%A4ndare:Mihai_Sucan&amp;diff=56950"/>
		<updated>2009-05-31T13:49:55Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: my page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello!&lt;br /&gt;
&lt;br /&gt;
I am [http://www.robodesign.ro Mihai Şucan], a student from Romania.&lt;br /&gt;
&lt;br /&gt;
I am integrating a paint tool into [http://www.moodle.org Moodle], as part of the [http://code.google.com/soc/ Google Summer of Code 2009] program.&lt;br /&gt;
&lt;br /&gt;
For more information please check:&lt;br /&gt;
&lt;br /&gt;
* [http://www.robodesign.ro my site]&lt;br /&gt;
* [https://docs.moodle.org/en/Development:Paint_tool my GSOC project specification].&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=56796</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=56796"/>
		<updated>2009-05-28T12:05:19Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: Link to blog post: PaintWeb performance&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This project will create a painting tool that can be used inside Moodle. It allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
{{Template:GSOC 09}}&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;May 28, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-performance PaintWeb performance]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring]&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=55722</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=55722"/>
		<updated>2009-05-14T12:27:13Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: include links to the latest blog post and forum thread about code refactoring&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Blog post: [http://www.robodesign.ro/mihai/blog/paintweb-code-refactoring-and-more PaintWeb code refactoring and more]&lt;br /&gt;
* &#039;&#039;&#039;May 14, 2009:&#039;&#039;&#039; Forum post: [http://moodle.org/mod/forum/discuss.php?d=123365 Testers wanted - paint tool code refactoring]&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55512</id>
		<title>Paint tool questions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55512"/>
		<updated>2009-05-10T13:48:09Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Summary */ making more obvious where i want the answers posted&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
I am [http://moodle.org/user/view.php?id=832305&amp;amp;course=1 Mihai Sucan], one of the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] students. I will be developing a new paint tool for Moodle. The Web application will not require any browser plugins. Drawing will be only bitmap-based. The gist of the code will be JavaScript mostly, with some server-side code for integration into Moodle.&lt;br /&gt;
&lt;br /&gt;
The main goal of the project are to is a working, simple to use paint tool for kids. For adults, the tool could also act as a quick way to draw something on a whiteboard. First and foremost, we plan to integrate [http://code.google.com/p/paintweb PaintWeb] into [http://tinymce.moxiecode.com TinyMCE] so that users will be able to click &amp;quot;&#039;&#039;&#039;Edit image&#039;&#039;&#039;&amp;quot; for any image element they have in the HTML article they are editing. This will invoke the paint tool from where any changes can be made, and then saved back to the server.&lt;br /&gt;
&lt;br /&gt;
Beyond the stated goals, we cannot expect too many things in addition, since three months is not much time. We did think about implementing layers support, vector shapes, realtime collaboration in Chat between multiple users, and more. However, such features are not a realistic aim for the end of the summer. This doesn&#039;t mean such features will never become available - we might go ahead and implement some after the summer.&lt;br /&gt;
&lt;br /&gt;
Please [https://docs.moodle.org/en/Development:Paint_tool read the specification], and also please check out the [http://code.google.com/p/paintweb/ Google Code PaintWeb project] where you can play with the paint tool already.&lt;br /&gt;
&lt;br /&gt;
This wiki page serves the purpose of listing questions to potential users of the paint tool. I want to understand how teachers/users would want the paint tool integrated, how they want to use it, for what, etc.&lt;br /&gt;
&lt;br /&gt;
I welcome any additional feedback, besides answers to the questions below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Please post your replies in [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread]. Thanks!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Thanks go to [http://moodle.org/user/view.php?id=141847&amp;amp;course=1 Olli Savolainen] for his [http://moodle.org/mod/forum/discuss.php?d=122460 valuable feedback] provided on the forums!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
== Background information ==&lt;br /&gt;
&lt;br /&gt;
* Are you a teacher? What do you teach?&lt;br /&gt;
* Please describe what you do, your interests, and why you use Moodle.&lt;br /&gt;
* Please describe why you would want a paint tool in Moodle.&lt;br /&gt;
* How much do you use computers? How about Web browsers?&lt;br /&gt;
* Do you have experience with other educational platforms?&lt;br /&gt;
* Do you have experience with other drawing tools? online? offline?&lt;br /&gt;
* Do you have experience wth dynamic geometry software? Like [http://www.geogebra.org Geogebra], [http://www.dynamicgeometry.com Sketchpad], [http://edu.kde.org/kig/ Kig] or others.&lt;br /&gt;
** Out of the dynamic geometry applications you have tested, name the one you like most.&lt;br /&gt;
** Also, please tell me the one you use most often. (might not always be the same as the most liked application...)&lt;br /&gt;
* Do your students have disabilities? Please explain which kind of disabilities.&lt;br /&gt;
** Do their disabilities impose some kind of requirements on a paint tool and on software in general? Please explain.&lt;br /&gt;
&lt;br /&gt;
== Project goals ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how the stated goals fit into user needs.&lt;br /&gt;
&lt;br /&gt;
* What&#039;s the first thing that came into your mind when you heard a paint tool is being developed during GSOC for Moodle?&lt;br /&gt;
* Do the stated goals come close to what you expected? Please explain.&lt;br /&gt;
** If not, what would you believe is more important?&lt;br /&gt;
** If this is not really what you want, would you still use it?&lt;br /&gt;
* If you would have to choose having only one Web application, what would you like in Moodle:&lt;br /&gt;
** a dynamic geometry application,&lt;br /&gt;
** a vector drawing tool,&lt;br /&gt;
** or a bitmapped drawing tool?&lt;br /&gt;
&lt;br /&gt;
== Technical requirements ==&lt;br /&gt;
&lt;br /&gt;
* What are the system, OS and browser requirements for the paint tool in your case? &lt;br /&gt;
* Please describe your usage environment (operating systems, browsers, general system performance, etc).&lt;br /&gt;
* Would you use the paint tool if it only works on one of the following operating systems: Windows, Linux, or Mac?&lt;br /&gt;
* Would you use the paint tool if it only works in Internet Explorer? Would you use it if it works in all major browsers except Internet Explorer?&lt;br /&gt;
* What screen resolution do you generally use?&lt;br /&gt;
* What image dimensions would you expect to use? (images of a high resolution need additional system resources)&lt;br /&gt;
* Your Internet connection speed?&lt;br /&gt;
** How about the school, how&#039;s the Internet connection speed?&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
* As a teacher, would you ask your young students to do drawing assignments/exams in an online environment?&lt;br /&gt;
** How would you do that? Please explain usage scenarios:&lt;br /&gt;
*** How you would create an assignment/exam?&lt;br /&gt;
*** Where you would like to find the paint tool?&lt;br /&gt;
*** How would you use it?&lt;br /&gt;
* Do you want the paint tool to be available anywhere TinyMCE is used for article editing? Such that you can edit any image in your article.&lt;br /&gt;
** If not, where would you like it only?&lt;br /&gt;
* In which situations your students should be allowed to draw?&lt;br /&gt;
** How about disallowing students to draw in some situations?&lt;br /&gt;
** When would you require students to only draw instead of write?&lt;br /&gt;
** Would these situations have different requirements on the application? Different user interface, tools, interaction, integration, etc.&lt;br /&gt;
* When would you require your students to draw on a physical support instead of using the digital drawing pad?&lt;br /&gt;
** How about the other way around, requiring students to use the Moodle painting tool instead of a physical whiteboard?&lt;br /&gt;
* What impact do you believe a painting tool would have on how you teach drawing to children?&lt;br /&gt;
* How do you proceed when you ask your students to draw something? What&#039;s the process, from start to finish?&lt;br /&gt;
* Based on the current process, what would you like in a Moodle painting tool?&lt;br /&gt;
* Do you find the current process of inserting drawings into Moodle cumbersome?&lt;br /&gt;
** What would improve things for you?&lt;br /&gt;
* Name something you do not like in the current process of working with drawings/images in Moodle.&lt;br /&gt;
* Name what you like most about Moodle in regards to working with drawings.&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for quick-drawing of some mathematical formulas?&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for drawing geometry shapes? Triangles, rectangles, etc. (even if it&#039;s not a dynamic geometry application)&lt;br /&gt;
&lt;br /&gt;
== Tools and features ==&lt;br /&gt;
&lt;br /&gt;
* Does the current set of drawing tools satisfy your needs?&lt;br /&gt;
* Which new tools you want added?&lt;br /&gt;
** Please name a few new tools you deem as required.&lt;br /&gt;
* Do you want predefined shapes?&lt;br /&gt;
** Please list some of the ones you would need most often.&lt;br /&gt;
* How important would be the ability to replay the drawing construction?&lt;br /&gt;
* How important is to have multiple layers support?&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55499</id>
		<title>Paint tool questions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55499"/>
		<updated>2009-05-09T10:18:35Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Usage */ improve some questions about different usage situations&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
I am [http://moodle.org/user/view.php?id=832305&amp;amp;course=1 Mihai Sucan], one of the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] students. I will be developing a new paint tool for Moodle. The Web application will not require any browser plugins. Drawing will be only bitmap-based. The gist of the code will be JavaScript mostly, with some server-side code for integration into Moodle.&lt;br /&gt;
&lt;br /&gt;
The main goal of the project are to is a working, simple to use paint tool for kids. For adults, the tool could also act as a quick way to draw something on a whiteboard. First and foremost, we plan to integrate [http://code.google.com/p/paintweb PaintWeb] into [http://tinymce.moxiecode.com TinyMCE] so that users will be able to click &amp;quot;&#039;&#039;&#039;Edit image&#039;&#039;&#039;&amp;quot; for any image element they have in the HTML article they are editing. This will invoke the paint tool from where any changes can be made, and then saved back to the server.&lt;br /&gt;
&lt;br /&gt;
Beyond the stated goals, we cannot expect too many things in addition, since three months is not much time. We did think about implementing layers support, vector shapes, realtime collaboration in Chat between multiple users, and more. However, such features are not a realistic aim for the end of the summer. This doesn&#039;t mean such features will never become available - we might go ahead and implement some after the summer.&lt;br /&gt;
&lt;br /&gt;
Please [https://docs.moodle.org/en/Development:Paint_tool read the specification], and also please check out the [http://code.google.com/p/paintweb/ Google Code PaintWeb project] where you can play with the paint tool already.&lt;br /&gt;
&lt;br /&gt;
This wiki page serves the purpose of listing questions to potential users of the paint tool. I want to understand how teachers/users would want the paint tool integrated, how they want to use it, for what, etc.&lt;br /&gt;
&lt;br /&gt;
I welcome any additional feedback, besides answers to the questions below. Please post your replies in [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Thanks go to [http://moodle.org/user/view.php?id=141847&amp;amp;course=1 Olli Savolainen] for his [http://moodle.org/mod/forum/discuss.php?d=122460 valuable feedback] provided on the forums!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
== Background information ==&lt;br /&gt;
&lt;br /&gt;
* Are you a teacher? What do you teach?&lt;br /&gt;
* Please describe what you do, your interests, and why you use Moodle.&lt;br /&gt;
* Please describe why you would want a paint tool in Moodle.&lt;br /&gt;
* How much do you use computers? How about Web browsers?&lt;br /&gt;
* Do you have experience with other educational platforms?&lt;br /&gt;
* Do you have experience with other drawing tools? online? offline?&lt;br /&gt;
* Do you have experience wth dynamic geometry software? Like [http://www.geogebra.org Geogebra], [http://www.dynamicgeometry.com Sketchpad], [http://edu.kde.org/kig/ Kig] or others.&lt;br /&gt;
** Out of the dynamic geometry applications you have tested, name the one you like most.&lt;br /&gt;
** Also, please tell me the one you use most often. (might not always be the same as the most liked application...)&lt;br /&gt;
* Do your students have disabilities? Please explain which kind of disabilities.&lt;br /&gt;
** Do their disabilities impose some kind of requirements on a paint tool and on software in general? Please explain.&lt;br /&gt;
&lt;br /&gt;
== Project goals ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how the stated goals fit into user needs.&lt;br /&gt;
&lt;br /&gt;
* What&#039;s the first thing that came into your mind when you heard a paint tool is being developed during GSOC for Moodle?&lt;br /&gt;
* Do the stated goals come close to what you expected? Please explain.&lt;br /&gt;
** If not, what would you believe is more important?&lt;br /&gt;
** If this is not really what you want, would you still use it?&lt;br /&gt;
* If you would have to choose having only one Web application, what would you like in Moodle:&lt;br /&gt;
** a dynamic geometry application,&lt;br /&gt;
** a vector drawing tool,&lt;br /&gt;
** or a bitmapped drawing tool?&lt;br /&gt;
&lt;br /&gt;
== Technical requirements ==&lt;br /&gt;
&lt;br /&gt;
* What are the system, OS and browser requirements for the paint tool in your case? &lt;br /&gt;
* Please describe your usage environment (operating systems, browsers, general system performance, etc).&lt;br /&gt;
* Would you use the paint tool if it only works on one of the following operating systems: Windows, Linux, or Mac?&lt;br /&gt;
* Would you use the paint tool if it only works in Internet Explorer? Would you use it if it works in all major browsers except Internet Explorer?&lt;br /&gt;
* What screen resolution do you generally use?&lt;br /&gt;
* What image dimensions would you expect to use? (images of a high resolution need additional system resources)&lt;br /&gt;
* Your Internet connection speed?&lt;br /&gt;
** How about the school, how&#039;s the Internet connection speed?&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
* As a teacher, would you ask your young students to do drawing assignments/exams in an online environment?&lt;br /&gt;
** How would you do that? Please explain usage scenarios:&lt;br /&gt;
*** How you would create an assignment/exam?&lt;br /&gt;
*** Where you would like to find the paint tool?&lt;br /&gt;
*** How would you use it?&lt;br /&gt;
* Do you want the paint tool to be available anywhere TinyMCE is used for article editing? Such that you can edit any image in your article.&lt;br /&gt;
** If not, where would you like it only?&lt;br /&gt;
* In which situations your students should be allowed to draw?&lt;br /&gt;
** How about disallowing students to draw in some situations?&lt;br /&gt;
** When would you require students to only draw instead of write?&lt;br /&gt;
** Would these situations have different requirements on the application? Different user interface, tools, interaction, integration, etc.&lt;br /&gt;
* When would you require your students to draw on a physical support instead of using the digital drawing pad?&lt;br /&gt;
** How about the other way around, requiring students to use the Moodle painting tool instead of a physical whiteboard?&lt;br /&gt;
* What impact do you believe a painting tool would have on how you teach drawing to children?&lt;br /&gt;
* How do you proceed when you ask your students to draw something? What&#039;s the process, from start to finish?&lt;br /&gt;
* Based on the current process, what would you like in a Moodle painting tool?&lt;br /&gt;
* Do you find the current process of inserting drawings into Moodle cumbersome?&lt;br /&gt;
** What would improve things for you?&lt;br /&gt;
* Name something you do not like in the current process of working with drawings/images in Moodle.&lt;br /&gt;
* Name what you like most about Moodle in regards to working with drawings.&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for quick-drawing of some mathematical formulas?&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for drawing geometry shapes? Triangles, rectangles, etc. (even if it&#039;s not a dynamic geometry application)&lt;br /&gt;
&lt;br /&gt;
== Tools and features ==&lt;br /&gt;
&lt;br /&gt;
* Does the current set of drawing tools satisfy your needs?&lt;br /&gt;
* Which new tools you want added?&lt;br /&gt;
** Please name a few new tools you deem as required.&lt;br /&gt;
* Do you want predefined shapes?&lt;br /&gt;
** Please list some of the ones you would need most often.&lt;br /&gt;
* How important would be the ability to replay the drawing construction?&lt;br /&gt;
* How important is to have multiple layers support?&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=55498</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=55498"/>
		<updated>2009-05-09T10:05:37Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: paint tool questions K12 forums thread link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users. Also check [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle: [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion.&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55497</id>
		<title>Paint tool questions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55497"/>
		<updated>2009-05-09T10:04:09Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: forum link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
I am [http://moodle.org/user/view.php?id=832305&amp;amp;course=1 Mihai Sucan], one of the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] students. I will be developing a new paint tool for Moodle. The Web application will not require any browser plugins. Drawing will be only bitmap-based. The gist of the code will be JavaScript mostly, with some server-side code for integration into Moodle.&lt;br /&gt;
&lt;br /&gt;
The main goal of the project are to is a working, simple to use paint tool for kids. For adults, the tool could also act as a quick way to draw something on a whiteboard. First and foremost, we plan to integrate [http://code.google.com/p/paintweb PaintWeb] into [http://tinymce.moxiecode.com TinyMCE] so that users will be able to click &amp;quot;&#039;&#039;&#039;Edit image&#039;&#039;&#039;&amp;quot; for any image element they have in the HTML article they are editing. This will invoke the paint tool from where any changes can be made, and then saved back to the server.&lt;br /&gt;
&lt;br /&gt;
Beyond the stated goals, we cannot expect too many things in addition, since three months is not much time. We did think about implementing layers support, vector shapes, realtime collaboration in Chat between multiple users, and more. However, such features are not a realistic aim for the end of the summer. This doesn&#039;t mean such features will never become available - we might go ahead and implement some after the summer.&lt;br /&gt;
&lt;br /&gt;
Please [https://docs.moodle.org/en/Development:Paint_tool read the specification], and also please check out the [http://code.google.com/p/paintweb/ Google Code PaintWeb project] where you can play with the paint tool already.&lt;br /&gt;
&lt;br /&gt;
This wiki page serves the purpose of listing questions to potential users of the paint tool. I want to understand how teachers/users would want the paint tool integrated, how they want to use it, for what, etc.&lt;br /&gt;
&lt;br /&gt;
I welcome any additional feedback, besides answers to the questions below. Please post your replies in [http://moodle.org/mod/forum/discuss.php?d=122978 the K12 forums thread].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Thanks go to [http://moodle.org/user/view.php?id=141847&amp;amp;course=1 Olli Savolainen] for his [http://moodle.org/mod/forum/discuss.php?d=122460 valuable feedback] provided on the forums!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
== Background information ==&lt;br /&gt;
&lt;br /&gt;
* Are you a teacher? What do you teach?&lt;br /&gt;
* Please describe what you do, your interests, and why you use Moodle.&lt;br /&gt;
* Please describe why you would want a paint tool in Moodle.&lt;br /&gt;
* How much do you use computers? How about Web browsers?&lt;br /&gt;
* Do you have experience with other educational platforms?&lt;br /&gt;
* Do you have experience with other drawing tools? online? offline?&lt;br /&gt;
* Do you have experience wth dynamic geometry software? Like [http://www.geogebra.org Geogebra], [http://www.dynamicgeometry.com Sketchpad], [http://edu.kde.org/kig/ Kig] or others.&lt;br /&gt;
** Out of the dynamic geometry applications you have tested, name the one you like most.&lt;br /&gt;
** Also, please tell me the one you use most often. (might not always be the same as the most liked application...)&lt;br /&gt;
* Do your students have disabilities? Please explain which kind of disabilities.&lt;br /&gt;
** Do their disabilities impose some kind of requirements on a paint tool and on software in general? Please explain.&lt;br /&gt;
&lt;br /&gt;
== Project goals ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how the stated goals fit into user needs.&lt;br /&gt;
&lt;br /&gt;
* What&#039;s the first thing that came into your mind when you heard a paint tool is being developed during GSOC for Moodle?&lt;br /&gt;
* Do the stated goals come close to what you expected? Please explain.&lt;br /&gt;
** If not, what would you believe is more important?&lt;br /&gt;
** If this is not really what you want, would you still use it?&lt;br /&gt;
* If you would have to choose having only one Web application, what would you like in Moodle:&lt;br /&gt;
** a dynamic geometry application,&lt;br /&gt;
** a vector drawing tool,&lt;br /&gt;
** or a bitmapped drawing tool?&lt;br /&gt;
&lt;br /&gt;
== Technical requirements ==&lt;br /&gt;
&lt;br /&gt;
* What are the system, OS and browser requirements for the paint tool in your case? &lt;br /&gt;
* Please describe your usage environment (operating systems, browsers, general system performance, etc).&lt;br /&gt;
* Would you use the paint tool if it only works on one of the following operating systems: Windows, Linux, or Mac?&lt;br /&gt;
* Would you use the paint tool if it only works in Internet Explorer? Would you use it if it works in all major browsers except Internet Explorer?&lt;br /&gt;
* What screen resolution do you generally use?&lt;br /&gt;
* What image dimensions would you expect to use? (images of a high resolution need additional system resources)&lt;br /&gt;
* Your Internet connection speed?&lt;br /&gt;
** How about the school, how&#039;s the Internet connection speed?&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
* As a teacher, would you ask your young students to do drawing assignments/exams in an online environment?&lt;br /&gt;
** How would you do that? Please explain usage scenarios:&lt;br /&gt;
*** How you would create an assignment/exam?&lt;br /&gt;
*** Where you would like to find the paint tool?&lt;br /&gt;
*** How would you use it?&lt;br /&gt;
* Do you want the paint tool to be available anywhere TinyMCE is used for article editing? Such that you can edit any image in your article.&lt;br /&gt;
** If not, where would you like it only?&lt;br /&gt;
* When would you require your students to draw on a physical support instead of using the digital drawing pad?&lt;br /&gt;
** How about the other way around, requiring students to use the Moodle painting tool instead of a physical whiteboard?&lt;br /&gt;
* What impact do you believe a painting tool would have on how you teach drawing to children?&lt;br /&gt;
* How do you proceed when you ask your students to draw something? What&#039;s the process, from start to finish?&lt;br /&gt;
* Based on current process, what would you like in a Moodle painting tool?&lt;br /&gt;
* Do you find the current process of inserting drawings into Moodle cumbersome?&lt;br /&gt;
** What would improve things for you?&lt;br /&gt;
* Name something you do not like in the current process of working with drawings/images in Moodle.&lt;br /&gt;
* Name what you like most about Moodle in regards to working with drawings.&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for quick-drawing of some mathematical formulas?&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for drawing geometry shapes? Triangles, rectangles, etc. (even if it&#039;s not a dynamic geometry application)&lt;br /&gt;
* In which teaching situations would you use a paint tool?&lt;br /&gt;
** Would these situations have different requirements on the application? (user interface, interaction, integration, etc)&lt;br /&gt;
&lt;br /&gt;
== Tools and features ==&lt;br /&gt;
&lt;br /&gt;
* Does the current set of drawing tools satisfy your needs?&lt;br /&gt;
* Which new tools you want added?&lt;br /&gt;
** Please name a few new tools you deem as required.&lt;br /&gt;
* Do you want predefined shapes?&lt;br /&gt;
** Please list some of the ones you would need most often.&lt;br /&gt;
* How important would be the ability to replay the drawing construction?&lt;br /&gt;
* How important is to have multiple layers support?&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=55496</id>
		<title>Paint tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool&amp;diff=55496"/>
		<updated>2009-05-09T09:46:53Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: corrections to structure, link to paint tool questions and more&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
Specification for the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] paint tool project.&lt;br /&gt;
&lt;br /&gt;
[http://www.robodesign.ro Mihai Şucan], [http://www.uav.ro Aurel Vlaicu University], Romania.&lt;br /&gt;
&lt;br /&gt;
The goal is to develop a new online painting tool inside Moodle, one which allows users to edit images in the HTML editor, in the file manager and in other places.&lt;br /&gt;
&lt;br /&gt;
The paint tool will be tightly integrated into [http://tinymce.moxiecode.com TinyMCE] and into Moodle, providing an API for embedding in several ways described below. Additionally, the tool will be developed such that it will allow other non Moodle developers to use the Web application.&lt;br /&gt;
&lt;br /&gt;
For the implementation of the painting Web application I will use the HTML 5 Canvas API.&lt;br /&gt;
&lt;br /&gt;
I have already developed a proof-of-concept / demo Web application, named [http://code.google.com/p/paintweb PaintWeb]. This project is currently being worked on for improvements to core code. A new user interface will soon become available as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The current PaintWeb demo is underdeveloped, it&#039;s simply only a proof of concept. It lacks any browser-specific work arounds for limitations and bugs. For example, the Text tool only works in Safari 4, Firefox 3.5 and similarly new browsers.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Tracker issue&#039;&#039;&#039; [http://tracker.moodle.org/browse/MDL-18651]&lt;br /&gt;
* &#039;&#039;&#039;Forum discussion&#039;&#039;&#039; [http://moodle.org/mod/forum/discuss.php?d=119670]&lt;br /&gt;
* &#039;&#039;&#039;Blog&#039;&#039;&#039; [http://www.robodesign.ro/mihai/blog]&lt;br /&gt;
* &#039;&#039;&#039;Proposal status:&#039;&#039;&#039; Accepted. [http://socghop.appspot.com/org/home/google/gsoc2009/moodle]&lt;br /&gt;
* &#039;&#039;&#039;Mentor:&#039;&#039;&#039; [https://docs.moodle.org/en/User:Martin_Langhoff Martin Langhoff]&lt;br /&gt;
&lt;br /&gt;
= Motivation and use-cases =&lt;br /&gt;
&lt;br /&gt;
Children like to draw very much. They like to express themselves using colors, and drawing anything they imagine. Currently Moodle does not allow children to draw. Teachers cannot create assignments which require users to draw something. Any user who wants to insert a drawing has to go through great lengths to draw the image using some offline drawing tool, then upload and insert it into Moodle.&lt;br /&gt;
&lt;br /&gt;
During online chats many courses would benefit having a paint tool integrated. For example, in chats about geometry students and teachers need to draw the shapes they are referring to, important lines like perpendiculars/bisectors/etc. This is not yet possible in Moodle. Having a paint tool would allow the development of a &amp;quot;live sketchboard&amp;quot; during chat sessions.&lt;br /&gt;
&lt;br /&gt;
The same way of working and thinking about the educational act itself would enhance courses from wide ranges, such as, but not limited to chemestry, mathematics, geometry and painting.&lt;br /&gt;
&lt;br /&gt;
= Why Canvas =&lt;br /&gt;
&lt;br /&gt;
Canvas is a new element in the [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5 specification], which provides a 2D context API.&lt;br /&gt;
&lt;br /&gt;
* Drawing is bitmapped, therefore no additional DOM elements needed, Image data management/manipulation becomes simple and straight-forward.&lt;br /&gt;
* The entire API is native to the browser. No extensions needed, no plugins.&lt;br /&gt;
* &amp;quot;Communication&amp;quot; between the Web page and the Canvas element is trivial, not even worth mentioning. Fact is, Canvas lives in the native space of the browser. You do not have any sandboxing, like in plugins (Flash/Java Applets). This also contributes to improved performance.&lt;br /&gt;
* Loading and saving images is trivial. The Canvas 2D context API provides simple methods for such purposes.&lt;br /&gt;
* Communication between JS and the server can be done via AJAX. It&#039;s much easier than doing it from Flash/Java Applets.&lt;br /&gt;
* Drawing is faster than using HTML, Flash, and Java Applets. Not-so-distant future plans for major Web browsers include OpenGL/DirectX hardware acceleration for most operations which means chosing Canvas is a very good decision in the longer term.&lt;br /&gt;
* Even if drawing is done on a bitmapped 2D canvas, the specification allows future browsers to implement saving the image as SVG, not just in a bitmapped format. The availability of SVG export can come with no cost for the Moodle developers, given a browser implementation which retains sufficient information to allow exporting the image to SVG.&lt;br /&gt;
* Better keyboard accessibility. Unlike Flash, Java Applets and other plugins, Canvas does not steal away the keyboard focus (one of the most annoying problems with plugins). Given the OLPC XO laptop and children users, this is very important for them.&lt;br /&gt;
* Zero performance impact for loading the Canvas-based Web application. Java Applets load very slow, freezing the browser for a few seconds (on AMD Athlon XP 1800+), and they require a lot more memory, because you have to run the entire JVM inside the browser. Flash also requires more memory to run. Again, users of OLPC XO laptop will most likely disable Flash/Gnash entirely, because it crawls down the entire browser when many Flash banners are shown on a single page.&lt;br /&gt;
* Flash is known, even by Google, to cause numerous crashes, and I quote: &amp;quot;&#039;&#039;&#039;Plugins are a major source of browser crashes. (Flash is in the callstack of a nontrivial percentage of Firefox crashes.&#039;&#039;&#039;)&amp;quot; [http://dev.chromium.org/developers/design-documents/plugin-architecture] It is, therefore, to be desired to avoid any kind of plugins, for stability reasons, not just performance.&lt;br /&gt;
* Canvas is a major browser feature being improved constantly. Each new version of each major Web browser improved the performance of the API.&lt;br /&gt;
* Almost no learning curve associated with developing a Canvas-based Web application. Existing JavaScript developers can further improve and fix the project at any time. They do not need Flash Professional (which is not free), they do not need to learn ActionScript, they do not need to learn Java. In general, it&#039;s better to keep the codebase compact, instead of each project using its own language. It&#039;s like using Python instead of PHP for some server-side parts.&lt;br /&gt;
* Cross-browser and cross-platform compatibility. Users do not need to install a different browser (it works in almost all major browsers, including, but not limited to Safari, Chrome, Opera, Firefox, Konqueror, Epiphany), and they do not need additional plugins, nor additional settings rather than the defaults. No specific operating system requirements are made either. Developers who want to work on the paint tool do not need to switch to Windows in order to edit some Flash project, and they do not need a completely different development stack for editing some Java project.&lt;br /&gt;
* Given the fact that all major browsers implement the Canvas 2D context API, except Microsoft Internet Explorer, makes it reasonable to expect that an upcoming release of MSIE will indeed support Canvas. Major companies already use Canvas in their projects (see [http://pipes.yahoo.com/ Yahoo Pipes]). Ultimately, it is in Microsoft&#039;s best interest to support a wider range of Web applications.&lt;br /&gt;
* The final version of [http://en.wikipedia.org/wiki/Internet_Explorer_8 Internet Explorer 8] was released in March. While it does not yet support the new Canvas element, this release has proven the renewed interest of Microsoft to implement new Web technologies, in an interoperable way. They have many standards-related improvements.&lt;br /&gt;
* Internet Explorer compatibility can be tackled in [http://www.azarask.in/blog/post/flash-canvas/ multiple ways]. For example, very recently a new release of the [http://code.google.com/p/explorercanvas/ ExplorerCanvas] project from Google has been made available. Such layers of compatibility are simple to use and do not generally require any additional changes to the drawing tool itself. Once IE will natively implement the Canvas support, we can simply remove the compatibility layer for the new version.&lt;br /&gt;
&lt;br /&gt;
I should also note that performance is critical not only for the OLPC XO. Many mobile devices like netbooks, notebooks and cell phones are getting connected to the Internet. All these devices have limited resources.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not very long time since Adobe released an up-to-date Flash player for Linux. Until then we were stuck with an outdated Flash player. However, now Flash player is much slower on Linux than the Flash player for Windows. We shouldn&#039;t be quick to forget the harm of closed source technologies.&lt;br /&gt;
&lt;br /&gt;
Regarding the use of more JavaScript libraries: the Moodle community and developers have made their choice. They use the Yahoo UI library. I do not want to introduce yet another library which only make things worse and slower. Performance is important and we also don&#039;t want bugs between conflicting JS libraries. I will use the YUI library when I consider it&#039;s needed inside PaintWeb.&lt;br /&gt;
&lt;br /&gt;
= Implementation details =&lt;br /&gt;
&lt;br /&gt;
== The paint tool ==&lt;br /&gt;
&lt;br /&gt;
We will reuse the open-source code from [http://code.google.com/p/paintweb PaintWeb]. I will completely reorganize the code, make a new GUI, and implement new functionality as desired by the community and the mentor.&lt;br /&gt;
&lt;br /&gt;
I plan to have a separate JS holding the implementation of the painting tools themselves. A separate JSON file for each language. We want PaintWeb to be internationalized. A separate file holding the implementation of the color editor, which will be a reusable component (maybe we can replace the color chooser from TinyMCE).&lt;br /&gt;
&lt;br /&gt;
Suggested file structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.js&#039;&#039;&#039; - the main codebase.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.min.js&#039;&#039;&#039; - the minified/compressed source code which includes the tools and the color editor packed together, for performance reasons. Optionally, this file can also include the language file, the config and the interface.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/paintweb.php&#039;&#039;&#039; - which provides API for easily including paintweb in any place across the entire Moodle application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/en.json&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/lang/ro.json&#039;&#039;&#039; ... etc&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/coloreditor.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.xhtml&#039;&#039;&#039; - the interface markup will not be included in the js, it&#039;s separate, for easy GUI tweaks.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/config.json&#039;&#039;&#039; - keyboard shortcuts and more settings.&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/interface.css&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/tools.js&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lib/paintweb/images/&#039;&#039;&#039; - any user interface images/icons needed.&lt;br /&gt;
* &#039;&#039;&#039;lang/*/paintweb.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;lang/*/help/paintweb/&#039;&#039;&#039; - folder holding user help pages for PaintWeb.&lt;br /&gt;
&lt;br /&gt;
All code will use [http://code.google.com/p/jsdoc-toolkit/ jsdoc-toolkit] comments, and an API reference documentation will be generated, to make it easy for new developers to understand the structure.&lt;br /&gt;
&lt;br /&gt;
For the language files, we can use PHP to properly connect to the global language system from Moodle (lang/*/paintweb.php).&lt;br /&gt;
&lt;br /&gt;
For the OLPC XO we might go for &amp;quot;hard-core&amp;quot; performance optimisations. Ideas:&lt;br /&gt;
&lt;br /&gt;
* Use data URIs for all images inside the CSS - less network requests, known to improve performance.&lt;br /&gt;
* Compact more files into a single one. We might need paintweb.olpc.js which includes as much as code as possible inside a single file. To do this, we will need an automatic packaging php script which takes all the separate files to build a single one.&lt;br /&gt;
* We might propose a different user interface for the OLPC, which is more minimalistic, and less resource-intensive.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039; To follow the on-going process of code reorganization, please take a look at the SVN repository hosting [http://code.google.com/p/paintweb/updates/list the PaintWeb project]. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== TinyMCE integration ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Tiny-mce.png|200px|thumb|right|TinyMCE 3 in Moodle 2 showing an image in the article being edited.]]&lt;br /&gt;
[[Image:Tinymce-properties.png|200px|thumb|right|The &amp;quot;Insert/edit image&amp;quot; dialog showing the new &amp;quot;Edit&amp;quot; button which allows invoking the paint tool]]&lt;br /&gt;
[[Image:Paintweb.png|200px|thumb|right|PaintWeb inside Moodle 2]]&lt;br /&gt;
&lt;br /&gt;
Looking through the source code of TinyMCE and on their official site: TinyMCE provides an API for extending the editor. Therefore, I propose we implement a new button which when clicked allows the user to edit the image he/she has selected in the HTML document. Once clicked, the PaintWeb tool loads, and changes all the toolbars, switching to a so-called &amp;quot;image editing&amp;quot; mode. Once done, the user can save the image (or else Cancel for no saving). We will need a sever-side script to handle the image save operation, some lib/paintweb/editor.php which takes the HTTP POST request, saves the file on the server in a folder we need to decide (mentor decision needed). Once the image is saved using AJAX, the user is returned back to the TinyMCE editor, exactly where he was. He will see the updated image.&lt;br /&gt;
&lt;br /&gt;
In order to implement this tight integration we need to add a new plugin in the &#039;&#039;&#039;lib/editor/tinymce/jscripts/tiny_mce/plugins&#039;&#039;&#039; folder. We will create the paintweb folder which will contain all the required JS to properly bind PaintWeb into TinyMCE.&lt;br /&gt;
&lt;br /&gt;
In a similar way, one can integrate PaintWeb into HTMLArea. Myself, I offer to integrate PaintWeb into TinyMCE, due to time restrains, and due to the fact HTMLArea is rather outdated.&lt;br /&gt;
&lt;br /&gt;
=== Mockup screenshots ===&lt;br /&gt;
&lt;br /&gt;
The current TinyMCE 3 editor has an &amp;quot;Insert/edit image&amp;quot; button on the toolbar. I suggest we add a new &amp;quot;Edit&amp;quot; button in the &amp;quot;Insert/edit image&amp;quot; dialog. This new button would allow the user to invoke PaintWeb to edit/re-edit &#039;&#039;&#039;any&#039;&#039;&#039; image he has selected inside the HTML editor. The image transfer will be automatic to the canvas element (canvas_element.getContext(&#039;2d&#039;).drawImage(selected_image_element)).&lt;br /&gt;
&lt;br /&gt;
Additionally, we can also insert a new button into the toolbar of TinyMCE 3 to directly invoke PaintWeb.&lt;br /&gt;
&lt;br /&gt;
The integration of the paint tool will be seamless to the user. He will be able to edit any image, at any moment. Once the user completes editing, he can pick the Save option to save the modified image, and then return to TinyMCE 3 by clicking &amp;quot;Finish&amp;quot;. All of this will use AJAX, and will not require entire page reloads.&lt;br /&gt;
&lt;br /&gt;
PaintWeb will also work inside the fullscreen mode of TinyMCE 3.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These are not screenshots from an actual running PaintWeb. This is a &amp;quot;photoshopped&amp;quot; rendition of how I would like to integrate PaintWeb into Moodle 2 and TinyMCE 3. For the actual implementation I will do further adjustments and improvements.&lt;br /&gt;
&lt;br /&gt;
== Moodle integration ==&lt;br /&gt;
&lt;br /&gt;
PaintWeb.php will provide an API which will allow the embedding of PaintWeb in a standalone version, all by itself, on any page where a Moodle developer wants. It will provide an API for easy loading and saving of images.&lt;br /&gt;
&lt;br /&gt;
Additionally, an API for dynamic inclusion of PaintWeb will be provided, via AJAX. Such that, from any place, PaintWeb can be loaded dynamically.&lt;br /&gt;
&lt;br /&gt;
I would like us to integrate PaintWeb inside the file manager, to allow editing of images there.&lt;br /&gt;
&lt;br /&gt;
= Goals =&lt;br /&gt;
&lt;br /&gt;
We need to have a clear focus, and a proper set of goals for the end of the summer. As such, my goal is to have the paint tool usable from TinyMCE, and optionally from the file manager.&lt;br /&gt;
&lt;br /&gt;
I can offer to further help the Moodle community after the summer with any new code I will work on from there on for PaintWeb. I will try my best to fix any of the bugs reported in the component, and to upgrade it whenever I have a new release.&lt;br /&gt;
&lt;br /&gt;
Planning for other features, like realtime collaboration, would not be a realistic aim for such a short period of time. Therefore, any user feedback should focus on the stated goals and how we can improve the outcome of the project.&lt;br /&gt;
&lt;br /&gt;
= Timeline =&lt;br /&gt;
&lt;br /&gt;
Once I am accepted for GSoC, I want to get started working on the project. This means I will start working from April 21 (I will not wait for May 23).&lt;br /&gt;
&lt;br /&gt;
Based on experience I estimate the following preliminary implementation timeline:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;April 21 - May 4&#039;&#039;&#039;. Two weeks for reorganizing, extending, improving the entire current demo / proof of concept code from PaintWeb. This means I will do code separation into multiple files (like described above) and add jsdoc comments. While doing code separation, I will also make sure it&#039;s easier to extend/add new tools (making things more modular). I will make sure the paint tool can be easily configured to use a different GUI and different keyboard shortcuts.&lt;br /&gt;
* &#039;&#039;&#039;May 5 - May 12&#039;&#039;&#039;. One week for testing and reviewing. Report any bugs found and code review feedback. Testing can continue afterwards in parallel, while I&#039;m doing other work.&lt;br /&gt;
* &#039;&#039;&#039;May 13 - May 20&#039;&#039;&#039;. One week for making the code cross-browser compatible, on those browsers with native Canvas API support. Basically, this means working around the lack of the native Text API in Opera and Firefox 3.0.&lt;br /&gt;
* &#039;&#039;&#039;May 21 - May 28&#039;&#039;&#039;. One-two weeks for implementing the new proposed GUI, with further improvements. This requires working on the HTML markup, CSS code and any JS associated with user interaction.&lt;br /&gt;
* &#039;&#039;&#039;May 29 - June 5&#039;&#039;&#039;. One week for testing and reviewing of the GUI. Again, once the week is over any testing can continue in parallel.&lt;br /&gt;
* &#039;&#039;&#039;June 6 - June 20&#039;&#039;&#039;. Two weeks for integrating PaintWeb into TinyMCE and Moodle, both client-side and server-side work. This means I will add the new paint tool button into TinyMCE, and I will make sure editing and saving images within the editor works. Obviously, this is where the most help / consulting will be needed from my mentor (Martin). &lt;br /&gt;
* &#039;&#039;&#039;June 21 - June 28&#039;&#039;&#039;. One week for testing and reviewing the PaintWeb integration. This will also continue in parallel after the week is over.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around August&#039;&#039;&#039;. One-two weeks for making the paint tool work in MSIE. During this stage I will test ExplorerCanvas and other projects which implement Canvas support in IE.&lt;br /&gt;
* (Optional) &#039;&#039;&#039;Around September&#039;&#039;&#039;. One week or more for implementing new features: bucket fill tool, rectangles with rounded corners, spray tool, grid lines, image/selection rotate, basic image filters (like invert, grayscale, etc), and maybe layers as well.&lt;br /&gt;
&lt;br /&gt;
The timeline depends a lot on community help and any additional requirements made while working on the project.&lt;br /&gt;
&lt;br /&gt;
Additionally, university exams are held some time during June here. I do not know precisely when, it depends on each professor to pick the date. I&#039;ll have 5 exams. This will stretch the above timeline by about three weeks. I did not include these delays in the timeline above because I do not know where to insert them. Thus, the above dates are more of &#039;ideal&#039; dates.&lt;br /&gt;
&lt;br /&gt;
In any case, by mid-term evaluation (July 6th - July 13th) I want to have the first stages completed (code reorganization + new GUI). By &#039;pencils down&#039; date (August 10 - August 17) I want to have the PaintWeb integration done and tested.&lt;br /&gt;
&lt;br /&gt;
I will announce on the dev forums when each stage is complete.&lt;br /&gt;
&lt;br /&gt;
Once GSoC 2009 has ended I would like to continue working, when I have time.&lt;br /&gt;
&lt;br /&gt;
= Why me =&lt;br /&gt;
&lt;br /&gt;
I have a keen interest into Web standards and educational software. I am currently pursuing the Bachelor of Science degree at [http://www.uav.ro UAV].&lt;br /&gt;
&lt;br /&gt;
My expertise into Web standards and technologies has been gradually building for the last 10 years. I have come to code my own content management system, and my own WYSIWYG HTML editor. I am also coding my own JavaScript library.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am a constant user of educational software since I started school. I continue to use such software even now during University studies. I have experience with Keypress Geometry Sketchpad, and with other mathematical editor tools (such as Mathematica, LyX and more). I have come to know what children and students need improved in the educational software available today. Last year I had a presentation at the [http://www.uvvg.ro Vasile Goldiş University] where I have presented several of my ideas for improving current educational software. One of the applications tested was Moodle itself.&lt;br /&gt;
&lt;br /&gt;
When time allowed, I have made contributions to several Web specifications (among them: [http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML 5] and [http://www.w3.org/TR/xbl/ XBL 2]). My contributions/reviews prompted the editor of the specifications in question to make changes as suggested.&lt;br /&gt;
&lt;br /&gt;
[http://www.opera.com Opera Software] published several [http://dev.opera.com/author/112520 tutorials] I wrote, which detail technical aspects of some new Web technologies, like VoiceXML and Canvas.&lt;br /&gt;
&lt;br /&gt;
In previous national contests of Web applications I have ranked among the first, if not the first.&lt;br /&gt;
&lt;br /&gt;
I closely watch the entire Web browser market and technologies, keeping myself up to date. I am aware of many emerging Web technologies. Thus, I can base my decisions better on which technologies to use.&lt;br /&gt;
&lt;br /&gt;
Last, but not least, I have a fairly good deal of head-start when it comes to developing a paint tool for Moodle. My [http://code.google.com/p/paintweb PaintWeb] demo/proof of concept is fairly usable and I can get to work from day one, no need to do any catchup with any APIs, no need to learn anything.&lt;br /&gt;
&lt;br /&gt;
= In the future =&lt;br /&gt;
&lt;br /&gt;
Ultimately, I would like to see Moodle have a paint tool which allows editing of multiple file formats: bitmapped images and SVGs (vector drawing as well), If we do the project described here, by the end of the summer we will be half way through the ultimate goal. By the end of the year, with sufficient dedication and help from other developers, SVG editing should be doable.&lt;br /&gt;
&lt;br /&gt;
In the future, I would also like to help improve the HTML markup and the entire JavaScript codebase used by Moodle.&lt;br /&gt;
&lt;br /&gt;
For PaintWeb I plan to make its codebase versatile. Meaning, I want it to be able to use multiple different GUIs and keyboard shortcuts just by simply changing a single config string. This would allow PaintWeb to be used on systems with fewer resources with a simpler UI, and in different configurations (say in a realtime chat room). I also want it to be able to use different backends for storage (e.g. Google Gears, Adobe AIR, etc), and different plugins (e.g. additional plugins for a realtime chat room would be needed).&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
&lt;br /&gt;
I am looking forward to a fruitful collaboration with the Moodle community of users and developers for the common goal of improving educational software for everyone.&lt;br /&gt;
&lt;br /&gt;
I should also note that I am committing full-time to this project over the summer. It is my desire to have a a well done project within a friendly community as this one. I will be online daily available on Jabber chat, IRC chat and email for any communication.&lt;br /&gt;
&lt;br /&gt;
Any questions and suggestions are welcome.&lt;br /&gt;
&lt;br /&gt;
= Latest updates =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;May 9, 2009:&#039;&#039;&#039; [https://docs.moodle.org/en/Development:Paint_tool_questions Paint tool questions] to potential users.&lt;br /&gt;
* &#039;&#039;&#039;May 2, 2009:&#039;&#039;&#039; Using Moodle [http://moodle.org/mod/forum/discuss.php?d=122460 Thoughts on the paint tool interface] forum discussion&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55495</id>
		<title>Paint tool questions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55495"/>
		<updated>2009-05-09T09:10:29Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: corrections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
I am [http://moodle.org/user/view.php?id=832305&amp;amp;course=1 Mihai Sucan], one of the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] students. I will be developing a new paint tool for Moodle. The Web application will not require any browser plugins. Drawing will be only bitmap-based. The gist of the code will be JavaScript mostly, with some server-side code for integration into Moodle.&lt;br /&gt;
&lt;br /&gt;
The main goal of the project are to is a working, simple to use paint tool for kids. For adults, the tool could also act as a quick way to draw something on a whiteboard. First and foremost, we plan to integrate [http://code.google.com/p/paintweb PaintWeb] into [http://tinymce.moxiecode.com TinyMCE] so that users will be able to click &amp;quot;&#039;&#039;&#039;Edit image&#039;&#039;&#039;&amp;quot; for any image element they have in the HTML article they are editing. This will invoke the paint tool from where any changes can be made, and then saved back to the server.&lt;br /&gt;
&lt;br /&gt;
Beyond the stated goals, we cannot expect too many things in addition, since three months is not much time. We did think about implementing layers support, vector shapes, realtime collaboration in Chat between multiple users, and more. However, such features are not a realistic aim for the end of the summer. This doesn&#039;t mean such features will never become available - we might go ahead and implement some after the summer.&lt;br /&gt;
&lt;br /&gt;
Please [https://docs.moodle.org/en/Development:Paint_tool read the specification], and also please check out the [http://code.google.com/p/paintweb/ Google Code PaintWeb project] where you can play with the paint tool already.&lt;br /&gt;
&lt;br /&gt;
This wiki page serves the purpose of listing questions to potential users of the paint tool. I want to understand how teachers/users would want the paint tool integrated, how they want to use it, for what, etc.&lt;br /&gt;
&lt;br /&gt;
I welcome any additional feedback, besides answers to the questions below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Thanks go to [http://moodle.org/user/view.php?id=141847&amp;amp;course=1 Olli Savolainen] for his [http://moodle.org/mod/forum/discuss.php?d=122460 valuable feedback] provided on the forums!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
== Background information ==&lt;br /&gt;
&lt;br /&gt;
* Are you a teacher? What do you teach?&lt;br /&gt;
* Please describe what you do, your interests, and why you use Moodle.&lt;br /&gt;
* Please describe why you would want a paint tool in Moodle.&lt;br /&gt;
* How much do you use computers? How about Web browsers?&lt;br /&gt;
* Do you have experience with other educational platforms?&lt;br /&gt;
* Do you have experience with other drawing tools? online? offline?&lt;br /&gt;
* Do you have experience wth dynamic geometry software? Like [http://www.geogebra.org Geogebra], [http://www.dynamicgeometry.com Sketchpad], [http://edu.kde.org/kig/ Kig] or others.&lt;br /&gt;
** Out of the dynamic geometry applications you have tested, name the one you like most.&lt;br /&gt;
** Also, please tell me the one you use most often. (might not always be the same as the most liked application...)&lt;br /&gt;
* Do your students have disabilities? Please explain which kind of disabilities.&lt;br /&gt;
** Do their disabilities impose some kind of requirements on a paint tool and on software in general? Please explain.&lt;br /&gt;
&lt;br /&gt;
== Project goals ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how the stated goals fit into user needs.&lt;br /&gt;
&lt;br /&gt;
* What&#039;s the first thing that came into your mind when you heard a paint tool is being developed during GSOC for Moodle?&lt;br /&gt;
* Do the stated goals come close to what you expected? Please explain.&lt;br /&gt;
** If not, what would you believe is more important?&lt;br /&gt;
** If this is not really what you want, would you still use it?&lt;br /&gt;
* If you would have to choose having only one Web application, what would you like in Moodle:&lt;br /&gt;
** a dynamic geometry application,&lt;br /&gt;
** a vector drawing tool,&lt;br /&gt;
** or a bitmapped drawing tool?&lt;br /&gt;
&lt;br /&gt;
== Technical requirements ==&lt;br /&gt;
&lt;br /&gt;
* What are the system, OS and browser requirements for the paint tool in your case? &lt;br /&gt;
* Please describe your usage environment (operating systems, browsers, general system performance, etc).&lt;br /&gt;
* Would you use the paint tool if it only works on one of the following operating systems: Windows, Linux, or Mac?&lt;br /&gt;
* Would you use the paint tool if it only works in Internet Explorer? Would you use it if it works in all major browsers except Internet Explorer?&lt;br /&gt;
* What screen resolution do you generally use?&lt;br /&gt;
* What image dimensions would you expect to use? (images of a high resolution need additional system resources)&lt;br /&gt;
* Your Internet connection speed?&lt;br /&gt;
** How about the school, how&#039;s the Internet connection speed?&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
* As a teacher, would you ask your young students to do drawing assignments/exams in an online environment?&lt;br /&gt;
** How would you do that? Please explain usage scenarios:&lt;br /&gt;
*** How you would create an assignment/exam?&lt;br /&gt;
*** Where you would like to find the paint tool?&lt;br /&gt;
*** How would you use it?&lt;br /&gt;
* Do you want the paint tool to be available anywhere TinyMCE is used for article editing? Such that you can edit any image in your article.&lt;br /&gt;
** If not, where would you like it only?&lt;br /&gt;
* When would you require your students to draw on a physical support instead of using the digital drawing pad?&lt;br /&gt;
** How about the other way around, requiring students to use the Moodle painting tool instead of a physical whiteboard?&lt;br /&gt;
* What impact do you believe a painting tool would have on how you teach drawing to children?&lt;br /&gt;
* How do you proceed when you ask your students to draw something? What&#039;s the process, from start to finish?&lt;br /&gt;
* Based on current process, what would you like in a Moodle painting tool?&lt;br /&gt;
* Do you find the current process of inserting drawings into Moodle cumbersome?&lt;br /&gt;
** What would improve things for you?&lt;br /&gt;
* Name something you do not like in the current process of working with drawings/images in Moodle.&lt;br /&gt;
* Name what you like most about Moodle in regards to working with drawings.&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for quick-drawing of some mathematical formulas?&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for drawing geometry shapes? Triangles, rectangles, etc. (even if it&#039;s not a dynamic geometry application)&lt;br /&gt;
* In which teaching situations would you use a paint tool?&lt;br /&gt;
** Would these situations have different requirements on the application? (user interface, interaction, integration, etc)&lt;br /&gt;
&lt;br /&gt;
== Tools and features ==&lt;br /&gt;
&lt;br /&gt;
* Does the current set of drawing tools satisfy your needs?&lt;br /&gt;
* Which new tools you want added?&lt;br /&gt;
** Please name a few new tools you deem as required.&lt;br /&gt;
* Do you want predefined shapes?&lt;br /&gt;
** Please list some of the ones you would need most often.&lt;br /&gt;
* How important would be the ability to replay the drawing construction?&lt;br /&gt;
* How important is to have multiple layers support?&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55484</id>
		<title>Paint tool questions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Paint_tool_questions&amp;diff=55484"/>
		<updated>2009-05-08T20:04:46Z</updated>

		<summary type="html">&lt;p&gt;Robodesign: /* Summary */ fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Summary =&lt;br /&gt;
&lt;br /&gt;
I am, [http://moodle.org/user/view.php?id=832305&amp;amp;course=1 Mihai Sucan], one of the [https://docs.moodle.org/en/GSOC/2009 Google Summer of Code 2009] students. I am developing over the summer a new paint tool for Moodle. The Web application will not require any browser plugins. Drawing will be bitmap-based, no vector shapes. The gist of the code will be JavaScript mostly, with some server-side code for integration into Moodle.&lt;br /&gt;
&lt;br /&gt;
The main goals of the project is to create a working, simple to use paint tool for kids. For adults, the tool could also act as a quick way to draw something on a whiteboard. First and foremost, we plan to integrate PaintWeb into TinyMCE so that users will be able to click &#039;Edit image&amp;quot; for any image element they have in the HTML article they are editing. This will invoke the paint tool from where any changes can be done, and then saved back to the server.&lt;br /&gt;
&lt;br /&gt;
Beyond the stated goals, we cannot expect too many things in addition, since three months is not much time. We did think about implementing layers support, vector shapes, realtime collaboration in Chat between multiple users, and more. However, such features are not a realistic aim for the end of the summer.&lt;br /&gt;
&lt;br /&gt;
Please [https://docs.moodle.org/en/Development:Paint_tool read the specification], and also please check out the [http://code.google.com/p/paintweb/ Google Code PaintWeb project] where you can play with the paint tool already.&lt;br /&gt;
&lt;br /&gt;
This wiki page serves the purpose of listing questions to potential users of the paint tool. I want to understand how teachers/users would want the paint tool integrated, how they want to use it, for what, etc.&lt;br /&gt;
&lt;br /&gt;
I welcome any additional feedback, besides answers to the questions below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Thanks go to [http://moodle.org/user/view.php?id=141847&amp;amp;course=1 Olli Savolainen] for his [http://moodle.org/mod/forum/discuss.php?d=122460 valuable feedback] provided on the forums!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
== Background information ==&lt;br /&gt;
&lt;br /&gt;
* Are you a teacher? What do you teach?&lt;br /&gt;
* Please describe what you do, your interests, and why you use Moodle.&lt;br /&gt;
* Please describe why you would want a paint tool in Moodle.&lt;br /&gt;
* How much do you use computers? How about Web browsers?&lt;br /&gt;
* Do you have experience with other educational platforms?&lt;br /&gt;
* Do you have experience with other drawing tools? online? offline?&lt;br /&gt;
* Do you have experience wth dynamic geometry software? Like [http://www.geogebra.org Geogebra], [http://www.dynamicgeometry.com Sketchpad], [http://edu.kde.org/kig/ Kig] or others.&lt;br /&gt;
** Out of the dynamic geometry applications you have tested, name the one you like most.&lt;br /&gt;
** Also please tell me the one you use most often. (might not always be the same as the most liked application...)&lt;br /&gt;
* Do your students have disabilities? Please explain which kind of disabilities.&lt;br /&gt;
&lt;br /&gt;
== Project goals ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how the stated goals fit into user needs.&lt;br /&gt;
&lt;br /&gt;
* What&#039;s the first thing that came into your mind when you heard a paint tool is being developed during GSOC?&lt;br /&gt;
* Do the stated goals come close to what you expected? Please explain if yes or not.&lt;br /&gt;
* If not, what would believe is more important?&lt;br /&gt;
* If this is not really what you want, would you still use it?&lt;br /&gt;
* If you would have to choose having only one Web application, what would you like in Moodle:&lt;br /&gt;
** a dynamic geometry application,&lt;br /&gt;
** a vector drawing tool,&lt;br /&gt;
** or a bitmapped drawing tool?&lt;br /&gt;
&lt;br /&gt;
== Technical requirements ==&lt;br /&gt;
&lt;br /&gt;
* What are the system/OS/browser requirements for the paint tool in your case?&lt;br /&gt;
* Please describe your usage environment (operating systems, browsers, general system performance, etc).&lt;br /&gt;
* Would you use the paint tool if it only works on one of the following operating systems: Windows, Linux, or Mac?&lt;br /&gt;
* Would you use the paint tool if it only works in Internet Explorer? Would you use it if it works in all major browsers except Internet Explorer?&lt;br /&gt;
* What screen resolution do you generally use? What image dimensions would you expect to use? (images of a high resolution need additional system resources)&lt;br /&gt;
* Your Internet connection speed? How about the school, how&#039;s the Internet connection speed?&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
* As a teacher, would you ask your young students to do drawing assignments/exams in an online environment?&lt;br /&gt;
* How would you to that? Please explain usage scenarios: how you would create an assignment/exam, where you would like to find the paint tool and how you would use it?&lt;br /&gt;
* Do you want the paint tool to be available anywhere TinyMCE article editing is done? Such that you can edit any image in your article.&lt;br /&gt;
* If not, where would you like it only?&lt;br /&gt;
* When would you require your students to draw on a physical support instead of using the digital drawing pad? How about the other way around, requiring students to use the Moodle painting tool instead of a physical whiteboard?&lt;br /&gt;
* What impact do you believe a painting tool would have on how you teach drawing to children?&lt;br /&gt;
* How do you proceed when you ask your students to draw something? What&#039;s the process, from start to finish?&lt;br /&gt;
* Based on current process, what would you like in a Moodle painting tool?&lt;br /&gt;
* Do you find the current process of inserting drawings into Moodle cumbersome? What would improve things for you?&lt;br /&gt;
* Name something you do not like in the current process of working with drawings/images in Moodle.&lt;br /&gt;
* Name what you like most about Moodle in regards to working with drawings.&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for quick-drawing of some mathematical formulas?&lt;br /&gt;
* Would you use the proposed painting tool in Moodle for drawing geometry shapes? Triangles, rectangles, etc. (even if it&#039;s not a dynamic geometry application)&lt;br /&gt;
* In which teaching situations would you use a paint tool? Would these have different requirements on the application? (user interface, interaction, integration, etc)&lt;br /&gt;
&lt;br /&gt;
== Tools and features ==&lt;br /&gt;
&lt;br /&gt;
* Does the current set of drawing tools satisfy your needs?&lt;br /&gt;
* Which new tools you want added? What do you believe *must* be added?&lt;br /&gt;
* Do you want predefined shapes? Please list some of the ones you would need most often.&lt;br /&gt;
* How important would be the ability to replay the drawing construction?&lt;br /&gt;
* How important would be to have layer support?&lt;/div&gt;</summary>
		<author><name>Robodesign</name></author>
	</entry>
</feed>