Drawing vector graphics in js widgets

Aaron J. Seigo aseigo at kde.org
Thu Feb 25 02:27:34 CET 2010


On February 24, 2010, Mohamed Ikbel Boulabiar wrote:
> Thanks for the answer and for the api errata you send yesterday.
> 
> I tried with the code below, but it only draws things without changing
> the properties of the pen.
> 
> 
> //////////////////
> var painter = new QPainter
> var pen = new QPen
> 
> pen.color = new QColor("red")
> pen.width = 15
> //painter.setbrush = pen.brush
> //painter.pen = pen
> painter.setpen = pen

there is no painter object until paintInterface is called, and it's local to 
paintInterface.

> plasmoid.paintInterface = function(painter)
> {
>   painter.drawEllipse(30, 40, 120, 113)
>   painter.drawRect(22, 21, 20, 13)
> }

so instead do:

plasmoid.paintInterface = function(painter)
{
  painter.pen = pen
  painter.drawEllipse(30, 40, 120, 113)
  painter.drawRect(22, 21, 20, 13)
}


-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks


More information about the Plasma-devel mailing list