June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,3 +1,4 @@
/*Code verified and output corrected by Abhishek Ghosh, 23rd September 2017*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

View file

@ -3,17 +3,13 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
canvas {
background-color: black;
}
</style>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.querySelector("canvas");
@ -25,8 +21,8 @@
canvas.addEventListener("mousemove", function (event) {
prevMouseX = mouseX;
prevMouseY = mouseY;
mouseX = event.clientX;
mouseY = event.clientY;
mouseX = event.x;
mouseY = event.y;
var incrX = (mouseX - prevMouseX) * 0.01;
var incrY = (mouseY - prevMouseY) * 0.01;
@ -100,5 +96,4 @@
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
_pr(t::Dict, x::Int, y::Int, z::Int) = join((rstrip(join(t[(n, m)] for n in range(0, 3+x+z))) for m in reverse(range(0, 3+y+z))), "\n")
function cuboid(x::Int, y::Int, z::Int)
t = Dict((n, m) => " " for n in range(0, 3 + x + z), m in range(0, 3 + y + z))
xrow = vcat("+", collect("$(i % 10)" for i in range(0, x)), "+")
for (i, ch) in enumerate(xrow) t[(i, 0)] = t[(i, 1+y)] = t[(1+z+i, 2+y+z)] = ch end
yrow = vcat("+", collect("$(j % 10)" for j in range(0, y)), "+")
for (j, ch) in enumerate(yrow) t[(0, j)] = t[(x+1, j)] = t[(2+x+z, 1+z+j)] = ch end
zdep = vcat("+", collect("$(k % 10)" for k in range(0, y)), "+")
for (k, ch) in enumerate(xrow) t[(k, 1+y+k)] = t[(1+x+k, 1+y+k)] = t[(1+x+k, k)] = ch end
return _pr(t, x, y, z)
end
for (x, y, z) in [(2, 3, 4), (3, 4, 2), (4, 2, 3), (5, 5, 6)]
println("\nCUBOID($x, $y, $z)\n")
println(cuboid(x, y, z))
end

View file

@ -0,0 +1,61 @@
# Project : Draw a cuboid
# Date : 2018/01/18
# Author : Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
load "guilib.ring"
paint = null
new qapp
{
win1 = new qwidget() {
setwindowtitle("Draw a cuboid")
setgeometry(100,100,500,600)
label1 = new qlabel(win1) {
setgeometry(10,10,400,400)
settext("")
}
new qpushbutton(win1) {
setgeometry(150,500,100,30)
settext("draw")
setclickevent("draw()")
}
show()
}
exec()
}
func draw
p1 = new qpicture()
color = new qcolor() {
setrgb(0,0,255,255)
}
pen = new qpen() {
setcolor(color)
setwidth(1)
}
paint = new qpainter() {
begin(p1)
setpen(pen)
color = new qcolor()
color.setrgb(255,0,0,255)
mybrush = new qbrush() {setstyle(1) setcolor(color)}
setbrush(mybrush)
paint.drawPolygon([[200,200],[300,200],[300,100],[200,100]], 0)
color = new qcolor()
color.setrgb(0,255,0,255)
mybrush = new qbrush() {setstyle(1) setcolor(color)}
setbrush(mybrush)
paint.drawPolygon([[200,100],[250,50],[350,50],[300,100]], 0)
color = new qcolor()
color.setrgb(0, 0, 255,255)
mybrush = new qbrush() {setstyle(1) setcolor(color)}
setbrush(mybrush)
paint.drawPolygon([[350,50],[350,150],[300,200],[300,100]], 0)
endpaint()
}
label1 { setpicture(p1) show() }
return