Color wheel: Difference between revisions
Content added Content deleted
m (correction: cyan (blue) at 210 degrees) |
(Added Vala) |
||
Line 1,572: | Line 1,572: | ||
This file is no longer there!!! 10 Sep 2021 |
This file is no longer there!!! 10 Sep 2021 |
||
=={{header|Vala}}== |
|||
{{trans|Julia}} |
|||
<syntaxhighlight lang="vala">public class Example: Gtk.Application { |
|||
private Gtk.ApplicationWindow window; |
|||
private Gtk.DrawingArea drawing_area; |
|||
public Example() { |
|||
Object(application_id: "my.application", flags: ApplicationFlags.FLAGS_NONE); |
|||
this.activate.connect(() => { |
|||
window = new Gtk.ApplicationWindow(this); |
|||
drawing_area = new Gtk.DrawingArea(); |
|||
drawing_area.set_draw_func(draw_circle); |
|||
window.set_child(drawing_area); |
|||
window.present(); |
|||
}); |
|||
} |
|||
private void draw_circle(Gtk.DrawingArea area, Cairo.Context cr, int width, int height) { |
|||
int centerx = width / 2; |
|||
int centery = height / 2; |
|||
double anglestep = 1.0 / width; |
|||
for (float theta = (float) 0.0; theta < 360; theta += (float) 0.1) { |
|||
float r; |
|||
float g; |
|||
float b; |
|||
Gtk.hsv_to_rgb(theta / (float) 360.0, 1, 1, out r, out g, out b); |
|||
cr.set_source_rgb(r, g, b); |
|||
cr.line_to(centerx, centery); |
|||
cr.arc(centerx, centery, ((double) width) / 2.2, GLib.Math.PI * 2 * theta / 360.0, anglestep); |
|||
cr.line_to(centerx, centery); |
|||
cr.stroke(); |
|||
} |
|||
} |
|||
public static int main(string[] argv) { |
|||
var app = new Example(); |
|||
return app.run(argv); |
|||
} |
|||
}</syntaxhighlight> |
|||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
Building a BMP file and opening it with the default viewer. It takes 5 seconds in my 5 years old notebook. Run with Cscript if you don want to be clicking at annoying message boxes. |
Building a BMP file and opening it with the default viewer. It takes 5 seconds in my 5 years old notebook. Run with Cscript if you don want to be clicking at annoying message boxes. |
||
Line 1,855: | Line 1,893: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{out}}== |
=={{out}}== |
||
[[File:Colorwheel vbs.png]] |
[[File:Colorwheel vbs.png]] |