我一直在尝试编写一个能够绘制圆形图形的函数。我尝试使用距离公式来计算我的观点:
@Override
public void GETCoins() {
String url = "https://www.cryptocompare.com/api/data/coinlist/";
Log.d("Debug ", "URL: " + url);
//Run async task to pull weather data. weatherTask.get... forces main thread to wait for this to finish
HTTPAsyncTask coinTask = new HTTPAsyncTask(this);
coinTask.execute(url, "GET");
try {
JSONObject jsonObject = new JSONObject(coinTask.get());
JSONObject obj = new JSONObject(jsonObject.getString("Data"));
Iterator<?> keys = obj.keys();
int i = 0;
while(keys.hasNext() ) {
String key = (String) keys.next();
if(obj.get(key) instanceof JSONObject) {
JSONObject val = new JSONObject(obj.get(key).toString());
String imageUrl = baseImageUrl + val.getString("ImageUrl");
String name = val.getString("Name");
String currency = val.getString("CoinName");
CryptoData data = new CryptoData(i, currency, 0,0, imageUrl, name);
allCurrencyList.add(data);
i++;
}
}
//updateData(jsonObject);
} catch (InterruptedException | JSONException | ExecutionException e) {
e.printStackTrace();
} finally {
Log.d("Debug ", "Coin API is null");
}
}
那不起作用,所以我看了别人的代码圈。这就是:
def distance_form(x1, y1, x2, y2):
d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
return d
我在数学上很不错,但我不确定这意味着什么。
答案 0 :(得分:1)
我认为这样做的标准方法是使用create_oval。
oval = canvas.create_oval(x0, y0, x1, y1, options)
希望它有所帮助。干杯!