YAPC::EU 2018 Glasgow Update!

This commit is contained in:
Ingy döt Net 2018-08-17 15:15:24 +01:00
parent 22f33d4004
commit 4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions

View file

@ -0,0 +1,4 @@
" :htdiW">:#,_>&>00p" :thgieH">:#,_>&>:10p0" :htpeD">:#,_$>&>:20p55+,+:1`*:vv
v\-*`0:-g01\++*`\0:-\-1g01:\-*`0:-g02\+*`\0:-\-1g02<:::::<\g3`\g01:\1\+55\1-1_v
>":"\1\:20g\`!3g:30p\00g2*\::20g\`\20g1-\`+1+3g\1\30g\:20g-::0\`\2*1+*-\48*\:^v
/\_ @_\#!:!#$>#$_\#!:,#-\#1 <+1\<*84g02"_"+1*2g00+551$<

View file

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

View file

@ -1,7 +1,4 @@
# Project : Draw a cuboid
# Date : 2018/01/18
# Author : Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
load "guilib.ring"

View file

@ -0,0 +1,91 @@
import java.awt._
import java.awt.event.{MouseAdapter, MouseEvent}
import javax.swing._
import scala.math.{Pi, cos, sin}
object Cuboid extends App {
SwingUtilities.invokeLater(() => {
class Cuboid extends JPanel {
private val nodes: Array[Array[Double]] =
Array(Array(-1, -1, -1), Array(-1, -1, 1), Array(-1, 1, -1), Array(-1, 1, 1),
Array(1, -1, -1), Array(1, -1, 1), Array(1, 1, -1), Array(1, 1, 1))
private var mouseX, prevMouseX, mouseY, prevMouseY: Int = _
private def edges =
Seq(Seq(0, 1), Seq(1, 3), Seq(3, 2), Seq(2, 0),
Seq(4, 5), Seq(5, 7), Seq(7, 6), Seq(6, 4),
Seq(0, 4), Seq(1, 5), Seq(2, 6), Seq(3, 7))
override def paintComponent(gg: Graphics): Unit = {
val g = gg.asInstanceOf[Graphics2D]
def drawCube(g: Graphics2D): Unit = {
g.translate(getWidth / 2, getHeight / 2)
for (edge <- edges) {
g.drawLine(nodes(edge.head)(0).round.toInt, nodes(edge.head)(1).round.toInt,
nodes(edge(1))(0).round.toInt, nodes(edge(1))(1).round.toInt)
}
for (node <- nodes) g.fillOval(node(0).round.toInt - 4, node(1).round.toInt - 4, 8, 8)
}
super.paintComponent(gg)
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
drawCube(g)
}
private def scale(sx: Double, sy: Double, sz: Double): Unit = {
for (node <- nodes) {
node(0) *= sx
node(1) *= sy
node(2) *= sz
}
}
private def rotateCube(angleX: Double, angleY: Double): Unit = {
val (sinX, cosX, sinY, cosY) = (sin(angleX), cos(angleX), sin(angleY), cos(angleY))
for (node <- nodes) {
val (x, y, z) = (node.head, node(1), node(2))
node(0) = x * cosX - z * sinX
node(2) = z * cosX + x * sinX
node(1) = y * cosY - node(2) * sinY
node(2) = node(2) * cosY + y * sinY
}
}
addMouseListener(new MouseAdapter() {
override def mousePressed(e: MouseEvent): Unit = {
mouseX = e.getX
mouseY = e.getY
}
})
addMouseMotionListener(new MouseAdapter() {
override def mouseDragged(e: MouseEvent): Unit = {
prevMouseX = mouseX
prevMouseY = mouseY
mouseX = e.getX
mouseY = e.getY
rotateCube((mouseX - prevMouseX) * 0.01, (mouseY - prevMouseY) * 0.01)
repaint()
}
})
scale(80, 120, 160)
rotateCube(Pi / 5, Pi / 9)
setPreferredSize(new Dimension(640, 640))
setBackground(Color.white)
}
new JFrame("Cuboid") {
add(new Cuboid, BorderLayout.CENTER)
pack()
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
setLocationRelativeTo(null)
setResizable(false)
setVisible(true)
}
})
}

View file

@ -0,0 +1,48 @@
x = 6 : y = 2 : z = 3
Sub cuboid(nx, ny, nz)
WScript.StdOut.WriteLine "Cuboid " & nx & " " & ny & " " & nz & ":"
lx = X * nx : ly = y * ny : lz = z * nz
'define the array
Dim area(): ReDim area(ly+lz, lx+ly)
For i = 0 to ly+lz
For j = 0 to lx+ly : area(i,j) = " " : Next
Next
'drawing lines
For i = 0 to nz-1 : drawLine area, lx, 0, Z*i, "-" : Next
For i = 0 to ny : drawLine area, lx, y*i, lz+y*i, "-" : Next
For i = 0 to nx-1 : drawLine area, lz, x*i, 0, "|" : Next
For i = 0 to ny : drawLine area, lz, lx+y*i, y*i, "|" : Next
For i = 0 to nz-1 : drawLine area, ly, lx, z*i, "/" : Next
For i = 0 to nx : drawLine area, ly, x*i, lz, "/" : Next
'output the cuboid (in reverse)
For i = UBound(area,1) to 0 Step -1
linOut = ""
For j = 0 to UBound(area,2) : linOut = linOut & area(i,j) : Next
WScript.StdOut.WriteLine linOut
Next
End Sub
Sub drawLine(arr, n, sx, sy, c)
Select Case c
Case "-"
dx = 1 : dy = 0
Case "|"
dx = 0 : dy = 1
Case "/"
dx = 1 : dy = 1
End Select
For i = 0 to n
xi = sx + (i * dx) : yi = sy + (i * dy)
If arr(yi, xi) = " " Then
arr(yi, xi) = c
Else
arr(yi, xi) = "+"
End If
Next
End Sub
cuboid 2,3,4